Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for small cell before checking for multi-cut #3088

Merged
merged 2 commits into from
Jan 5, 2023
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions Src/EB/AMReX_EB2_3D_C.cpp
Original file line number Diff line number Diff line change
@@ -44,23 +44,31 @@ void set_eb_data (const int i, const int j, const int k,
Real azm = apz(i,j,k);
Real azp = apz(i,j,k+1);

// Check for small cell first
if (((axm == 0.0_rt && axp == 0.0_rt) &&
(aym == 0.0_rt && ayp == 0.0_rt) &&
(azm == 0.0_rt || azp == 0.0_rt)) ||
((axm == 0.0_rt && axp == 0.0_rt) &&
(aym == 0.0_rt || ayp == 0.0_rt) &&
(azm == 0.0_rt && azp == 0.0_rt)) ||
((axm == 0.0_rt || axp == 0.0_rt) &&
(aym == 0.0_rt && ayp == 0.0_rt) &&
(azm == 0.0_rt && azp == 0.0_rt))) {
Comment on lines +48 to +56

Check notice

Code scanning / CodeQL

Complex condition

Complex condition: too many logical operations in this expression.
set_covered(i, j, k, cell, vfrac, vcent, barea, bcent, bnorm);
is_small_cell = true;
return;
}

// Check for multiple cuts
// We know there are no multiple cuts on faces by now.
// Firstly, we need to check the case that there are two cuts
// We need to check the case that there are two cuts
// at the opposite corners.
bool multi_cuts = (axm >= 0.5_rt && axm < 1.0_rt &&
axp >= 0.5_rt && axp < 1.0_rt &&
aym >= 0.5_rt && aym < 1.0_rt &&
ayp >= 0.5_rt && ayp < 1.0_rt &&
azm >= 0.5_rt && azm < 1.0_rt &&
azp >= 0.5_rt && azp < 1.0_rt);
// Secondly, we also need to check if area fractions became 0
// at any opposite face when building the faces
if ((axm == 0.0_rt && axp == 0.0_rt) ||
(aym == 0.0_rt && ayp == 0.0_rt) ||
(azm == 0.0_rt && azp == 0.0_rt)) {
multi_cuts = true;
}

if (multi_cuts) {
set_covered(i, j, k, cell, vfrac, vcent, barea, bcent, bnorm);
@@ -72,8 +80,18 @@ void set_eb_data (const int i, const int j, const int k,
Real dapy = aym - ayp;
Real dapz = azm - azp;
Real apnorm = std::sqrt(dapx*dapx+dapy*dapy+dapz*dapz);
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(apnorm != 0.0_rt,
"amrex::EB2:build_cells: apnorm==0");
if (apnorm == 0.0_rt) {
bool maybe_multi_cuts = (axm == 0.0_rt && axp == 0.0_rt) ||
(aym == 0.0_rt && ayp == 0.0_rt) ||
(azm == 0.0_rt && azp == 0.0_rt);
if (maybe_multi_cuts) {
set_covered(i, j, k, cell, vfrac, vcent, barea, bcent, bnorm);
is_multicut = true;
return;
} else {
amrex::Abort("amrex::EB2:build_cells: apnorm==0");
}
}
Real apnorminv = 1.0_rt/apnorm;
Real nx = dapx * apnorminv;
Real ny = dapy * apnorminv;