# AMPH<span style="color:red">IB</span>IOUS: A MultiPlatform High-performance Immersed-Boundary Incompressible Open-soUrce Solver

(which thrives on CPUs or GPUs, managing simple geometries and STL files too)

Code website: [http://amphibious.cfd](http://amphibious.cfd)

<!--- ## A MultiPhase Immersed-Boundary Incompressible Open-soUrce Solver -->

<img src="amphibious.png" width="100">

**AMPH<span style="color:red">IB</span>IOUS** is a DNS code that:

- solves the incompressible Navier-Stokes equations;
- is explicit in time, and corrects pressure iteratively;
- uses second-order finite differences; 
- implements a simple immersed-boundary method, fully second-order;
- runs fast on CPUs and GPUs;
- accepts analytical descriptions of simple geometries;
- accepts STL-based descriptions of complex geometries;
- is written in **[CPL](https://cplcode.net)**.

## Literature

- Code documentation: *[here](http://www.amphibious.cfd/documentation/)*
- Immersed-boundary method: [Luchini et al. (2025)](http://arxiv.org/abs/2506.14328)
- Pressure correction, code description and validation: paper in preparation... 

## Requirements

- the **[CPL](https://cplcode.net/Download)** compiler and its (few) dependencies
- a C compiler and the `nvc` compiler
- MPI for parallel CPU computing; GPU-aware support for multiGPU computing; 
- OpenACC for parallel (multi)GPU computing

## Main files

- `preproc.cpl`: sets the case up (499 lines)
- `solver.cpl`: solves the case (710 lines)
- `postproc.cpl`: post-processes the case for statistics and visualization (668 lines)
- `headers.cpl`: macro and definitions shared by `preproc` and `solver` (93 lines)
- modules (4028 lines)
- `Makefile`: compilation commands for `preproc`, `solver`, `postproc` and utilities
- `examples/channel/`: tutorial example with analytically defined geometry (flow in a plane channel)
- `examples/nose/`: tutorial example with STL-defined geometry (flow in the human nose)

## Development and testing

The folders contain all is needed to run the cases, as well as the expected screen output to be reproduced. Please reproduce `reference-output.dat` for the two examples before issuing a Merge Request

## Performance

Performance data is preliminary, before profiling and optimization.

- Scalar CPU performance: 0.055 seconds per million points/timestep
- Parallel CPU performance: nearly linear scaling observed up to 1024 cores
- Single-GPU performance: 0.00067 seconds per million points/timestep (3 pressure iterations)
- Multi-GPU performance: linear scaling observed up to 32 GPUs, where one timestep for *one billion* points takes less than 0.02 seconds

<img src="scaling.jpg" width="600">

## Contributors

marco.atzori@polimi.it, niccolo.berizzi@polimi.it, francesco1.esposito@polimi.it, paolo.luchini@cplcode.net, andrea.portioli@polimi.it, maurizio.quadrio@polimi.it and others
