Skip to content

Fix constantface comm#542

Open
NickvonWit wants to merge 3 commits into
IPPL-framework:masterfrom
NickvonWit:fix-constantface-comm
Open

Fix constantface comm#542
NickvonWit wants to merge 3 commits into
IPPL-framework:masterfrom
NickvonWit:fix-constantface-comm

Conversation

@NickvonWit
Copy link
Copy Markdown

Fix face-specific boundary detection in ExtrapolateFace::apply()

This PR fixes #541. It also adds problem specific, Constant or Periodic Face, test files for the CG Solver.

The new test file for the constant face accounts for #535 by shifting the coordinates, to have the halo cells lie on the boundary instead of. The mechanism is explained in detail in my thesis.

File: src/Field/BcTypes.hpp (ExtrapolateFace<Field>::apply())

The old boundary check used an OR over both faces, so a rank touching the lower
global boundary would also apply the upper face BC (and vice versa). On multiple
ranks this overwrote internal halo cells that should come from neighbouring
ranks, breaking ConstantFace / ZeroFace problems.

The check is now face-specific: a face is only treated as a physical boundary if
this rank owns the matching global boundary side. Internal interfaces fall
through to halo exchange as intended.

Before:

bool isBoundary = (lDomains[myRank][d].max() == domain[d].max())
                  || (lDomains[myRank][d].min() == domain[d].min());

After:

const bool isLowerFace = !(face & 1);

const bool isBoundary =
    isLowerFace ? (lDomains[myRank][d].min() == domain[d].min())
                : (lDomains[myRank][d].max() == domain[d].max());

Running the same tests as in #541, again with 4 ranks/CPUs:

TestCGSolver_convergence_constant:

size,h,relError,trueResidual,solverResidual,itCount,solveTime
4,0.2,0.03993833615825652,5.192396279594881e-16,1.548388472317241e-14,4,0.0007419999999999927
8,0.1111111111111111,0.0118946827628043,2.280480765191515e-14,4.454411477477602e-12,18,0.0001960000000000017
16,0.05882352941176471,0.003297211400358864,7.361141393128399e-14,3.744523593663216e-11,30,0.001140999999999989
32,0.0303030303030303,0.00087231155428423,1.311740466831537e-13,1.40521600427478e-10,57,0.008532999999999999
64,0.01538461538461539,0.000224653947278718,4.601852170306531e-13,3.315314961627911e-10,113,0.041592
128,0.007751937984496124,5.702542539421606e-05,2.503480591224792e-12,1.025120149851657e-09,226,0.622335
cg_fix_const

TestCGSolver_convergence_periodic:

size,h,relError,trueResidual,solverResidual,itCount,solveTime
4,0.25,0.6377366121760882,1.596057071843241e-16,5.123796534383003e-14,1,0.0009799999999999948
8,0.125,0.06610999025353599,4.70268102220917e-16,5.55931194985223e-14,4,8.000000000001062e-05
16,0.0625,0.01511692691447543,5.860301855464142e-11,1.112753509887523e-07,12,0.0002899999999999986
32,0.03125,0.003724276265085818,5.170018915267303e-11,2.776629330922694e-07,21,0.001666000000000001
64,0.015625,0.0009277485090611948,9.456697119791474e-11,1.436507970115203e-06,41,0.01862800000000001
128,0.0078125,0.0002317313213305733,8.187506446496449e-11,3.51770745253475e-06,81,0.232264
cg_fix_per

Create a new test file for a Constant Face and Periodic Face
respectively. We remove the old file.
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.

Constant Face Boundary Conditions do not communicate properly

1 participant