Skip to content

Conversation

ankithadas
Copy link
Contributor

Summary

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

Comment on lines +288 to +346
switch (bct) {
case AMREX_LO_NEUMANN:
{
if (mask(i,j,k) == 0 && mask(i+s,j,k) == 1) {
phi(i,j,k,icomp) = phi(i+s,j,k,icomp);
}
break;
}
case AMREX_LO_REFLECT_ODD:
{
if (mask(i,j,k) == 0 && mask(i+s,j,k) == 1) {
phi(i,j,k,icomp) = -phi(i+s,j,k,icomp);
}
break;
}
case AMREX_LO_DIRICHLET:
{
const int NX = amrex::min(blen+1, maxorder);
GpuArray<Real,4> x{-bcl * dxinv, Real(0.5), Real(1.5), Real(2.5)};
Array2D<Real, 0, 3, 0, 2> coef{};
for (int r = 0; r <= maxorder-2; ++r) {
poly_interp_coeff(-Real(0.5), x.data(), r+2, &(coef(0,r)));
}
if (mask(i,j,k) == 0 && mask(i+s,j,k) == 1) {
int order = 1;
bool has_cutfaces = false;
for (int r = 0; r <= NX-2; ++r) {
Real a = area(i+(1-side)+s*r,j,k);
if (a > Real(0.0)) {
++order;
if (a < Real(1.0)) {
has_cutfaces = true;
}
} else {
break;
}
}
if (has_cutfaces) { order = amrex::min(2,order); }
if (order == 1) {
if (inhomog) {
phi(i,j,k,icomp) = bcval(i,j,k,icomp);
} else {
phi(i,j,k,icomp) = Real(0.0);
}
} else {
Real tmp = Real(0.0);
for (int m = 1; m < order; ++m) {
tmp += phi(i+m*s,j,k,icomp) * coef(m,order-2);
}
phi(i,j,k,icomp) = tmp;
if (inhomog) {
phi(i,j,k,icomp) += bcval(i,j,k,icomp)*coef(0,order-2);
}
}
}
break;
}
default: {}
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
101 (41 lines)
.
Comment on lines +359 to +417
switch (bct) {
case AMREX_LO_NEUMANN:
{
if (mask(i,j,k) == 0 && mask(i,j+s,k) == 1) {
phi(i,j,k,icomp) = phi(i,j+s,k,icomp);
}
break;
}
case AMREX_LO_REFLECT_ODD:
{
if (mask(i,j,k) == 0 && mask(i,j+s,k) == 1) {
phi(i,j,k,icomp) = -phi(i,j+s,k,icomp);
}
break;
}
case AMREX_LO_DIRICHLET:
{
const int NX = amrex::min(blen+1, maxorder);
GpuArray<Real,4> x{-bcl * dyinv, Real(0.5), Real(1.5), Real(2.5)};
Array2D<Real, 0, 3, 0, 2> coef{};
for (int r = 0; r <= maxorder-2; ++r) {
poly_interp_coeff(-Real(0.5), x.data(), r+2, &(coef(0,r)));
}
if (mask(i,j,k) == 0 && mask(i,j+s,k) == 1) {
int order = 1;
bool has_cutfaces = false;
for (int r = 0; r <= NX-2; ++r) {
Real a = area(i,j+(1-side)+s*r,k);
if (a > Real(0.0)) {
++order;
if (a < Real(1.0)) {
has_cutfaces = true;
}
} else {
break;
}
}
if (has_cutfaces) { order = amrex::min(2,order); }
if (order == 1) {
if (inhomog) {
phi(i,j,k,icomp) = bcval(i,j,k,icomp);
} else {
phi(i,j,k,icomp) = Real(0.0);
}
} else {
Real tmp = Real(0.0);
for (int m = 1; m < order; ++m) {
tmp += phi(i,j+m*s,k,icomp) * coef(m,order-2);
}
phi(i,j,k,icomp) = tmp;
if (inhomog) {
phi(i,j,k,icomp) += bcval(i,j,k,icomp)*coef(0,order-2);
}
}
}
break;
}
default: {}
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
101 (41 lines)
.
Comment on lines +430 to +488
switch (bct) {
case AMREX_LO_NEUMANN:
{
if (mask(i,j,k) == 0 && mask(i,j,k+s) == 1) {
phi(i,j,k,icomp) = phi(i,j,k+s,icomp);
}
break;
}
case AMREX_LO_REFLECT_ODD:
{
if (mask(i,j,k) == 0 && mask(i,j,k+s) == 1) {
phi(i,j,k,icomp) = -phi(i,j,k+s,icomp);
}
break;
}
case AMREX_LO_DIRICHLET:
{
const int NX = amrex::min(blen+1, maxorder);
GpuArray<Real,4> x{-bcl * dzinv, Real(0.5), Real(1.5), Real(2.5)};
Array2D<Real, 0, 3, 0, 2> coef{};
for (int r = 0; r <= maxorder-2; ++r) {
poly_interp_coeff(-Real(0.5), x.data(), r+2, &(coef(0,r)));
}
if (mask(i,j,k) == 0 && mask(i,j,k+s) == 1) {
int order = 1;
bool has_cutfaces = false;
for (int r = 0; r <= NX-2; ++r) {
Real a = area(i,j,k+(1-side)+s*r);
if (a > Real(0.0)) {
++order;
if (a < Real(1.0)) {
has_cutfaces = true;
}
} else {
break;
}
}
if (has_cutfaces) { order = amrex::min(2,order); }
if (order == 1) {
if (inhomog) {
phi(i,j,k,icomp) = bcval(i,j,k,icomp);
} else {
phi(i,j,k,icomp) = Real(0.0);
}
} else {
Real tmp = Real(0.0);
for (int m = 1; m < order; ++m) {
tmp += phi(i,j,k+m*s,icomp) * coef(m,order-2);
}
phi(i,j,k,icomp) = tmp;
if (inhomog) {
phi(i,j,k,icomp) += bcval(i,j,k,icomp)*coef(0,order-2);
}
}
}
break;
}
default: {}
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
101 (41 lines)
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant