Skip to content

Commit 3f07d66

Browse files
authored
fix box logic when boxes touch periodic boundary (erf-model#2701)
1 parent 96dbf58 commit 3f07d66

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Source/BoundaryConditions/ERF_FillPatcher.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,47 @@ void ERFFillPatcher::BuildMask (BoxArray const& fba,
123123
// Minimal bounding box of fine BA plus a halo cell
124124
Box fba_bnd = grow(fba.minimalBox(), IntVect(1,1,1));
125125

126+
BoxArray fba_per;
127+
Box fdomain = m_fgeom.Domain();
128+
// Here we add additional boxes that are periodic wraparounds of existing boxes
129+
if (m_fgeom.isAnyPeriodic())
130+
{
131+
Box domain_cc(fdomain); domain_cc.enclosedCells();
132+
BoxList bl_mf = fba.boxList();
133+
BoxList bl_mf_new;
134+
for (auto& b : bl_mf) {
135+
for (int dim = 0; dim < AMREX_SPACEDIM; dim++) {
136+
if (m_fgeom.isPeriodic(dim)) {
137+
int n = domain_cc.length(dim);
138+
if (b.smallEnd(dim) == fdomain.smallEnd(dim)) {
139+
Box bb_lo(b); bb_lo.enclosedCells(); bb_lo.shift(dim,n); bb_lo.setType(b.ixType());
140+
bb_lo &= fba_bnd;
141+
bl_mf_new.push_back(bb_lo);
142+
}
143+
Box bb_hi(b); bb_hi.enclosedCells();
144+
if (bb_hi.bigEnd(dim) == fdomain.bigEnd(dim)) {
145+
bb_hi.shift(dim,-n); bb_hi.setType(b.ixType());
146+
bb_hi &= fba_bnd;
147+
bl_mf_new.push_back(bb_hi);
148+
}
149+
} // periodic
150+
} // dim
151+
} // bl_mf
152+
153+
for (auto& b : bl_mf_new) {
154+
bl_mf.push_back(b);
155+
} // bl_mf
156+
fba_per.define(std::move(bl_mf));
157+
158+
} else {
159+
fba_per = fba;
160+
}
161+
126162
// BoxList and BoxArray to store complement
127163
BoxList com_bl; BoxArray com_ba;
128164

129165
// Compute the complement
130-
fba.complementIn(com_bl,fba_bnd);
166+
fba_per.complementIn(com_bl,fba_bnd);
131167

132168
// com_bl cannot be null since we grew with halo cells
133169
AMREX_ALWAYS_ASSERT(com_bl.size() > 0);

0 commit comments

Comments
 (0)