Problem Generators¶
A problem generator (pgen) sets up the initial conditions and any problem-specific runtime behavior for a simulation. AthenaK decides which problem generator to run either at build time (for custom problems) or at runtime through the input file (for the built-in test problems).
Selecting a problem generator¶
There are two ways to choose a problem generator.
Built-in problem generator, selected at runtime. When AthenaK is built without a custom problem, the
pgen_nameparameter in the<problem>block selects one of the problem generators that ship with the code:<problem> pgen_name = linear_wave
Custom problem generator, selected at build time. Compile a specific problem generator source file from
src/pgen/(or your own) with thePROBLEMoption:cmake -B build -D PROBLEM=my_problem_file cmake --build build -j
This compiles
src/pgen/my_problem_file.cppand wires it in through the user-problem hook. A build configured this way always runs that problem generator and ignorespgen_name.
If pgen_name is not recognized and no custom -D PROBLEM=... build was used,
AthenaK aborts with a fatal error.
Built-in pgen_name values¶
The problem generators dispatched in src/pgen/pgen.cpp are:
advectioncpawgr_bondicshockdiffusionlinear_waveimplodegr_monopolemri3dorszag_tangrad_linear_waverad_beamshock_tubeshwavez4c_boosted_puncturez4c_linear_wave
In addition, two pre-defined unit-test problem generators are built in by default:
eos_compose— exercises the tabulated (CompOSE) equation-of-state machinery.gauss_legendre— exercises the Gauss–Legendre quadrature used for spherical grids and surface integrals.
Where to find existing examples¶
Core pgen sources:
src/pgen/Test-oriented pgens:
src/pgen/tests/Ready-to-run input files:
inputs/andinputs/tests/
Common workflow¶
# Build (default built-in pgens)
cmake -B build
cmake --build build -j
# Parse-only check for the chosen pgen
./build/src/athena -i inputs/tests/linear_wave_hydro.athinput -n
# Run
./build/src/athena -i inputs/tests/linear_wave_hydro.athinput
Tips for custom pgens¶
Start from a nearby file in
src/pgen/orsrc/pgen/tests/.Keep all run-time knobs in the
<problem>block so users can override them easily.Validate with
-n(parse only) before launching long runs.