|
1 | 1 | # Common Pitfalls |
2 | 2 |
|
3 | | -## Array Bounds |
4 | | -- Arrays use non-unity lower bounds with ghost cells |
| 3 | +## Array Bounds & Ghost Cells |
| 4 | +- Grid dimensions: `m`, `n`, `p` (cells in x, y, z). 1D: n=p=0. 2D: p=0. |
| 5 | +- Interior domain: `0:m`, `0:n`, `0:p` |
| 6 | +- Buffer/ghost region: `-buff_size:m+buff_size` (similar for n, p in multi-D) |
| 7 | +- `buff_size` depends on WENO order and features (typically `2*weno_polyn + 2`) |
| 8 | +- Domain bounds: `idwint(1:3)` (interior `0:m`), `idwbuff(1:3)` (with ghost cells) |
| 9 | +- Cell-center coords: `x_cc(-buff_size:m+buff_size)`, `y_cc(...)`, `z_cc(...)` |
| 10 | +- Cell-boundary coords: `x_cb(-1-buff_size:m+buff_size)` |
5 | 11 | - Riemann solver indexing: left state at `j`, right state at `j+1` |
6 | 12 | - Off-by-one errors in ghost cell regions are a common source of bugs |
7 | 13 |
|
| 14 | +## Field Variable Indexing |
| 15 | +- Conserved variables: `q_cons_vf(1:sys_size)`. Primitive: `q_prim_vf(1:sys_size)`. |
| 16 | +- Index ranges depend on `model_eqns` and enabled features (set in `m_global_parameters.fpp`): |
| 17 | + - `cont_idx` — continuity (partial densities, one per fluid) |
| 18 | + - `mom_idx` — momentum components |
| 19 | + - `E_idx` — total energy (scalar) |
| 20 | + - `adv_idx` — volume fractions (advection equations) |
| 21 | + - `bub_idx`, `stress_idx`, `xi_idx`, `species_idx`, `B_idx`, `c_idx` — optional |
| 22 | +- Shorthand scalars: `momxb`/`momxe`, `contxb`/`contxe`, `advxb`/`advxe`, etc. |
| 23 | +- `sys_size` = total number of conserved variables (computed at startup) |
| 24 | +- Changing `model_eqns` or enabling features changes ALL index positions |
| 25 | + |
8 | 26 | ## Blast Radius |
9 | 27 | - `src/common/` is shared by ALL three executables (pre_process, simulation, post_process) |
10 | 28 | - Any change to common/ requires testing all three targets |
|
23 | 41 | - Fypp macros must expand correctly for both GPU and CPU builds |
24 | 42 | - GPU builds only work with nvfortran, Cray ftn, and AMD flang |
25 | 43 |
|
26 | | -## Test Golden Files |
27 | | -- Tests compare output against golden files in `tests/<hash>/golden.txt` |
| 44 | +## Test System |
| 45 | +- Tests are generated **programmatically** in `toolchain/mfc/test/cases.py`, not standalone files |
| 46 | +- Each test is a parameter modification on top of `BASE_CFG` defaults |
| 47 | +- Test UUID = CRC32 hash of the test's trace string; `./mfc.sh test -l` lists all |
| 48 | +- To add a test: modify `cases.py` using `CaseGeneratorStack` push/pop pattern |
| 49 | +- Golden files: `tests/<UUID>/golden.txt` — tolerance-based comparison, not exact match |
28 | 50 | - If your change intentionally modifies output, regenerate golden files: |
29 | 51 | `./mfc.sh test --generate --only <affected_tests> -j 8` |
30 | 52 | - Do not regenerate ALL golden files unless you understand every output change |
31 | | -- Golden file diffs are compared with tolerance, not exact match |
32 | 53 |
|
33 | 54 | ## PR Checklist |
34 | 55 | Before submitting a PR: |
|
0 commit comments