FOSSIL
FOrtran Surfaces, Solids, Immersed boundaries and Level sets
Geometry for simulation codes, in pure Fortran: surfaces and 2-D curves read, repaired, processed and measured;
signed distances and level sets; immersed-boundary queries and AMR tagging; exact cut cells and their solver support;
curvilinear blocks and overset assembly; body-fitted grids; moving bodies and collision; on the CPU or bit-exact on
the GPU.
๐ STL in, STL out ASCII or binary, format detected, NaN and Inf rejected with a status; analyze gives the box, volume, centroid, connectivity, shells and bodies. First surface |
๐ฉน Repair dirty meshes sanitize removes slivers and duplicates, closes gaps and orients the normals outward; fill_holes patches and fairs the holes left. Repair |
๐ ๏ธ Geometry processing Exact booleans and self-intersections, decimation, isotropic remeshing, smoothing, alpha wrapping, marching cubes, segmentation. Processing and analysis |
๐ฌ Geometry analysis Mass properties, certified deviation and Hausdorff distance, feature edges, local thickness and gaps, curvature, named patches. Processing and analysis |
๐ Signed distance Closest facet on a SAH BVH, bit-exact against brute force; four sign algorithms, the fast winding number for surfaces with holes. Distance |
๐ Level sets A signed-distance field on a stretched grid: exact narrow band, flood-fill signs, fast sweeping, an eikonal diagnostic. Distance fields |
ใฐ๏ธ 2-D curves Closed and open polylines for quadtree solvers, with the same queries as the surfaces; sections of any STL by a grid plane. Curves |
๐ฏ Immersed-boundary queries Per point: closest point, feature, pseudo-normal and body; image points and probes; wall distance with cutoff; wall curvature. IB queries |
๐งญ AMR tagging Blocks and cells classified as cut, near, inside or outside from the tree alone; signed tag bands on a block. AMR tagging |
๐งฑ Exact cut cells Grid-line crossings decided by exact predicates; 2-D and 3-D fluid fractions, apertures and fluid pieces with their own volumes. Cut cells |
๐งฉ Cut-cell solver support Links between pieces, state- and flux-redistribution neighbourhoods, merge targets, moments, quadrature rules and coarse levels. Solver support |
๐ Moving bodies Body-frame queries without a rebuild, an O(N) tree refit, and the swept geometry of a time step: exact swept volumes. Moving bodies |
๐ฅ Collision detection Body-body distance with the closest pair; the time of first contact by conservative advancement, with no tunnelling; the first impact among many bodies. Contact |
๐ธ๏ธ Structured blocks Curvilinear blocks: topology detection, certified cell validity, point location by tree or stencil walk, interpolation stencils, quality. Blocks and overset |
๐ Overset assembly Holes by winding number, hole map or X-rays; donor candidates with their quality; explicit or implicit classification, orphans by cause, connectivity. Blocks and overset |
๐ Body-fitted grids Projection constrained to patches, feature curves and corners; 2-D hyperbolic extrusion; a wall-spacing and quality report with y1+. Body-fitted grids |
๐ On the GPU, bit for bit OpenACC kernels shared with the CPU path: distances, rich queries, tagging and posed queries equal the CPU results bit for bit. GPU |
๐ Free and portable Pure Fortran 2003+, no C; gfortran, ifx, nvfortran; FoBiS or fpm; GPLv3, BSD or MIT. Installation |
A NACA 0012 section pitching and translating through a Cartesian grid, every frame computed by FOSSIL: its exact cut cells and the level sets of its signed distance, with the pose passed to the query instead of rebuilding the tree.
Grids around bodies: an overset assembly recomputed as the cylinder's O-grid moves through the background, with the orphans that appear where it leaves it, and a body-fitted O-grid marched out of the section by hyperbolic extrusion.
 STL in, STL out the dragon loaded, 6588 facets, and the box analyze computes |
 Repair dirty meshes holes closed one by one by fill_holes, refined and faired |
 Geometry processing a block drilled nine times, each step checked by an independent boolean |
 Geometry analysis a decimation sweep coloured by its certified distance from the original |
 Signed distance probes and their closest points on the dragon |
 Level sets the signed-distance field on a stretched grid |
 2-D curves a section of the dragon and its 2-D signed distance |
 Immersed-boundary queries closest points on a face, an edge or a vertex |
 AMR tagging cut, inside and outside cells of a block, in signed bands |
 Exact cut cells the fluid fraction of the cut cells of a section |
 Cut-cell solver support the small pieces of a moving ellipse and their merge targets, every frame |
 Moving bodies the area a moving section sweeps in a time step |
 Collision detection conservative advancement to the time of impact: plain bound, 25 steps; directional, 5 |
 Structured blocks points tracked through an O-grid by stencil walks, across its seam |
 Overset assembly an O-grid over a background: the holes, the receptors around them, the O-grid's receptors |
 Body-fitted grids an O-grid marched out of a NACA 0012 section by hyperbolic extrusion |
 On the GPU, bit for bit the device code path on a slice: 0 differences from the host |
 Free and portable the tutorial programs, run one after the other |
The tutorial, the cookbook and the reference are on the FOSSIL website. Every code sample there is a program compiled and run to produce the output shown.
Authors
Stefano Zaghi ยท stefano.zaghi@cnr.it
Chief Yak Shaver, Accidental Research Scientist, and HPC Farmer โ CFD researcher who decided that one more day debugging Fortran build systems was one day too many, opened a Python REPL "just to prototype," and now finds himself maintaining a meshing library, a chimera assembler, an MPI load balancer, and the seven blog tabs he keeps meaning to read.
Claude (Anthropic)
Omniscient Code Oracle & Tireless Rubber Duck โ AI pair programmer, responsible for writing the boring parts so humans don't have to.
Contributions are welcome โ see the Contributing page.
Copyrights
This project is distributed under a multi-licensing system:
Anyone interested in using, developing, or contributing to this project is welcome โ pick the license that best fits your needs.
Quick start
use fossil
use penf, only: R8P
use vecfor, only: ex_R8P
implicit none
type(surface_stl_object) :: surface
real(R8P) :: d
! Load (ASCII or binary, auto-detected) and run the full repair pipeline.
call surface%load_from_file(file_name='cube.stl', guess_format=.true.)
call surface%sanitize ! degenerate / duplicate / non-manifold / winding
print '(A)', surface%statistics()
! Signed distance from a point โ uses SAH BVH + pseudo-normal sign by default.
d = surface%distance(point=2.0_R8P * ex_R8P, is_signed=.true., is_square_root=.true.)
print '(A,ES12.5)', 'signed distance = ', d
call surface%translate(x=1.0_R8P, y=2.0_R8P, z=0.5_R8P)
call surface%save_into_file(file_name='cube-moved.stl')
See src/tests/ for more examples including clipping, distance queries, and validity predicates (is_watertight, is_manifold, is_volume).
For interactive use without writing Fortran, the companion fossilizer CLI (src/app/fossilizer.f90) wraps the library for command-line STL analysis and manipulation.
Install
Upgrading from 2.x: see Upgrading to 3.0 for the changes in behaviour.
One-line install
curl -fsSL https://github.com/szaghi/FOSSIL/releases/latest/download/install.sh | bash
It installs the latest release into ~/.local with the build system you choose among those FOSSIL ships
(--build fobis|fpm: a menu asks when you do not say), the compiler you name (--fc, --gnu, --intel,
--nvidia), one install per compiler (lib/fossil/<compiler>-<version>/, include/fossil/<compiler>-<version>/), and
makes it usable through pkg-config (pkg-config --cflags --libs fossil, with PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig).
The release carries FOSSIL's dependencies (BeFoR64, FACE, FLAP, FoXy, PENF, StringiFor, VTKFortran, VecFor). Pass
options after bash -s --, e.g. ... | bash -s -- --build fpm --prefix /opt/fossil; --help lists them all,
--uninstall removes the install. The installer is FoBiS's
(One-line installer).
FoBiS
Standalone โ clone, fetch the dependencies into src/third_party/, and build:
git clone https://github.com/szaghi/FOSSIL && cd FOSSIL
fobis fetch # fetch the fobos [dependencies]
fobis build --mode static-gnu # build static library
fobis build --mode tests-gnu && ./scripts/run_tests.sh # build and run tests
As a project dependency โ declare FOSSIL in your fobos and run fetch:
[dependencies]
deps_dir = src/third_party
FOSSIL = https://github.com/szaghi/FOSSIL
fobis fetch # fetch and build
fobis fetch --update # re-fetch and rebuild
fpm
git clone https://github.com/szaghi/FOSSIL && cd FOSSIL
fpm build --profile release # fpm resolves the dependencies from fpm.toml
As an fpm dependency:
[dependencies]
FOSSIL = { git = "https://github.com/szaghi/FOSSIL.git" }
FOSSIL ships no CMake or Make build files.