Skip to content

ERFFillPatcher::BuildMask misses periodic corner images when constructing the coarse/fine mask #3091

@asalmgren

Description

@asalmgren

Location

  • Source/BoundaryConditions/ERF_FillPatcher.cpp:126-156
  • Source/BoundaryConditions/ERF_FillPatcher.cpp:165-196

Problem

BuildMask augments the fine-grid box list with periodic images by shifting each box along one periodic dimension at a time:

if (m_fgeom.isPeriodic(dim)) {
    ...
    bb_lo.shift(dim,n);
    ...
    bb_hi.shift(dim,-n);
}

It never generates combined shifts such as (+Lx,+Ly) or (-Lx,+Ly).

Why this is a bug

In doubly or triply periodic cases, a fine patch touching a periodic corner should also mask out its diagonal periodic image. Without those combined corner
images, complementIn can classify periodic-corner cells as uncovered coarse/fine-boundary cells, and the patcher can incorrectly interpolate over data t
hat should be treated as fine-covered.

That is most likely to show up near periodic corners in relaxation/set regions.

Suggested patch

Generate periodic image boxes for all combinations of periodic shifts, not only single-axis shifts. One simple approach is to iterate over the 3^N shift
combinations (-1, 0, +1 in each periodic dimension), skip the all-zero shift, and add each shifted image that intersects the bounding box.

--- a/Source/BoundaryConditions/ERF_FillPatcher.cpp
+++ b/Source/BoundaryConditions/ERF_FillPatcher.cpp
@@
-        for (auto& b : bl_mf) {
-            for (int dim = 0; dim < AMREX_SPACEDIM; dim++) {
-                if (m_fgeom.isPeriodic(dim)) {
-                    ...
-                }
-            }
-        }
+        for (auto& b : bl_mf) {
+            for (all periodic shift combinations in {-1,0,+1}^N, excluding the zero shift) {
+                Box bb = b;
+                shift bb by +/- domain length in every selected periodic dimension;
+                bb.enclosedCells();
+                bb.setType(b.ixType());
+                bb &= fba_bnd;
+                if (bb.ok()) { bl_mf_new.push_back(bb); }
+            }
+        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions