From 113e7a113bfe3c1b73218b5b2c65e741e41cccc8 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Thu, 27 Jun 2024 19:18:23 -0500 Subject: [PATCH 1/3] reorder tet face nodes to be consistent with Fmask --- src/ref_elem_utils.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ref_elem_utils.jl b/src/ref_elem_utils.jl index 1fa75801..1049868d 100644 --- a/src/ref_elem_utils.jl +++ b/src/ref_elem_utils.jl @@ -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)) From 98fd73bd0a1713528f9d462e2a20fcdb6701e5fd Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Thu, 27 Jun 2024 19:18:58 -0500 Subject: [PATCH 2/3] fix periodic BCs in 3D (broken by changing tet face node order) --- src/connectivity_functions.jl | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/connectivity_functions.jl b/src/connectivity_functions.jl index da775d35..cec741fb 100644 --- a/src/connectivity_functions.jl +++ b/src/connectivity_functions.jl @@ -324,12 +324,13 @@ function build_periodic_boundary_maps!(xf, yf, zf, ids = 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 + + p = match_coordinate_vectors((yb[:,i], zb[:,i]), (yb[:,j], zb[:,j])) + @. mapPB[:,i] = mapMB[p,j] FToF[Bfaces[i]] = Bfaces[j] end @@ -341,10 +342,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 + + p = match_coordinate_vectors((xb[:,i], zb[:,i]), (xb[:,j], zb[:,j])) + @. mapPB[:,i] = mapMB[p,j] FToF[Bfaces[i]] = Bfaces[j] end @@ -356,10 +359,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 + + p = match_coordinate_vectors((xb[:,i], yb[:,i]), (xb[:,j], yb[:,j])) + @. mapPB[:,i] = mapMB[p,j] FToF[Bfaces[i]] = Bfaces[j] end From 46276dd2d3cb0b2c761d8583362a62be3d26e33c Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Thu, 27 Jun 2024 19:22:07 -0500 Subject: [PATCH 3/3] remove cruft, preallocate p --- src/connectivity_functions.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/connectivity_functions.jl b/src/connectivity_functions.jl index cec741fb..aa845354 100644 --- a/src/connectivity_functions.jl +++ b/src/connectivity_functions.jl @@ -320,8 +320,7 @@ 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 @@ -329,7 +328,7 @@ function build_periodic_boundary_maps!(xf, yf, zf, abs(zc[i] - zc[j]) < NODETOL * LZ && abs(abs(xc[i] - xc[j]) - LX) < NODETOL * LX - p = match_coordinate_vectors((yb[:,i], zb[:,i]), (yb[:,j], zb[:,j])) + match_coordinate_vectors!(p, (yb[:,i], zb[:,i]), (yb[:,j], zb[:,j])) @. mapPB[:,i] = mapMB[p,j] FToF[Bfaces[i]] = Bfaces[j] @@ -346,7 +345,7 @@ function build_periodic_boundary_maps!(xf, yf, zf, abs(zc[i] - zc[j]) < NODETOL * LZ && abs(abs(yc[i] - yc[j]) - LY) < NODETOL * LY - p = match_coordinate_vectors((xb[:,i], zb[:,i]), (xb[:,j], zb[:,j])) + match_coordinate_vectors!(p, (xb[:,i], zb[:,i]), (xb[:,j], zb[:,j])) @. mapPB[:,i] = mapMB[p,j] FToF[Bfaces[i]] = Bfaces[j] @@ -363,7 +362,7 @@ function build_periodic_boundary_maps!(xf, yf, zf, abs(yc[i] - yc[j]) < NODETOL * LY && abs(abs(zc[i] - zc[j]) - LZ) < NODETOL * LZ - p = match_coordinate_vectors((xb[:,i], yb[:,i]), (xb[:,j], yb[:,j])) + match_coordinate_vectors!(p, (xb[:,i], yb[:,i]), (xb[:,j], yb[:,j])) @. mapPB[:,i] = mapMB[p,j] FToF[Bfaces[i]] = Bfaces[j]