Skip to content

Commit d84fe3d

Browse files
authored
EB anisotropic meshes - changes for cut_face_2d routine (#4554)
This PR makes the necessary changes in the variables - `areafrac`, `nx`, `ny`, `centx`, `centy`, `Sx2`, `Sy2`, `Sxy`, in the `cut_face_2d` routine, for anisotropic meshes (ie. when mesh spacings are not equal). The derivation is in the attached pdf in the link below. The changes are in Eqns. 35-37, 43-44, 46-47, 49-50, 55-56. [EB_anisotropic.pdf](https://github.com/user-attachments/files/21201504/EB_anisotropic.pdf)
1 parent d969d6e commit d84fe3d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Src/EB/AMReX_EB2_3D_C.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
195195
void cut_face_2d (Real& areafrac, Real& centx, Real& centy,
196196
Real& Sx2, Real& Sy2, Real& Sxy,
197197
Real axm, Real axp, Real aym, Real ayp,
198-
Real bcx, Real bcy) noexcept
198+
Real bcx, Real bcy,
199+
Real dxval, Real dyval) noexcept
199200
{
200201
#ifdef AMREX_USE_FLOAT
201202
constexpr Real sml = 1.e-5_rt;
@@ -204,9 +205,9 @@ void cut_face_2d (Real& areafrac, Real& centx, Real& centy,
204205
constexpr Real sml = 1.e-14;
205206
constexpr Real tiny = 1.e-15;
206207
#endif
207-
Real apnorm = std::hypot(axm-axp,aym-ayp);
208-
Real nx = (axm-axp) * (1.0_rt/apnorm); // pointing to the wall
209-
Real ny = (aym-ayp) * (1.0_rt/apnorm);
208+
Real apnorm = std::hypot((axm-axp)*dyval,(aym-ayp)*dxval);
209+
Real nx = dyval * (axm-axp) * (1.0_rt/apnorm); // pointing to the wall
210+
Real ny = dxval * (aym-ayp) * (1.0_rt/apnorm);
210211

211212
Real nxabs = std::abs(nx);
212213
Real nyabs = std::abs(ny);
@@ -264,9 +265,9 @@ void cut_face_2d (Real& areafrac, Real& centx, Real& centy,
264265
Real dx2 = dx * (x_ym + x_yp);
265266
Real dx3 = dx * (x_ym*x_ym + x_ym*x_yp + x_yp*x_yp);
266267
Real dx4 = dx * (x_ym + x_yp) * (x_ym*x_ym + x_yp*x_yp);
267-
Real af1 = 0.5_rt*(axm+axp) + aa*0.5_rt*dx2;
268-
centx = 0.125_rt*(axp-axm) + aa*(1.0_rt/6._rt)*dx3;
269-
Sx2 = (1.0_rt/24._rt)*(axm+axp) + aa*(1.0_rt/12._rt)*dx4;
268+
Real af1 = 0.5_rt*(axm+axp) + aa*0.5_rt*dx2*dxval/dyval;
269+
centx = 0.125_rt*(axp-axm) + aa*(1.0_rt/6._rt)*dx3*dxval/dyval;
270+
Sx2 = (1.0_rt/24._rt)*(axm+axp) + aa*(1.0_rt/12._rt)*dx4*dxval/dyval;
270271

271272
Real signy = (ny > 0.0_rt) ? 1.0_rt : -1.0_rt;
272273
Real y_xm = (-0.5_rt + axm)*signy;
@@ -276,13 +277,13 @@ void cut_face_2d (Real& areafrac, Real& centx, Real& centy,
276277
Real dy2 = dy * (y_xm + y_xp);
277278
Real dy3 = dy * (y_xm*y_xm + y_xm*y_xp + y_xp*y_xp);
278279
Real dy4 = dy * (y_xm + y_xp) * (y_xm*y_xm + y_xp*y_xp);
279-
Real af2 = 0.5_rt*(aym+ayp) + aa*0.5_rt*dy2;
280-
centy = (1.0_rt/8._rt)*(ayp-aym) + aa*(1.0_rt/6._rt)*dy3;
281-
Sy2 = (1.0_rt/24._rt)*(aym+ayp) + aa*(1.0_rt/12._rt)*dy4;
280+
Real af2 = 0.5_rt*(aym+ayp) + aa*0.5_rt*dy2*dyval/dxval;
281+
centy = (1.0_rt/8._rt)*(ayp-aym) + aa*(1.0_rt/6._rt)*dy3*dyval/dxval;
282+
Sy2 = (1.0_rt/24._rt)*(aym+ayp) + aa*(1.0_rt/12._rt)*dy4*dyval/dxval;
282283

283284
Real S_b = (nxabs < nyabs)
284-
? (Sx2 - (1.0_rt/24._rt) - signx*(1.0_rt/6._rt)*(x_ym*x_ym*x_ym+x_yp*x_yp*x_yp)) / ny
285-
: (Sy2 - (1.0_rt/24._rt) - signy*(1.0_rt/6._rt)*(y_xm*y_xm*y_xm+y_xp*y_xp*y_xp)) / nx;
285+
? (Sx2 - (1.0_rt/24._rt) - signx*(1.0_rt/6._rt)*(x_ym*x_ym*x_ym+x_yp*x_yp*x_yp)) / ny * dxval/dyval
286+
: (Sy2 - (1.0_rt/24._rt) - signy*(1.0_rt/6._rt)*(y_xm*y_xm*y_xm+y_xp*y_xp*y_xp)) / nx * dyval/dxval;
286287
Sxy = (nxabs < nyabs)
287288
? -signy*(1.0_rt/16._rt)*dy2 + 0.5_rt*nx*S_b
288289
: -signx*(1.0_rt/16._rt)*dx2 + 0.5_rt*ny*S_b;
@@ -482,7 +483,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
482483
bcz = 0.5_rt*bcz - 0.5_rt;
483484
cut_face_2d(apx(i,j,k),fcx(i,j,k,0),fcx(i,j,k,1), // NOLINT(readability-suspicious-call-argument)
484485
m2x(i,j,k,0),m2x(i,j,k,1),m2x(i,j,k,2),
485-
lzm,lzp,lym,lyp,bcy,bcz);
486+
lzm,lzp,lym,lyp,bcy,bcz,dx[1],dx[2]);
486487
}
487488

488489
if (apx(i,j,k) == 0.0_rt) {
@@ -590,7 +591,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
590591
bcz = 0.5_rt*bcz - 0.5_rt;
591592
cut_face_2d(apy(i,j,k),fcy(i,j,k,0),fcy(i,j,k,1), // NOLINT(readability-suspicious-call-argument)
592593
m2y(i,j,k,0),m2y(i,j,k,1),m2y(i,j,k,2),
593-
lzm,lzp,lxm,lxp,bcx,bcz);
594+
lzm,lzp,lxm,lxp,bcx,bcz,dx[0],dx[2]);
594595
}
595596

596597
if (apy(i,j,k) == 0.0_rt) {
@@ -698,7 +699,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
698699
bcy = 0.5_rt*bcy - 0.5_rt;
699700
cut_face_2d(apz(i,j,k),fcz(i,j,k,0),fcz(i,j,k,1), // NOLINT(readability-suspicious-call-argument)
700701
m2z(i,j,k,0),m2z(i,j,k,1),m2z(i,j,k,2),
701-
lym,lyp,lxm,lxp,bcx,bcy);
702+
lym,lyp,lxm,lxp,bcx,bcy,dx[0],dx[1]);
702703
}
703704

704705
if (apz(i,j,k) == 0.0_rt) {

0 commit comments

Comments
 (0)