Severity: medium · Category: correctness · Fix order: 18 of 29 — fix this 18th.
Filenames are numbered in reverse fix order: 001 = fix last, 029 = fix first. This file is 012.
Location: src/prob/prob_bc.cpp:27
Based on commit 7307d872 (line numbers refer to that tree).
The defect
What is wrong — prob_set_BC_MF uses 'ncomp = field=="velocity" ? AMREX_SPACEDIM : 1', so for field=="tracer" with m_ntrac>1 only component 0 of the mixed-BC iMultiFab is set; make_BC_MF allocated it with m_ntrac components initialized to 0 (BCType::int_dir).
Why it matters
EB Godunov run with probtype 1100/1101/1102, a 'mixed' boundary, incflo.ntrac=2, advect_tracer=1: on the mixed face, tracer components 1..ntrac-1 in tracBC_MF stay int_dir, so HydroUtils::ComputeFluxesOnBoxFromState applies no inflow/outflow BC to those tracers there -- their inflow values are silently ignored and the solution is wrong.
Suggested fix
In prob_set_BC_MF (src/prob/prob_bc.cpp:27), derive ncomp per field so "tracer" uses m_ntrac instead of falling into the 1-component default. This matches what the mask consumer requires: in AMReX-Hydro, HydroBC::getBC reads the per-cell type array at component n whenever the boundary iMultiFab is non-null and bypasses the BCRec fallback, so every component allocated by make_BC_MF (bcs.size() == m_ntrac for tracer) must be written. The non-mixed branch of make_BC_MF (src/boundary_conditions/incflo_set_bcs.cpp:96-101) already loops over all ncomp components — this makes the mixed branch consistent with it. The other field values ("projection", "density", "temperature") are genuinely 1-component today, so the ternary is sufficient. Maintainer judgement call: a more future-proof alternative is to pass ncomp explicitly from make_BC_MF (it already has bcs.size()), which would automatically cover a multi-component temperature or other new fields; the attached diff takes the minimal per-field-string route instead.
--- a/src/prob/prob_bc.cpp
+++ b/src/prob/prob_bc.cpp
@@ -24,7 +24,8 @@
int half_num_cells = domain.length(direction) / 2;
// for this problem, bcs are same for all fields, only ncomp varies
- int ncomp = field == "velocity" ? AMREX_SPACEDIM : 1;
+ int ncomp = field == "velocity" ? AMREX_SPACEDIM
+ : (field == "tracer" ? m_ntrac : 1);
Orientation::Side side = ori.faceDir();
if (side == Orientation::low) {
Sets ncomp to m_ntrac for field=="tracer" so all tracer components of the mixed-BC mask are filled, matching make_BC_MF's allocation (bcs.size()==m_ntrac). Other fields keep ncomp as before (velocity: AMREX_SPACEDIM; density/temperature/projection: 1), matching their allocations. Relies on AMReX-Hydro HydroBC::getBC reading the per-component BC array when non-null.
Diff(s) are against 7307d872, written from the current source and verified only with git apply --check — never compiled, never run, never applied to the tree. Treat them as precise intent, not tested patches.
Verification evidence
F049 — confirmed (one verifier lens)
Lens 1 (refutation attempt): prob_bc.cpp:27 'int ncomp = field == "velocity" ? AMREX_SPACEDIM : 1;' writes only comp 0 for tracer, while make_BC_MF allocates bcs.size()==m_ntrac comps initialized to 0 (int_dir). AMReX-Hydro HydroBC::getBC reads 'bca(index...,n)' and ignores the BCRec fallback when bca is non-null, so tracer comps 1..ntrac-1 see int_dir on the mixed face. Path reachable: mixed branch reads m_ntrac tracer BC values (boundary_conditions.cpp:230) and nothing restricts ntrac to 1; no fix in git history of prob_bc.cpp.
Based on commit 7307d872, which is also the tree the audit verified against. From an automated audit of src/. Audit finding id: F049. Reviewer unit(s): theme:ntrac-ncomp. Nothing here was compiled or run — the failure scenarios are code reasoning, so the reaching configuration above is the cheapest way to confirm or refute it.
Severity: medium · Category: correctness · Fix order: 18 of 29 — fix this 18th.
Filenames are numbered in reverse fix order:
001= fix last,029= fix first. This file is012.Location:
src/prob/prob_bc.cpp:27Based on commit
7307d872(line numbers refer to that tree).The defect
What is wrong — prob_set_BC_MF uses 'ncomp = field=="velocity" ? AMREX_SPACEDIM : 1', so for field=="tracer" with m_ntrac>1 only component 0 of the mixed-BC iMultiFab is set; make_BC_MF allocated it with m_ntrac components initialized to 0 (BCType::int_dir).
Why it matters
EB Godunov run with probtype 1100/1101/1102, a 'mixed' boundary, incflo.ntrac=2, advect_tracer=1: on the mixed face, tracer components 1..ntrac-1 in tracBC_MF stay int_dir, so HydroUtils::ComputeFluxesOnBoxFromState applies no inflow/outflow BC to those tracers there -- their inflow values are silently ignored and the solution is wrong.
Suggested fix
In
prob_set_BC_MF(src/prob/prob_bc.cpp:27), derivencompper field so"tracer"usesm_ntracinstead of falling into the 1-component default. This matches what the mask consumer requires: in AMReX-Hydro,HydroBC::getBCreads the per-cell type array at componentnwhenever the boundary iMultiFab is non-null and bypasses theBCRecfallback, so every component allocated bymake_BC_MF(bcs.size() == m_ntracfor tracer) must be written. The non-mixed branch ofmake_BC_MF(src/boundary_conditions/incflo_set_bcs.cpp:96-101) already loops over allncompcomponents — this makes the mixed branch consistent with it. The otherfieldvalues ("projection", "density", "temperature") are genuinely 1-component today, so the ternary is sufficient. Maintainer judgement call: a more future-proof alternative is to passncompexplicitly frommake_BC_MF(it already hasbcs.size()), which would automatically cover a multi-component temperature or other new fields; the attached diff takes the minimal per-field-string route instead.Sets ncomp to m_ntrac for field=="tracer" so all tracer components of the mixed-BC mask are filled, matching make_BC_MF's allocation (bcs.size()==m_ntrac). Other fields keep ncomp as before (velocity: AMREX_SPACEDIM; density/temperature/projection: 1), matching their allocations. Relies on AMReX-Hydro HydroBC::getBC reading the per-component BC array when non-null.
Diff(s) are against
7307d872, written from the current source and verified only withgit apply --check— never compiled, never run, never applied to the tree. Treat them as precise intent, not tested patches.Verification evidence
F049— confirmed (one verifier lens)Lens 1 (refutation attempt): prob_bc.cpp:27 'int ncomp = field == "velocity" ? AMREX_SPACEDIM : 1;' writes only comp 0 for tracer, while make_BC_MF allocates bcs.size()==m_ntrac comps initialized to 0 (int_dir). AMReX-Hydro HydroBC::getBC reads 'bca(index...,n)' and ignores the BCRec fallback when bca is non-null, so tracer comps 1..ntrac-1 see int_dir on the mixed face. Path reachable: mixed branch reads m_ntrac tracer BC values (boundary_conditions.cpp:230) and nothing restricts ntrac to 1; no fix in git history of prob_bc.cpp.
Based on commit
7307d872, which is also the tree the audit verified against. From an automated audit ofsrc/. Audit finding id: F049. Reviewer unit(s): theme:ntrac-ncomp. Nothing here was compiled or run — the failure scenarios are code reasoning, so the reaching configuration above is the cheapest way to confirm or refute it.