Skip to content

Commit

Permalink
Fix tet face node ordering to be consistent with rd.Fmask (#172)
Browse files Browse the repository at this point in the history
* reorder tet face nodes to be consistent with Fmask

* fix periodic BCs in 3D (broken by changing tet face node order)

* remove cruft, preallocate p
  • Loading branch information
jlchan authored Jun 28, 2024
1 parent 7ec2f0a commit 44c8237
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
36 changes: 20 additions & 16 deletions src/connectivity_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,16 @@ function build_periodic_boundary_maps!(xf, yf, zf,
yfaces = map(x -> x[1], findall(@. (@. abs(yc - ymax) < NODETOL * LY) | (@. abs(yc - ymin) < NODETOL * LY)))
zfaces = map(x -> x[1], findall(@. (@. abs(zc - zmax) < NODETOL * LZ) | (@. abs(zc - zmin) < NODETOL * LZ)))

D = zeros(eltype(xb), size(xb,1), size(xb,1))
ids = zeros(Int, size(xb, 1))
p = zeros(Int, size(xb, 1))
if is_periodic_x # find matches in x faces
for i in xfaces, j in xfaces
if i!=j
if abs(yc[i] - yc[j]) < NODETOL * LY && abs(zc[i] - zc[j]) < NODETOL * LZ && abs(abs(xc[i] - xc[j]) - LX) < NODETOL * LX
# create distance matrix
@. D = abs(yb[:,i] - yb[:,j]') + abs(zb[:,i] - zb[:,j]')
map!(x->x[1], ids, findall(@. D < NODETOL * LY))
@. mapPB[:,i] = mapMB[ids,j]
if i!=j
if abs(yc[i] - yc[j]) < NODETOL * LY &&
abs(zc[i] - zc[j]) < NODETOL * LZ &&
abs(abs(xc[i] - xc[j]) - LX) < NODETOL * LX

match_coordinate_vectors!(p, (yb[:,i], zb[:,i]), (yb[:,j], zb[:,j]))
@. mapPB[:,i] = mapMB[p,j]

FToF[Bfaces[i]] = Bfaces[j]
end
Expand All @@ -341,10 +341,12 @@ function build_periodic_boundary_maps!(xf, yf, zf,
if is_periodic_y
for i in yfaces, j = yfaces
if i!=j
if abs(xc[i] - xc[j]) < NODETOL * LX && abs(zc[i] - zc[j]) < NODETOL * LZ && abs(abs(yc[i] - yc[j]) - LY) < NODETOL * LY
@. D = abs(xb[:,i] - xb[:,j]') + abs(zb[:,i] - zb[:,j]')
map!(x->x[1], ids, findall(@. D < NODETOL * LX))
@. mapPB[:,i] = mapMB[ids,j]
if abs(xc[i] - xc[j]) < NODETOL * LX &&
abs(zc[i] - zc[j]) < NODETOL * LZ &&
abs(abs(yc[i] - yc[j]) - LY) < NODETOL * LY

match_coordinate_vectors!(p, (xb[:,i], zb[:,i]), (xb[:,j], zb[:,j]))
@. mapPB[:,i] = mapMB[p,j]

FToF[Bfaces[i]] = Bfaces[j]
end
Expand All @@ -356,10 +358,12 @@ function build_periodic_boundary_maps!(xf, yf, zf,
if is_periodic_z
for i in zfaces, j in zfaces
if i!=j
if abs(xc[i] - xc[j]) < NODETOL * LX && abs(yc[i] - yc[j]) < NODETOL * LY && abs(abs(zc[i] - zc[j]) - LZ) < NODETOL * LZ
@. D = abs(xb[:,i] - xb[:,j]') + abs(yb[:,i] - yb[:,j]')
map!(x->x[1], ids, findall(@. D < NODETOL * LX))
@. mapPB[:,i] = mapMB[ids,j]
if abs(xc[i] - xc[j]) < NODETOL * LX &&
abs(yc[i] - yc[j]) < NODETOL * LY &&
abs(abs(zc[i] - zc[j]) - LZ) < NODETOL * LZ

match_coordinate_vectors!(p, (xb[:,i], yb[:,i]), (xb[:,j], yb[:,j]))
@. mapPB[:,i] = mapMB[p,j]

FToF[Bfaces[i]] = Bfaces[j]
end
Expand Down
8 changes: 4 additions & 4 deletions src/ref_elem_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ end
function map_face_nodes(::Tet, face_nodes...)
r, s = face_nodes
e = ones(size(r))
rf = [r; r; -e; r]
sf = [-e; s; r; s]
tf = [s; -(e + r + s); s; -e]
rf = [r; -(e + r + s); -e; r]
sf = [-e; r; r; s]
tf = [s; s; s; -e]
return rf, sf, tf
end

function init_face_data(elem::Tri; quad_rule_face = gauss_quad(0,0,N))
function init_face_data(elem::Tri; quad_rule_face = gauss_quad(0, 0, N))
r1D, w1D = quad_rule_face
e = ones(size(r1D))
z = zeros(size(r1D))
Expand Down

0 comments on commit 44c8237

Please sign in to comment.