zoomy_amrex.symsolver

zoomy_amrex.symsolver#

Driver of the symbolic solvers on AMReX: prints the C++ solver, builds it in the AMReX apptainer, runs it on the mesh’s uniform Cartesian grid and reads the result back. Sits behind the C++ solver template (zoomy_core.symsolver.backend_cxx) and in front of Source/symsolver.

Inside the AMReX image (zoomy-server’s amrex backend) the driver builds and runs natively, see in_image. Binaries are cached in ZOOMY_AMREX_SYMCACHE, default <package>/../.symcache when writable, else ~/.cache/zoomy/amrex_symcache (else the temp directory).

Module Contents#

Classes#

AmrexDriver

Builds, launches and reads back the AMReX C++ solver of a backend_cxx template: build tree, Cartesian case with LSQ tables and inputs, optional AMR levels, mpirun.

SymbolicHyperbolicSolverAmrex

The explicit hyperbolic solver template on AMReX; its linear solves (Newton-Krylov of the implicit diffusion, finite-difference Jacobians) default to amrex::GMRES.

SymbolicChorinSolverAmrex

The Chorin projection solver template on AMReX; the model is the triple (pred, press, corr).

Functions#

in_image

True when this process already runs where AMReX builds: ZOOMY_AMREX_IN_IMAGE (1 / 0) when set, else AMReX sources at $AMREX_HOME and either an apptainer container around this process (APPTAINER_CONTAINER) or no apptainer to call. Then the build and the run are plain subprocesses; otherwise they go through apptainer exec of SIF.

cartesian

The mesh’s uniform Cartesian grid (1-3-D) as a dict: lo, hi, n, d, the grid order of the cells (x fastest) and each cell’s grid index. Anything but a full uniform grid raises NotImplementedError.

sides

BC branch of the x-lo, x-hi, y-lo, … sides (by outward normal; -1 on a periodic side) and the periodic flag per direction.

side_of

The side (2 * axis + upper) of the boundary faces tagged tag.

lsq_fit

LSQ topology and geometry (lsq_gradQ; for degree >= 2 also the boundary closure lsq_closure) of a proxy mesh with grid’s spacing, its sides carrying the case’s BC branches. Closure classes are renumbered by the kinds of the six sides, so a class has the same id on every proxy (grid size, AMR level) and in Kernels.H.

lsq_table

Text table of the LSQ stencils and weights per cell class (distance to each side, up to the stencil reach), read by zs::Mesh::load. Each class has the base list and one list per boundary-closure class; a periodic axis uses the interior class, its seam samples being halo cells.

restart_dir

The checkpoint directory chk<t> (of io.save_state) at path: itself or its latest.

hypre_prefix

The hypre install of the CPU or GPU build (~/.cache/zoomy/hypre-{cpu,cuda}-3.2.0), built first by containers/zoomy_amrex/build_hypre_cuda.sh when missing.

Data#

API#

zoomy_amrex.symsolver.ROOT#

None

zoomy_amrex.symsolver.SRC#

None

zoomy_amrex.symsolver.CACHE#

‘_cache(…)’

zoomy_amrex.symsolver.CONTAINERS#

‘Path(…)’

zoomy_amrex.symsolver.SIF#

None

zoomy_amrex.symsolver.HYPRE_VERSION#

‘3.2.0’

zoomy_amrex.symsolver.HYPRE_CACHE#

‘Path(…)’

zoomy_amrex.symsolver.HYPRE_SCRIPT#

None

zoomy_amrex.symsolver.BUILD_CPUS#

‘_cpus(…)’

zoomy_amrex.symsolver.RUN_CPUS#

‘_cpus(…)’

zoomy_amrex.symsolver.APP#

(‘symsolver/symAmrex.cpp’, ‘symsolver/rt_amrex.H’, ‘symsolver/amr_amrex.H’, ‘UserFunctions.H’, ‘Zoom…

zoomy_amrex.symsolver.in_image()#

True when this process already runs where AMReX builds: ZOOMY_AMREX_IN_IMAGE (1 / 0) when set, else AMReX sources at $AMREX_HOME and either an apptainer container around this process (APPTAINER_CONTAINER) or no apptainer to call. Then the build and the run are plain subprocesses; otherwise they go through apptainer exec of SIF.

class zoomy_amrex.symsolver.AmrexDriver(**params)#

Bases: param.Parameterized

Builds, launches and reads back the AMReX C++ solver of a backend_cxx template: build tree, Cartesian case with LSQ tables and inputs, optional AMR levels, mpirun.

References

  • Zhang et al. 2019, https://doi.org/10.21105/joss.01370

  • Berger, Oliger 1984, https://doi.org/10.1016/0021-9991(84)90073-1

  • Berger, Colella 1989, https://doi.org/10.1016/0021-9991(89)90035-1

Initialization

ranks#

‘Integer(…)’

gpu#

‘Boolean(…)’

max_grid_size#

‘Integer(…)’

tiny_profile#

‘Boolean(…)’

build_only#

‘Boolean(…)’

linear_solver#

‘OptionParam(…)’

amr#

‘Dict(…)’

build(nsm, dimension, classes=None)#

Print the solver, write the build tree and make it, cached by a hash of the sources. Called by run.

Args

  • classes: boundary-closure classes of the case (lsq_fit); without, no closure in the derivative aux.

Returns

Path of the binary.

run(mesh, model, Q0, workdir, Qaux0=None, fine=())#

March Q0 (mesh order) to time_end and return (time, Q); snapshots, wall time and (AMR) per-level states stay in self.snapshots, self.wall, self.initial and self.levels.

Args

  • fine: AMR only, [(mesh_l, Q0_l)] the initial state of level l on its refined domain (else interpolated).

Returns

(time, Q) with Q on level 0 (the composite averaged down); the binary if build_only.

class zoomy_amrex.symsolver.SymbolicHyperbolicSolverAmrex(**params)#

Bases: zoomy_amrex.symsolver.AmrexDriver, zoomy_core.symsolver.backend_cxx.CxxBackend

The explicit hyperbolic solver template on AMReX; its linear solves (Newton-Krylov of the implicit diffusion, finite-difference Jacobians) default to amrex::GMRES.

Initialization

linear_solver#

‘OptionParam(…)’

class zoomy_amrex.symsolver.SymbolicChorinSolverAmrex(**params)#

Bases: zoomy_amrex.symsolver.AmrexDriver, zoomy_core.symsolver.backend_cxx.CxxChorinBackend

The Chorin projection solver template on AMReX; the model is the triple (pred, press, corr).

References

  • Chorin 1968, https://doi.org/10.1090/S0025-5718-1968-0242392-2

Initialization

zoomy_amrex.symsolver.cartesian(mesh)#

The mesh’s uniform Cartesian grid (1-3-D) as a dict: lo, hi, n, d, the grid order of the cells (x fastest) and each cell’s grid index. Anything but a full uniform grid raises NotImplementedError.

zoomy_amrex.symsolver.sides(mesh, nsm, dim)#

BC branch of the x-lo, x-hi, y-lo, … sides (by outward normal; -1 on a periodic side) and the periodic flag per direction.

zoomy_amrex.symsolver.side_of(mesh, tag, dim)#

The side (2 * axis + upper) of the boundary faces tagged tag.

zoomy_amrex.symsolver.lsq_fit(nsm, systems, degree, grid, branch)#

LSQ topology and geometry (lsq_gradQ; for degree >= 2 also the boundary closure lsq_closure) of a proxy mesh with grid’s spacing, its sides carrying the case’s BC branches. Closure classes are renumbered by the kinds of the six sides, so a class has the same id on every proxy (grid size, AMR level) and in Kernels.H.

Args

  • systems: further systems the template differentiates besides nsm.

  • branch: BC branch per side (sides; -1: periodic, no closure).

Returns

dict proxy, np, topo, geom, order, classes; classes maps (owner, kind) (kind "state" or "reconstruction") to the class per row.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986

zoomy_amrex.symsolver.lsq_table(fit, grid, periodic, owner)#

Text table of the LSQ stencils and weights per cell class (distance to each side, up to the stencil reach), read by zs::Mesh::load. Each class has the base list and one list per boundary-closure class; a periodic axis uses the interior class, its seam samples being halo cells.

Args

  • fit: result of lsq_fit.

  • owner: system whose reconstruction classes (the O2 gradient) follow the monomials.

Returns

The table as text.

References

  • Mavriplis 2003, https://doi.org/10.2514/6.2003-3986

zoomy_amrex.symsolver.restart_dir(path)#

The checkpoint directory chk<t> (of io.save_state) at path: itself or its latest.

zoomy_amrex.symsolver.hypre_prefix(gpu)#

The hypre install of the CPU or GPU build (~/.cache/zoomy/hypre-{cpu,cuda}-3.2.0), built first by containers/zoomy_amrex/build_hypre_cuda.sh when missing.

References

  • Falgout, Yang 2002, https://doi.org/10.1007/3-540-47789-6_66