InterfaceReconstructionLibrary.jl
A Julia wrapper for the Interface Reconstruction Library (IRL), a C++ library for geometric volume-of-fluid computations: interface reconstruction, volume and moment calculation, and polyhedron/half-space cutting.
Installation
pkg> add InterfaceReconstructionLibraryThe C library ships as IRL_jll, so there is nothing to build by hand.
Building the C library yourself
Only needed if you are changing IRL itself or testing against an unreleased commit. Build libirl_c and point IRL_LIBPATH at it before using InterfaceReconstructionLibrary; that overrides the JLL binary:
git clone https://github.com/robert-chiodi/interface-reconstruction-library.git irl
cmake -S irl -B irl/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \
-DCMAKE_PREFIX_PATH=/path/to/eigen-install
cmake --build irl/build --target irl_c -j
export IRL_LIBPATH=$PWD/irl/build/libirl_c.so
julia --project=. test/runtests.jlYou need CMake, a C++14 compiler, gfortran, and Eigen3.
Usage
using InterfaceReconstructionLibrary
set_cutting_method!(RecursiveSimplex)
# A tetrahedron; columns are vertices.
tet = Tet([0.0 1.0 0.0 0.0;
0.0 0.0 0.0 1.0;
0.0 0.0 1.0 0.0])
volume(tet) # 1/6
# Cut it with the plane x = 0.5. IRL's internal side is normal·x <= distance.
sep = PlanarSeparator([([1.0, 0.0, 0.0], 0.5)])
internal_volume(tet, sep) # 7/48
# Volume + centroid of both sides at once.
cube = RectangularCuboid([0,0,0], [1,1,1])
m = separated_moments(cube, sep)
volume(m, Internal) # 0.5
centroid(m, Internal) # [0.25, 0.5, 0.5]
# Moment-of-fluid reconstruction: recover a separator from moments.
rec = reconstruct_mof(cube, m)Two things to know about IRL's conventions:
- Volumes are signed, so vertex ordering matters.
- Cutting expects a plane that passes through the cell. A separator placed entirely outside the cell gives a degenerate result (this matches IRL's C++ behaviour; it is not a bug in this wrapper).
See Conventions for indexing rules and how reconstruction guesses are built, and the API reference for the full list of exported functions.
Licence
The wrapper code is MIT. It wraps IRL, which is MPL-2.0; the compiled binaries (distributed via IRL_jll) stay under MPL-2.0.