Skip to content

Commit

Permalink
Linear Solver: Fix semicoarsening issues with multiple AMR levels (AM…
Browse files Browse the repository at this point in the history
…ReX-Codes#3961)

The coarsening ratio vector in MLLinOp cannot be used on fine amr
levels. In a few places, we forgot about it. This bug only affected
multi amr level composite nodal solves with semicoarsening enabled.
  • Loading branch information
WeiqunZhang authored May 29, 2024
1 parent 28b0101 commit 14d56ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ MLNodeLaplacian::restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab&
int idir = 0;
#else
int idir = 2;
if (cmglev > 0) {
if (amrlev == 0) {
regular_coarsening = mg_coarsen_ratio_vec[cmglev-1] == mg_coarsen_ratio;
IntVect ratio = mg_coarsen_ratio_vec[cmglev-1];
if (ratio[1] == 1) {
Expand Down Expand Up @@ -603,7 +603,7 @@ MLNodeLaplacian::interpolation (int amrlev, int fmglev, MultiFab& fine, const Mu
int idir = 0;
#else
int idir = 2;
if (fmglev > 0) {
if (amrlev == 0) {
regular_coarsening = mg_coarsen_ratio_vec[fmglev] == mg_coarsen_ratio;
IntVect ratio = mg_coarsen_ratio_vec[fmglev];
if (ratio[1] == 1) {
Expand Down
16 changes: 9 additions & 7 deletions Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,19 @@ MLNodeLaplacian::averageDownCoeffsSameAmrLevel (int amrlev)

for (int mglev = 1; mglev < m_num_mg_levels[amrlev]; ++mglev)
{
IntVect ratio = mg_coarsen_ratio_vec[mglev-1];
IntVect ratio = (amrlev > 0) ? IntVect(2) : mg_coarsen_ratio_vec[mglev-1];
bool regular_coarsening = true;
#if (AMREX_SPACEDIM == 1)
int idir = 0;
bool regular_coarsening = true;
#else
int idir = 2;
bool regular_coarsening = mg_coarsen_ratio_vec[mglev-1] == mg_coarsen_ratio;
if (ratio[1] == 1) {
idir = 1;
} else if (ratio[0] == 1) {
idir = 0;
if (amrlev == 0) {
regular_coarsening = mg_coarsen_ratio_vec[mglev-1] == mg_coarsen_ratio;
if (ratio[1] == 1) {
idir = 1;
} else if (ratio[0] == 1) {
idir = 0;
}
}
#endif
for (int idim = 0; idim < nsigma; ++idim)
Expand Down
4 changes: 2 additions & 2 deletions Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ MLNodeTensorLaplacian::restriction (int amrlev, int cmglev, MultiFab& crse, Mult

applyBC(amrlev, cmglev-1, fine, BCMode::Homogeneous, StateMode::Solution);

IntVect const ratio = mg_coarsen_ratio_vec[cmglev-1];
IntVect const ratio = (amrlev > 0) ? IntVect(2) : mg_coarsen_ratio_vec[cmglev-1];
int semicoarsening_dir = info.semicoarsening_direction;

bool need_parallel_copy = !amrex::isMFIterSafe(crse, fine);
Expand Down Expand Up @@ -131,7 +131,7 @@ MLNodeTensorLaplacian::interpolation (int amrlev, int fmglev, MultiFab& fine,
{
BL_PROFILE("MLNodeTensorLaplacian::interpolation()");

IntVect const ratio = mg_coarsen_ratio_vec[fmglev];
IntVect const ratio = (amrlev > 0) ? IntVect(2) : mg_coarsen_ratio_vec[fmglev];
int semicoarsening_dir = info.semicoarsening_direction;

bool need_parallel_copy = !amrex::isMFIterSafe(crse, fine);
Expand Down

0 comments on commit 14d56ef

Please sign in to comment.