Packaged with the library are a number of example applications that demonstrate the construction of models using the methods available through IBAMR.
Contents
- Where are the examples?
- Choosing an example
- Example source code
- Building and running examples
- Adapting examples
Where are the examples?
The primary IBAMR examples are in examples/. Lower-level examples for IBTK
building blocks are in ibtk/examples/.
IBAMR_SRC_DIR/
|-- examples/ primary IBAMR examples
`-- ibtk/examples/ lower-level IBTK examples
Choosing an example
The source tree is the definitive list, but these starting points are usually the most useful:
- For immersed boundary applications, start with
examples/IBfor classical IB methods,examples/IBFEfor finite-element immersed structures,examples/CIBfor exactly constrained IB methods,examples/ConstraintIBfor constraint-based IB models, andexamples/IIMfor immersed interface and related Lagrangian-Eulerian methods. - For Eulerian solver examples, look at
examples/navier_stokes,examples/vc_navier_stokes,examples/advect,examples/adv_diff, andexamples/level_set. - For coupled or application-oriented models, look at examples involving finite-element mechanics, complex fluids, multiphase flow, and wave tanks.
- For lower-level library usage, look in
ibtk/examplesfor examples of grid operations, elliptic solvers, boundary condition utilities, ghost-cell filling, and PETSc-related operations.
Example source code
Most examples use example.cpp as the main source file. Some examples include
additional C++ source and header files, generated geometry helpers, or use a
different main source filename such as main.cpp. Input files are commonly
named input2d, input3d, or variants of those names.
Building and running examples
Configure and build IBAMR with CMake first; see the Building page for the supported build workflow. From the IBAMR build directory, build all examples with:
cmake --build . --target examples --parallel 8
To build one major example group, use its CMake group target. For example:
cmake --build . --target examples-IB --parallel 8
You can list the available targets from the build directory with:
cmake --build . --target help
CMake target names are global, and individual executable targets are not always the same as the executable filenames.
For a concrete example, build and run the two-dimensional explicit immersed
boundary example examples/IB/explicit/ex1 from the IBAMR build directory:
cmake --build . --target IB-ex1 --parallel 8
cd examples/IB/explicit/ex1
./main2d input2d
Here IB-ex1 is the CMake target name, and main2d is the executable written
into the build-tree example directory. The cd command above is relative to the
IBAMR build directory, not the source directory. The CMake target also copies
the needed input and structure files into that directory, so they do not need to
be copied manually. A successful run prints immersed-boundary initialization
output and timestep progress, and may write log or visualization output files.
Not every example provides both main2d and main3d. Some examples also
require optional IBAMR features, such as libMesh support; examples whose
requirements are not enabled in a particular build are skipped by the CMake
configuration.
Adapting examples
The examples are useful starting points for source files, input databases, mesh files, and solver settings. For an application built outside the IBAMR source tree, use the CMake package workflow described on the Applications page, rather than copying build-system files from an example directory.
Tutorial slides for IBAMR
The slide deck used for the NITMB workshop Mathematical Modeling, Computational Methods, and Biological Fluid Dynamics: Research and Training can be downloaded here