Skip to content

Commit

Permalink
Avoid divide-by-zero in 2D EB (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang authored Sep 2, 2020
1 parent 3d65510 commit 64e7727
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Src/EB/AMReX_EB2_2D_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ void set_eb_data (const int i, const int j,
bnorm(i,j,0,1) = signy;
vfrac(i,j,0) = 0.5*(axm+axp);
vcent(i,j,0,0) = 0.0;
vcent(i,j,0,1) = (0.125*(ayp-aym) + ny*0.5*bcent(i,j,0,1)*bcent(i,j,0,1)) / vfrac(i,j,0);
vcent(i,j,0,1) = (0.125*(ayp-aym) + ny*0.5*bcent(i,j,0,1)*bcent(i,j,0,1)) / (vfrac(i,j,0) + 1.e-30);
} else if (nyabs < tiny or nxabs > almostone) {
barea(i,j,0) = 1.0;
bcent(i,j,0,1) = 0.0;
bnorm(i,j,0,0) = signx;
bnorm(i,j,0,1) = 0.0;
vfrac(i,j,0) = 0.5*(aym+ayp);
vcent(i,j,0,0) = (0.125*(axp-axm) + nx*0.5*bcent(i,j,0,0)*bcent(i,j,0,0)) / vfrac(i,j,0);
vcent(i,j,0,0) = (0.125*(axp-axm) + nx*0.5*bcent(i,j,0,0)*bcent(i,j,0,0)) / (vfrac(i,j,0) + 1.e-30);
vcent(i,j,0,1) = 0.0;
} else {
Real aa = nxabs/ny;
Expand Down
2 changes: 1 addition & 1 deletion Src/EB/AMReX_EB2_3D_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void set_eb_data (const int i, const int j, const int k,

Real dapx = axm - axp;
Real dapy = aym - ayp;
Real dapz = azm - azp;
Real dapz = azm - azp;
Real apnorm = std::sqrt(dapx*dapx+dapy*dapy+dapz*dapz);
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(apnorm != 0.0,
"amrex::EB2:build_cells: apnorm==0");
Expand Down

0 comments on commit 64e7727

Please sign in to comment.