Skip to content

Developer Guide

hippoLBM is an application of the onika runtime: plugins of small operators, composed in YAML.

hippoLBM/
├── CMakeLists.txt          # find_package(onika), plugins, executable wrapper, tests
├── include/hippoLBM/       # shared headers
│   ├── compute/            #   parallel_for helpers, reductions
│   └── core/               #   Point3D, Box3D, enums (FLUID_CELL, WALL_CELL, ...)
├── src/                    # one plugin per directory, one operator per file
│   ├── grid/               #   hippo_grid: domain, LBM parameters, fields, traversals, ghosts, initial conditions
│   ├── collision/          #   hippo_collision: macro_variables, bgk, mrt, streaming
│   ├── bcs/                #   hippo_bcs: bounce-back, neumann, rho, lid_driven_cavity, cavity_z_*
│   ├── obstacle/           #   hippo_object: obstacle registration, update, bounce-back
│   ├── prepro/             #   hippo_prepro: init_couette, init_double_couette
│   ├── couette/            #   hippo_couette (optional): bgk_couette_relax, macro_variables_couette_relax
│   ├── io/                 #   hippo_io: ParaView, log, checkpoint / restart
│   └── check/              #   hippo_check: profiles, check_macro_quantities
├── data/config/            # default configuration (main-config.msp, config_*.msp)
├── example/                # example decks (tutorials) and STL files
├── regression-test/        # ctest decks and data
├── perf/                   # benchmark decks
└── script/                 # post-processing scripts (profiles, vorticity)

Writing an operator

An operator is a class deriving from onika::scg::OperatorNode, with typed slots declared by ADD_SLOT, a documentation() string and an execute() method; it is registered in a plugin with OperatorNodeFactory::instance()->register_factory. Most hippoLBM operators are templated on the lattice size Q and registered with make_variant_operator:

template <int Q>
class SetDPPressureGradientLBM : public OperatorNode {
 public:
  ADD_SLOT(LBMDomain<Q>, domain, INPUT, REQUIRED, DocString("The domain containing the grid."));
  ADD_SLOT(LBMFields<Q>, fields, INPUT_OUTPUT, REQUIRED, DocString("The fields to be initialized."));
  ADD_SLOT(LBMParameters, Params, INPUT, DocString{"The computed LBM parameters."});
  ADD_SLOT(std::vector<double>, delta_p, INPUT, REQUIRED, DocString{"..."});
  ...
  inline std::string documentation() const final { return R"EOF( ... YAML example ... )EOF"; }
  inline void execute() final {
    ...
    parallel_for(box, func, parallel_execution_context("set_dp_pressure_gradient_x"), pf, Grid, ...);
  }
};

ONIKA_AUTORUN_INIT(set_dp_pressure_gradient) {
  OperatorNodeFactory::instance()->register_factory("set_dp_pressure_gradient",
                                                    make_variant_operator<SetDPPressureGradientLBM>);
}

Kernels are functors with ONIKA_HOST_DEVICE_FUNC operators, launched with parallel_for on a Box3D or on a list of indices (traversals); a ParallelForFunctorTraits specialization with CudaCompatible = true makes them run on the GPU. Fatal errors must call MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE), not std::exit, so that no MPI rank is left hanging.

Regenerating the operator list

The Exhaustive Operator List is generated from the ADD_SLOT declarations of the sources and the --help output of each operator, with the script scripts/gen_operators.py of this documentation repository:

1
2
3
4
mkdir -p help && for op in $(grep -rhoE 'register_factory\(\s*"[a-z0-9_]+"' /path/to/hippoLBM/src | sed -E 's/.*"(.*)"/\1/' | sort -u); do
  build-hippoLBM/hippoLBM --help $op 2>&1 | sed -n '/^Operator/,$p' > help/op_$op.txt
done
python3 scripts/gen_operators.py /path/to/hippoLBM help > docs/User/Operators/index.md