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

Cover multiple cuts #1810

Merged
merged 17 commits into from
Feb 26, 2021
Prev Previous commit
Next Next commit
switch to using s values instead of edge types
  • Loading branch information
drangara committed Feb 16, 2021
commit 43b1eeade31cd9e7c2ac3599812d28e0e69426cf
142 changes: 66 additions & 76 deletions Src/EB/AMReX_EB2_3D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,12 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,
amrex::Loop(lo, hi,
[=] (int i, int j, int k) noexcept
{
int ncuts = 0;
if (fx(i,j,k) == Type::irregular) {
if (ey(i,j,k) == Type::irregular) ++ncuts;
if (ey(i,j,k+1) == Type::irregular) ++ncuts;
if (ez(i,j,k) == Type::irregular) ++ncuts;
if (ez(i,j+1,k) == Type::irregular) ++ncuts;
}

if (ncuts > 2) {
// If only opposite corners of face are inside fluid, it
// will result in mutilple cut edges, so cover them
if ( ( s(i,j,k ) < 0.0 && s(i,j+1,k ) >= 0.0
&& s(i,j,k+1) >= 0.0 && s(i,j+1,k+1) < 0.0 )
|| ( s(i,j,k ) >= 0.0 && s(i,j+1,k ) < 0.0
&& s(i,j,k+1) < 0.0 && s(i,j+1,k+1) >= 0.0 )) {
amrex::Print() << "AMReX WARNING: covering multiple cuts\n";

// Cover the face
Expand All @@ -194,51 +191,51 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,

// Cover the other ey that touch the corners if necessary
if (j > ey.begin.y) {
if (ey(i,j-1,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i,j-1,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ey(i,j-1,k) = Type::covered;
if (ey(i,j-1,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i,j-1,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ey(i,j-1,k+1) = Type::covered;
}
if (j < ey.end.y-1) {
if (ey(i,j+1,k ) == Type::irregular && s(i,j+1,k ) < 0.0)
if (s(i,j+1,k ) == Type::irregular && s(i,j+1,k ) < 0.0)
ey(i,j+1,k) = Type::covered;
if (ey(i,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
if (s(i,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
ey(i,j+1,k+1) = Type::covered;
}

// Cover the other ez that touch the corners if necessary
if (k > ez.begin.z) {
if (ez(i ,j,k-1) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j,k-1) == Type::irregular && s(i ,j,k ) < 0.0)
ez(i,j,k-1) = Type::covered;
if (ez(i,j+1,k-1) == Type::irregular && s(i,j+1,k ) < 0.0)
if (s(i,j+1,k-1) == Type::irregular && s(i,j+1,k ) < 0.0)
ez(i,j+1,k-1) = Type::covered;
}
if (k < ez.end.z-1) {
if (ez(i ,j,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i ,j,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ez(i,j,k+1) = Type::covered;
if (ez(i,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
if (s(i,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
ez(i,j+1,k+1) = Type::covered;
}

// Cover the ex that touch the corners if necessary
if (i > ex.begin.x) {
if (ex(i-1,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i-1,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ex(i-1,j,k) = Type::covered;
if (ex(i-1,j+1,k ) == Type::irregular && s(i,j+1,k ) < 0.0)
if (s(i-1,j+1,k ) == Type::irregular && s(i,j+1,k ) < 0.0)
ex(i-1,j+1,k) = Type::covered;
if (ex(i-1,j ,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i-1,j ,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ex(i-1,j,k+1) = Type::covered;
if (ex(i-1,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
if (s(i-1,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
ex(i-1,j+1,k+1) = Type::covered;
}
if (i <= ex.end.x-1) {
if (ex(i ,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ex(i,j,k) = Type::covered;
if (ex(i ,j ,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i ,j ,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ex(i,j,k+1) = Type::covered;
if (ex(i ,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
if (s(i ,j+1,k+1) == Type::irregular && s(i,j+1,k+1) < 0.0)
ex(i,j+1,k+1) = Type::covered;
if (ex(i ,j+1,k ) == Type::irregular && s(i,j+1,k ) < 0.0)
if (s(i ,j+1,k ) == Type::irregular && s(i,j+1,k ) < 0.0)
ex(i,j+1,k) = Type::covered;
}

Expand All @@ -251,15 +248,12 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,
amrex::Loop(lo, hi,
[=] (int i, int j, int k) noexcept
{
int ncuts = 0;
if (fy(i,j,k) == Type::irregular) {
if (ex(i,j,k) == Type::irregular) ++ncuts;
if (ex(i,j,k+1) == Type::irregular) ++ncuts;
if (ez(i,j,k) == Type::irregular) ++ncuts;
if (ez(i+1,j,k) == Type::irregular) ++ncuts;
}

if (ncuts > 2) {
// If only opposite corners of face are inside fluid, it
// will result in mutilple cut edges, so cover them
if ( ( s(i,j,k ) < 0.0 && s(i+1,j,k ) >= 0.0
&& s(i,j,k+1) >= 0.0 && s(i+1,j,k+1) < 0.0 )
|| ( s(i,j,k ) >= 0.0 && s(i+1,j,k ) < 0.0
&& s(i,j,k+1) < 0.0 && s(i+1,j,k+1) >= 0.0 )) {
amrex::Print() << "AMReX WARNING: covering multiple cuts\n";

// Cover the face
Expand All @@ -273,51 +267,51 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,

//Cover the other ex that touch the corners if necessary
if (i > ex.begin.x) {
if (ex(i-1,j,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i-1,j,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ex(i-1,j,k) = Type::covered;
if (ex(i-1,j,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i-1,j,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ex(i-1,j,k+1) = Type::covered;
}
if (i < ex.end.x-1) {
if (ex(i+1,j,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
ex(i+1,j,k) = Type::covered;
if (ex(i+1,j,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
if (s(i+1,j,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
ex(i+1,j,k+1) = Type::covered;
}

// Cover the other ez that touch the corners if necessary
if (k > ez.begin.z) {
if (ez(i ,j,k-1) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j,k-1) == Type::irregular && s(i ,j,k ) < 0.0)
ez(i,j,k-1) = Type::covered;
if (ez(i+1,j,k-1) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j,k-1) == Type::irregular && s(i+1,j,k ) < 0.0)
ez(i+1,j,k-1) = Type::covered;
}
if (k < ez.end.z-1) {
if (ez(i ,j,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i ,j,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ez(i,j,k+1) = Type::covered;
if (ez(i+1,j,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
if (s(i+1,j,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
ez(i+1,j,k+1) = Type::covered;
}

// Cover the ey that touch the corners if necessary
if (j > ey.begin.y) {
if (ey(i ,j-1,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j-1,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ey(i,j-1,k) = Type::covered;
if (ey(i+1,j-1,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j-1,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
ey(i+1,j-1,k) = Type::covered;
if (ey(i+1,j-1,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
if (s(i+1,j-1,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
ey(i+1,j-1,k+1) = Type::covered;
if (ey(i ,j-1,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i ,j-1,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ey(i,j-1,k+1) = Type::covered;
}
if (j <= ey.end.y-1) {
if (ey(i ,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ey(i,j,k) = Type::covered;
if (ey(i ,j ,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
if (s(i ,j ,k+1) == Type::irregular && s(i ,j,k+1) < 0.0)
ey(i,j,k+1) = Type::covered;
if (ey(i+1,j ,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
if (s(i+1,j ,k+1) == Type::irregular && s(i+1,j,k+1) < 0.0)
ey(i+1,j,k+1) = Type::covered;
if (ey(i+1,j ,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j ,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
ey(i+1,j,k) = Type::covered;
}

Expand All @@ -330,16 +324,12 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,
amrex::Loop(lo, hi,
[=] (int i, int j, int k) noexcept
{
int ncuts = 0;
if (fz(i,j,k) == Type::irregular) {
if (ex(i,j,k) == Type::irregular) ++ncuts;
if (ex(i,j+1,k) == Type::irregular) ++ncuts;
if (ey(i,j,k) == Type::irregular) ++ncuts;
if (ey(i+1,j,k) == Type::irregular) ++ncuts;
}

if (ncuts > 2)
{
// If only opposite corners of face are inside fluid, it
// will result in mutilple cut edges, so cover them
if ( ( s(i,j,k ) < 0.0 && s(i+1,j,k ) >= 0.0
&& s(i,j+1,k) >= 0.0 && s(i+1,j+1,k) < 0.0 )
|| ( s(i,j,k ) >= 0.0 && s(i+1,j,k ) < 0.0
&& s(i,j+1,k) < 0.0 && s(i+1,j+1,k) >= 0.0 )) {
amrex::Print() << "AMReX WARNING: covering multiple cuts\n";
// Cover the face
fz(i,j,k) = Type::covered;
Expand All @@ -352,51 +342,51 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,

//Cover the other ex that touch the corners if necessary
if (i > ex.begin.x) {
if (ex(i-1,j,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i-1,j,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ex(i-1,j,k) = Type::covered;
if (ex(i-1,j+1,k) == Type::irregular && s(i ,j+1,k) < 0.0)
if (s(i-1,j+1,k) == Type::irregular && s(i ,j+1,k) < 0.0)
ex(i-1,j+1,k) = Type::covered;
}
if (i < ex.end.x-1) {
if (ex(i+1,j,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
ex(i+1,j,k) = Type::covered;
if (ex(i+1,j+1,k) == Type::irregular && s(i+1,j+1,k) < 0.0)
if (s(i+1,j+1,k) == Type::irregular && s(i+1,j+1,k) < 0.0)
ex(i+1,j+1,k) = Type::covered;
}

// Cover the other ey that touch the corners if necessary
if (j > ey.begin.y) {
if (ey(i ,j-1,k) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j-1,k) == Type::irregular && s(i ,j,k ) < 0.0)
ey(i,j-1,k) = Type::covered;
if (ey(i+1,j-1,k) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j-1,k) == Type::irregular && s(i+1,j,k ) < 0.0)
ey(i+1,j-1,k) = Type::covered;
}
if (j < ey.end.y-1) {
if (ey(i ,j+1,k) == Type::irregular && s(i ,j+1,k) < 0.0)
if (s(i ,j+1,k) == Type::irregular && s(i ,j+1,k) < 0.0)
ey(i,j+1,k) = Type::covered;
if (ey(i+1,j+1,k) == Type::irregular && s(i+1,j+1,k) < 0.0)
if (s(i+1,j+1,k) == Type::irregular && s(i+1,j+1,k) < 0.0)
ey(i+1,j+1,k) = Type::covered;
}

// Cover the ez that touch the corners if necessary
if (k > ez.begin.z) {
if (ez(i ,j ,k-1) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j ,k-1) == Type::irregular && s(i ,j,k ) < 0.0)
ez(i,j,k-1) = Type::covered;
if (ez(i ,j+1,k-1) == Type::irregular && s(i ,j+1,k) < 0.0)
if (s(i ,j+1,k-1) == Type::irregular && s(i ,j+1,k) < 0.0)
ez(i,j+1,k-1) = Type::covered;
if (ez(i+1,j+1,k-1) == Type::irregular && s(i+1,j+1,k) < 0.0)
if (s(i+1,j+1,k-1) == Type::irregular && s(i+1,j+1,k) < 0.0)
ez(i+1,j+1,k-1) = Type::covered;
if (ez(i+1,j ,k-1) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j ,k-1) == Type::irregular && s(i+1,j,k ) < 0.0)
ez(i+1,j,k-1) = Type::covered;
}
if (k <= ez.end.z-1) {
if (ez(i ,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
if (s(i ,j ,k ) == Type::irregular && s(i ,j,k ) < 0.0)
ez(i,j,k) = Type::covered;
if (ez(i ,j+1,k ) == Type::irregular && s(i ,j+1,k) < 0.0)
if (s(i ,j+1,k ) == Type::irregular && s(i ,j+1,k) < 0.0)
ez(i,j+1,k) = Type::covered;
if (ez(i+1,j+1,k ) == Type::irregular && s(i+1,j+1,k) < 0.0)
if (s(i+1,j+1,k ) == Type::irregular && s(i+1,j+1,k) < 0.0)
ez(i+1,j+1,k) = Type::covered;
if (ez(i+1,j ,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
if (s(i+1,j ,k ) == Type::irregular && s(i+1,j,k ) < 0.0)
ez(i+1,j,k) = Type::covered;
}

Expand Down