Tutorials and use cases

Tutorials and use cases#

A 1-D mesh

Build a 1-D LSQMesh and inspect cells, faces and boundary ghost cells.

tutorials/mesh/mesh_1d.ipynb

A 2-D gmsh mesh

Generate a triangular gmsh mesh of a channel, load it as an LSQMesh and inspect the boundary tags.

tutorials/mesh/mesh_2d_gmsh.ipynb

AMReX: adaptive mesh refinement

A 1-D dam break on AMReX with one refinement level that follows the waves.

tutorials/amrex/amr.ipynb

AMReX: from symbolic model to generated C++

A 1-D dam break printed as C++ headers for AMReX, built, run and read back.

tutorials/amrex/minimal.ipynb

Bump sensitivities by finite differences

Steady 1-D flow over a Gaussian bump: d eta / d(position, width) by central finite differences, with a step-size check.

tutorials/ad/bump_finite_differences.ipynb

Bump sensitivities by forward-mode AD

Steady 1-D flow over a Gaussian bump: d eta / d(position, width) by jax.jvp, equal to central finite differences.

tutorials/ad/bump_forward_ad.ipynb

Bump sensitivities by reverse-mode AD

Steady 1-D flow over a Gaussian bump: dJ/d(position, width) and dJ/db of the whole bed by jax.grad on the checkpointed loop.

tutorials/ad/bump_reverse_ad.ipynb

Chorin projection: a VAM channel

A pressure-split model (VAM level 1) in a 2-D channel on the Chorin solver: predictor, pressure solve and correction on NumPy and JAX.

tutorials/vam/chorin_channel.ipynb

Code printer: AMReX

Print a NumericalSystemModel as an AMReX C++ header and read its flux function.

tutorials/components/printer_amrex.ipynb

Derivatives of function hooks

The derivative of a hook in a point-implicit friction: JAX AD by default, the user’s partials, or zero.

tutorials/hooks/hook_derivatives.ipynb

End to end: 1-D dam break

The whole pipeline once: model, SystemModel, NumericalSystemModel, NumPy solver and plot of a 1-D dam break.

tutorials/components/end_to_end.ipynb

Forward-mode AD through the JAX solver

dJ/dn of a 1-D shallow-water march with Manning friction by jax.jvp, checked against central finite differences.

tutorials/ad/forward_ad.ipynb

Function hooks

Manning friction of a 1-D shallow-water model supplied as a JAX function through the solver setting functions.

tutorials/hooks/function_hook.ipynb

Model and SystemModel

Derive the shallow water equations as a Model, freeze them into a SystemModel and read the wave speeds off its dispersion relation.

tutorials/components/model_system_model.ipynb

NumericalSystemModel

Attach the numerics to a SystemModel: the 1/h regularisation, the reconstruction and the Riemann solver.

tutorials/components/numerical_system_model.ipynb

OpenFOAM: the same model, printed as C++

A 1-D dam break on the OpenFOAM backend, built and run in the container and compared with the NumPy solver.

tutorials/foam/minimal.ipynb

ParaView output of the 2-D bump

Write the 2-D bump to HDF5, convert it to a .vtu series with a .pvd and open it in ParaView.

tutorials/swe/bump_2d_paraview.ipynb

Quick start: a 2-D bump on NumPy and JAX

One shallow-water case in 2-D, run on the NumPy and the JAX solver from the same NumericalSystemModel.

tutorials/swe/bump_2d.ipynb

Reverse-mode AD through the JAX solver

dJ/dn of a 1-D shallow-water march by AdMode.reverse and jax.grad, equal to forward mode for any ad_checkpoints.

tutorials/ad/reverse_ad.ipynb

Shallow moments in 2-D

Write a bed-drag closure, inject it into SME, run in 2-D and read the vertical velocity profile back.

tutorials/sme/moments_2d.ipynb

Shallow water in 1-D

The whole pipeline once: model, operators, scheme, solve and plot, in 1-D on the NumPy reference solver.

tutorials/swe/simple_numpy.ipynb

Zoomy in your browser

SME(2) dam break in Pyodide: Model, SystemModel, NSM, generated C++, a NumPy solve and the velocity profile.

tutorials/pyodide/pyodide.ipynb

type
dimension
physics
component
method
feature
backend