Repository navigation
Fix issues #222, #224, #226, #230; fix meanFlowDir = +/-3 in init_ConvectedVortex - #258
Conversation
…X-Fluids#230 AMReX-Fluids#222 main(): a run setting only stop_interval aborted before stop_time was derived from it. Count stop_interval as a valid stopping criterion in the guard, and name all three in the message. AMReX-Fluids#224 velocity_update()/scalar_update(): a NaN in the new state ended the run with exit(0), reporting success to batch scripts and CI. Use amrex::Abort so the run stops with a nonzero status, a backtrace and a proper Finalize. AMReX-Fluids#226 ComputeAofs(): the non-EB flux-register path ignored do_crse_add and do_fine_add, so the mac_sync added coarse fluxes that the EB twin skips. Honour both flags as the EB branch does; do_fine_add is now used in every build config, so drop its ignore_unused. AMReX-Fluids#230 Initialize_bcs(): an old-style ns.lo_bc/hi_bc entry silently overrode a conflicting xlo.type, defeating the "Multiple conflicting BCs" check. Let the integer table fill in only when no string type was given, so a mismatch reaches that check. Also read lo_bc and hi_bc as a pair -- ns.hi_bc alone was previously parsed into nothing and dropped. Verified: regtest.2d.poiseuille (amr.max_level=1, exercising the AMReX-Fluids#226 mac_sync path) is bit-identical to development; the 2D non-EB and EB regression decks run clean apart from eb_run2d shock_past_cylinder, which fails identically on development. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
case 3 added meanFlowMag to both the x and y velocity components and left z untouched; case -3 did the same with the opposite sign. Set the z component only, matching the single-component pattern of case +/-1 and +/-2. With the mean flow correctly on z, AMREX_D_TERM drops it entirely in 2D, so meanFlowDir = +/-3 would silently run as "no mean flow". Extend the validation guard above to abort in that case instead. Verified in 3D with prob.meanFlowMag = 50, reported as max|u| / max|v| / max|w|: dir= 0 -> 51.6 / 51.6 / 0 (vortex alone) dir= 1 -> 101.6 / 51.6 / 0 dir= 2 -> 51.6 / 101.6 / 0 dir= 3 -> 51.6 / 51.6 / 50 Before this change dir=3 gave 101.6 / 101.6 / 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| if ( IC.meanFlowDir == 3 || IC.meanFlowDir == -3 ) { | ||
| amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir = +/-3 requires 3D\n in the inputs file."); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
The intent of meanFlowDir = 3 was as originally written, that is to create a mean flow that is not axis aligned. This problem is inherently 2D but can be run as pseudo 3D. I can see that meanFlowDir = 3 is confusing and suggest we could use 4 instead of 3.
There was a problem hiding this comment.
Thanks — you are right, and I had this backwards. I read the old case 3 as a typo because it was the only branch that was not single-component, and I did not consider that non-axis-aligned was the point. Sorry for removing it.
Adopted your numbering in ff09d46: +/-4 is now the diagonal, restored as the pre-PR case +/-3 body verbatim, and +/-3 is the z-aligned flow.
One extension to your suggestion, which I am happy to drop if you disagree: I kept this 2D guard, but narrowed it to +/-3 only. Now that +/-3 means z, AMREX_D_TERM still drops it in 2D and the mean flow would vanish silently. The message now points at +/-4:
init_ConvectedVortex: prob.meanFlowDir = +/-3 puts the mean flow along z
and requires 3D. Use +/-4 for a diagonal mean flow in the x-y plane.
+/-4 itself works fine in 2D, so the pseudo-2D use you describe is unaffected.
| @@ -649,6 +649,11 @@ void NavierStokes::init_ConvectedVortex (Box const& vbx, | |||
| if ( IC.meanFlowDir < -3 || IC.meanFlowDir > 3 ) { | |||
There was a problem hiding this comment.
| if ( IC.meanFlowDir < -3 || IC.meanFlowDir > 3 ) { | |
| if ( IC.meanFlowDir < -4 || IC.meanFlowDir > 4 ) { |
| AMREX_D_TERM(vel(i,j,k,0) = u_vort;, | ||
| vel(i,j,k,1) = v_vort;, | ||
| vel(i,j,k,2) = -IC.meanFlowMag + w_vort); | ||
| break; |
There was a problem hiding this comment.
| break; | |
| break; | |
| case 4 : | |
| AMREX_D_TERM(vel(i,j,k,0) = IC.meanFlowMag + u_vort;, | |
| vel(i,j,k,1) = IC.meanFlowMag + v_vort;, | |
| vel(i,j,k,2) = w_vort); | |
| break; | |
| case -4 : | |
| AMREX_D_TERM(vel(i,j,k,0) = -IC.meanFlowMag + u_vort;, | |
| vel(i,j,k,1) = -IC.meanFlowMag + v_vort;, | |
| vel(i,j,k,2) = w_vort); | |
| break; |
There was a problem hiding this comment.
Applied in ff09d46, with case 4 / case -4 added after case -3 and before the case 0 / default fallthrough.
I applied it by hand rather than with the "commit suggestion" button: the suggested block has trailing whitespace after vel(i,j,k,2) = w_vort); on the case -4 line, and the repo's trailing_whitespaces style job would have failed on it.
Otherwise the body is your text unchanged, which also means it is character-identical to the pre-PR case +/-3.
| @@ -649,6 +649,11 @@ void NavierStokes::init_ConvectedVortex (Box const& vbx, | |||
| if ( IC.meanFlowDir < -3 || IC.meanFlowDir > 3 ) { | |||
| amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir must be 0 (no mean flow) or +/-1, +/-2, +/-3\n in the inputs file."); | |||
There was a problem hiding this comment.
| amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir must be 0 (no mean flow) or +/-1, +/-2, +/-3\n in the inputs file."); | |
| amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir must be 0 (no mean flow) or +/-1, +/-2, +/-3, +/-4\n in the inputs file."); |
There was a problem hiding this comment.
Applied in ff09d46, reworded slightly to say what each value does rather than just listing them:
init_ConvectedVortex: prob.meanFlowDir must be 0 (no mean flow),
+/-1, +/-2, +/-3 (mean flow along x, y, z) or +/-4 (diagonal in the x-y plane)
in the inputs file.
I also filled in Docs/sphinx_documentation/source/ProblemSetup.rst, which described meanFlowDir only as "Direction of the mean flow the vortex is convected by" and listed no valid values at all.
Per @cgilet's review of AMReX-Fluids#258: the original meanFlowDir = +/-3, which added meanFlowMag to both the x and y velocity components, was not a bug. It was a deliberate non-axis-aligned mean flow for a problem that is inherently 2D but may be run as pseudo-3D. The previous commit removed that capability. Restore it under a new number rather than dropping it: 0 no mean flow (the vortex alone) +/-1 mean flow along x +/-2 mean flow along y +/-3 mean flow along z (3D only) +/-4 diagonal mean flow in the x-y plane case +/-4 is the pre-PR case +/-3 body verbatim, so a deck that used 3 reproduces its old results exactly by switching to 4. Note the diagonal has |U| = meanFlowMag*sqrt(2), as it always did. The 2D guard is kept but now applies only to +/-3, where AMREX_D_TERM drops the z component and the mean flow would silently vanish; its message points at +/-4, which is what a 2D user wanting a diagonal flow needs. +/-4 itself works in 2D. Also document the encoding in ProblemSetup.rst, which previously listed no valid values for meanFlowDir at all. Verified in 3D with prob.meanFlowMag = 50, as max|u| / max|v| / max|w|: dir= 0 -> 51.6 / 51.6 / 0 dir= 1 -> 101.6 / 51.6 / 0 dir= 2 -> 51.6 / 101.6 / 0 dir= 3 -> 51.6 / 51.6 / 50 dir= 4 -> 101.6 / 101.6 / 0 (matches pre-PR dir=3) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@cgilet thanks for the review — pushed as ff09d46, replies on each thread. Summary: you were right that the original
Full 3D sweep at 2D: Two things I did not want to decide on my own:
Unrelated to your comments, for context on the rest of the PR: #229 is not included — |
Fixes #222,
fixes #224,
fixes #226,
fixes #230,
plus one bug found while reviewing already-merged code.
Issues addressed
#222 —
main(): a run that sets onlystop_intervalaborts beforestop_timeis derived from it. Countstop_intervalas a valid stopping criterion in the guard, and name all three in the message.#224 — a NaN in the new state ends the run with
exit(0), reporting success. Both sites (velocity_update,scalar_update) now useamrex::Abort, so the run stops with a nonzero status, a backtrace and a properFinalize. Noexit(0)/exit(1)remains anywhere inSource/.#226 —
ComputeAofs: the non-EB flux-register path ignoresdo_crse_add/do_fine_add. Honour both flags exactly as the EB branch does.do_fine_addis now used in every build config, so itsignore_unusedis dropped.#230 — an old-style
ns.lo_bc/hi_bcentry silently overrides a conflictingxlo.type. Let the integer table fill in only when no string type was supplied (bc_type == "null"), so a mismatch reaches the existing "Multiple conflicting BCs" check. Also closes the related gap noted in the issue:lo_bcandhi_bcare now read as a pair, where previouslyns.hi_bcon its own was parsed into nothing and silently dropped.Also included
init_ConvectedVortex:meanFlowDir = +/-3put the mean flow on x and y, not z (Source/prob/prob_init.cpp).case 3addedmeanFlowMagto both the x and y velocity components and left z untouched;case -3did the same with the opposite sign. Now sets the z component only, matching the single-component pattern ofcase +/-1and+/-2. SinceAMREX_D_TERMdrops the z term in 2D, the validation guard above is extended to abort on+/-3in 2D rather than silently running as "no mean flow".This one is in a separate commit (
3fd14d64) since it did not come from a filed issue -- happy to split it out if you would rather keep this PR strictly issue-scoped.Not included: #229
I implemented the suggested fix for #229 and it made things worse.
amrex::volumeWeightedSumis EB-aware -- it has weighted by the volume fraction since AMReX8b367b0071(2022-09-25) -- so the patch double-countsvfrac. Covered cells are already handled too, sincevfrac == 0exactly. Details and measurements in #229 (comment); I suggest closing #229 as invalid.Verification
Built
Exec/run2d,Exec/eb_run2d(MPI,USE_EB=TRUE) andExec/run3d(MPI) -- all clean.No answer change.
regtest.2d.poiseuille(amr.max_level=1, so it exercises theComputeAofs: non-EB flux-register path ignoresdo_crse_add/do_fine_add, so the mac_sync adds coarse fluxes the EB twin skips #226mac_syncpath) produces aplt00010that is bit-identical to a from-scratch build ofdevelopment. This confirms the issue's reasoning that the spuriousCrseAddwas discarded before it was refluxed.Regression decks. 4/4 in
Exec/run2dand 5/6 inExec/eb_run2drun clean.eb_run2d/regtest.2d.shock_past_cylinderaborts withMLMG failed, but that is pre-existing -- it fails identically on unmodifieddevelopment.main(): a run that sets onlystop_intervalaborts beforestop_timeis derived from it #222 --stop_interval = 0.002withmax_step = -1and nostop_timenow runs and stops exactly atTIME = 0.002.Initialize_bcs: an old-stylens.lo_bc/hi_bcentry silently overrides a conflictingxlo.type, defeating the "Multiple conflicting BCs" check #230 --ns.lo_bc = 5combined withxlo.type = mass_inflownow aborts withMultiple conflicting BCs specified for xlo: 1, 5. Integer-only decks are unaffected (shock_past_cylinderstill printsxlo set to mass inflow).ns.hi_bcwithoutns.lo_bcnow aborts.meanFlowDir-- 3D sweep withprob.meanFlowMag = 50, asmax|u| / max|v| / max|w|:meanFlowDirdir=0shows the vortex alone contributes 51.6 to both u and v, sodir=1/2add 50 to exactly one component anddir=3now does the same on w.#224 was not exercised at runtime -- I tried to induce a NaN with
ns.fixed_dt = 50, but the run dies in MLMG before reaching the velocity-update check. The change is a one-line substitution that compiles, andamrex::Abortreturning a nonzero status is demonstrated by the #230 tests above, but I did not prove that specific call site fires.🤖 Generated with Claude Code