https://github.com/cans-world/cans
A code for fast, massively-parallel direct numerical simulations (DNS) of canonical flows
Science Score: 59.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org -
✓Committers with academic emails
1 of 6 committers (16.7%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.3%) to scientific vocabulary
Keywords
Repository
A code for fast, massively-parallel direct numerical simulations (DNS) of canonical flows
Basic Info
Statistics
- Stars: 246
- Watchers: 13
- Forks: 86
- Open Issues: 4
- Releases: 22
Topics
Metadata Files
README.md

Synopsis
CaNS (Canonical Navier-Stokes) is a code for massively-parallel numerical simulations of fluid flows. It aims at solving any fluid flow of an incompressible, Newtonian fluid that can benefit from a FFT-based solver for the second-order finite-difference Poisson equation in a 3D Cartesian grid. In two directions the grid is regular and the solver supports the following combination of (homogeneous) boundary conditions:
- Neumann-Neumann
- Dirichlet-Dirichlet
- Neumann-Dirichlet
- Periodic
In the third domain direction, the solver is more flexible as it uses Gauss elimination. There the grid can also be non-uniform (e.g. fine at the boundary and coarser in the center).
CaNS also allows for choosing an implicit temporal discretization of the momentum diffusion terms, either fully implicit or only along the last domain direction. This results in solving a 3D/1D Helmholtz equation per velocity component. In the fully implicit case, FFT-based solvers are also used, and the same options described above for pressure boundary conditions apply to the velocity.
Reference
P. Costa. A FFT-based finite-difference solver for massively-parallel direct numerical simulations of turbulent flows. Computers & Mathematics with Applications 76: 1853--1862 (2018). doi:10.1016/j.camwa.2018.07.034 [arXiv preprint]
News
Major Update: CaNS 3.0 is out! :tada:
See the Release Notes for more details.
[06/08/2025]: Support for running on AMD-based supercomputers and new GPU communication backend available! CaNS has been ported using to other platforms using HIP and thanks to the recently developed diezDecomp library. See the updated [docs/INFO_COMPILING.md](docs/INFO_COMPILING.md) for more details.
[10/04/2025]: The writing of checkpoint files has changed. To allow for more flexibility, CaNS now writes one file per scalar field, where each velocity component, pressure, and scalar fields is stored in a different checkpoint file.
[14/02/2025]: Most pre-processor macros have been turned into runtime arguments, which allow for a much simpler control of the computational setup without re-compiling the source. See the updated docs/INFO_INPUT.md and docs/INFO_COMPILING.md for more details.
[08/02/2025]: A new approach for solving the Poisson equation based on a Parallel Cyclic Reduction -- Tridiagonal Matrix Algorithm (PCR-TDMA) approach. See docs/INFO_COMPILING.md for more details.
[31/01/2025]: CaNS now can solve the transport equations associated with an arbritrary number of scalars :tada:, with a versatile discretization of the diffusion term. Thermal convection under the Boussinesq approximation is also supported. See the updated docs/INFO_INPUT.md and docs/INFO_COMPILING.md files for more details, and some of the new cases under examples/.
[29/01/2025]: To avoid having the build.conf and configs/*.mk files - often changed by the user - tracked by git, the compiling behavior has changed slightly; see Compilation below.
[28/01/2025]: Input file input.nml has changed slightly, to allow for prescribing a fixed time step size dt_f.
Features
Some features are:
- Hybrid MPI/OpenMP parallelization
- FFTW guru interface / cuFFT used for computing multi-dimensional vectors of 1D transforms
- The right type of transformation (Fourier, cosine, sine, etc) is automatically determined form the input file
- cuDecomp pencil decomposition library for hardware-adaptive distributed memory calculations on many GPUs
- diezDecomp pencil decomposition library distributed memory calculations on various GPU/CPU hardware platforms
- 2DECOMP&FFT library used for performing global data transpositions on CPUs and some of the data I/O
- GPU acceleration using OpenACC directives
- A different canonical flow can be simulated just by changing the input files
Some examples of flows that this code can solve are:
- periodic or developing channel
- periodic or developing square duct
- tri-periodic domain
- lid-driven cavity
Motivation
This project aimed first at being a modern alternative to the well-known FISHPACK routines (Paul Swarztrauber & Roland Sweet, NCAR) for solving a three-dimensional Helmholtz equation. After noticing some works simulating canonical flows with iterative solvers -- when faster direct solvers could have been used instead -- it seemed natural to create a versatile tool and make it available. This code can be used as a first base code for which solvers for more complex flows can be developed (e.g. extensions with fictitious domain methods).
Method
The fluid flow is solved with a second-order finite difference pressure correction scheme, discretized in a MAC grid arrangement. Time is advanced with a three-step low storage Runge-Kutta scheme. Optionally, for increased stability at low Reynolds numbers, at the price of higher computational demand, the diffusion term can be treated implicitly. See the reference above for details.
Usage
Downloading CaNS
Since CaNS loads the external pencil decomposition libraries as Git Submodules, the repository should be cloned as follows:
bash
git clone --recursive https://github.com/CaNS-World/CaNS
so the libraries are downloaded too. Alternatively, in case the repository has already been cloned without the Submodules (i.e., folders cuDecomp and 2decomp-fft under dependencies/ are empty), the following command can be used to update them:
bash
git submodule update --init --recursive
Compilation
Prerequisites
The prerequisites for compiling CaNS are the following:
- MPI
- FFTW3/cuFFT library for CPU/GPU runs
- The
nvfortrancompiler (for GPU runs) - CMake for compiling the cuDecomp library (for GPU runs)
- NCCL and NVSHMEM (optional, may be exploited by the cuDecomp library)
- OpenMP (optional)
In short
For most systems, CaNS can be compiled from the root directory with the following commands make libs && make, which will compile the 2DECOMP&FFT/cuDecomp libraries, and CaNS.
Detailed instructions
The Makefile in root directory is used to compile the code, and is expected to work out-of-the-box for most systems. The build.conf file in the root directory can be used to choose the Fortran compiler (MPI wrapper), and a few pre-defined profiles depending on the nature of the run (e.g., production vs debugging), and pre-processing options; see INFO_COMPILING.md for more details. The default build.conf file is created from configs/defaults/build-default.conf at the first compilation. Concerning the pre-processing options, the following are available:
SINGLE_PRECISION: calculation will be carried out in single precision (the default precision is double)GPU: enable GPU-accelerated runs
Input file
The input file input.nml sets the physical and computational parameters. In the examples/ folder are examples of input files for several canonical flows. See INFO_INPUT.md for a detailed description of the input file.
Files out1d.h90, out2d.h90 and out3d.h90 in src/ set which data are written in 1-, 2- and 3-dimensional output files, respectively. The code should be recompiled after editing out?d.h90 files.
Running the code
Run the executable with mpirun with a number of tasks complying to what has been set in the input file dns.in. Data will be written by default in a folder named data/, which must be located where the executable is run (by default in the run/ folder).
Visualizing field data
See INFO_VISU.md.
Contributing
We appreciate any contributions and feedback that can improve CaNS. If you wish to contribute to the tool, please get in touch with the maintainers or open an Issue in the repository / a thread in Discussions. Pull Requests are welcome, but please propose/discuss the changes in an linked Issue first.
Final notes
Please read the ACKNOWLEDGEMENTS, LICENSE files.
Owner
- Name: CaNS-World
- Login: CaNS-World
- Kind: organization
- Repositories: 2
- Profile: https://github.com/CaNS-World
GitHub Events
Total
- Create event: 38
- Commit comment event: 1
- Release event: 2
- Issues event: 32
- Watch event: 40
- Delete event: 33
- Issue comment event: 36
- Push event: 186
- Pull request review comment event: 11
- Pull request review event: 15
- Pull request event: 69
- Fork event: 13
Last Year
- Create event: 38
- Commit comment event: 1
- Release event: 2
- Issues event: 32
- Watch event: 40
- Delete event: 33
- Issue comment event: 36
- Push event: 186
- Pull request review comment event: 11
- Pull request review event: 15
- Pull request event: 69
- Fork event: 13
Committers
Last synced: over 1 year ago
Top Committers
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 56
- Total pull requests: 161
- Average time to close issues: about 2 months
- Average time to close pull requests: 6 days
- Total issue authors: 9
- Total pull request authors: 10
- Average comments per issue: 1.05
- Average comments per pull request: 0.27
- Merged pull requests: 135
- Bot issues: 0
- Bot pull requests: 2
Past Year
- Issues: 16
- Pull requests: 67
- Average time to close issues: 20 days
- Average time to close pull requests: 5 days
- Issue authors: 3
- Pull request authors: 6
- Average comments per issue: 1.0
- Average comments per pull request: 0.39
- Merged pull requests: 45
- Bot issues: 0
- Bot pull requests: 2
Top Authors
Issue Authors
- p-costa (45)
- soaringxmc (3)
- nyue (2)
- manmeet3591 (1)
- lcebaman (1)
- binayakl (1)
- bahardy (1)
- sajjadintel (1)
- tommasotoffanin (1)
Pull Request Authors
- p-costa (142)
- nscapin (5)
- gianlupo (2)
- soaringxmc (2)
- v1kko (2)
- dependabot[bot] (2)
- lekzzA (2)
- benczaja (2)
- nyue (1)
- GabrieleBoga (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 4
spack.io: cans
CaNS (Canonical Navier-Stokes) is a code for massively-parallel numerical simulations of fluid flows. It aims at solving any fluid flow of an incompressible, Newtonian fluid that can benefit from a FFT-based solver for the second-order finite-difference Poisson equation in a 3D Cartesian grid.
- Homepage: https://github.com/CaNS-World/CaNS
- License: []
-
Latest release: 1.1.4
published over 3 years ago
Rankings
Maintainers (4)
Dependencies
- actions/checkout v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite