How code-saturne/code_saturne works
Project Type and Purpose
• Code_Saturne is a large‐scale, open‐source Computational Fluid Dynamics (CFD) application designed for HPC.
• It provides both CLI and GUI front‐ends, Python scripting, a study‐manager module, and a modular C++/Fortran core engine with parallel MPI support.
• Dedicated physics modules (turbulence, combustion, radiative transfer, multiphase, atmospheric chemistry, groundwater, etc.) plug into the core finite‐volume (FVM) solver.
File Structure Analysis
Top‐level:
• bin/ → launcher scripts (bash, Python)
• python/ → Python API, GUI (Qt-based) and study‐manager
• src/ → core engine subdivided into folders (base services, FVM, algebraic solvers, physics submodules: atmo, cdo, turb, etc.)
• external/ → third‐party physics libraries (e.g., atmospheric chemistry)
• extras/ → coupling support (FMI, batch scripts, templates)
• data/ → default configuration, thermodynamic data, user scripts
• tests/ → unit and regression tests
• docs/ → user and developer guides, Doxygen, manpages
• sbin/, libple/… → auxiliary installation, mesh‐location library
Key README Insights
• Emphasizes portability, MPI parallelism, variety of mesh and output formats (CGNS, MED, EnSight).
• In‐situ post‐processing via ParaView Catalyst and Melissa.
• Coupling with external EDF tools (SYRTHES, code_aster).
a. Main Components
1. User Interfaces
• CLI tools (bin/code_saturne.py, code_saturne.sh)
• Python GUI (python/code_saturne/gui) – Qt‐based (MVC pattern)
• Study‐manager (python/code_saturne/studymanager)
2. Python API Layer
• Case management, XML reader/writer, scripting glue
3. Core Engine
• C++/Fortran solver executable (src/apps/cs_solver, cs_io_dump)
• Layered modules:
• Base services (src/base): I/O, parallelism, logging, mesh handling
• FVM framework (src/fvm): grid data structures, discretization kernels
• Algebraic solvers (src/alge): matrix assembly, iterative solvers, CUDA/HIP accelerations
• Physics submodules (src/atmo, cdo, turb, comb, rayt, gwf, lagr, etc.)
• User extension hooks (src/user) and examples
4. Data & Case Configuration
• XML engine (python and C++ modules)
• Configuration files (data/setup.xml, extras templates)
5. External Services & Libraries
• MPI communication
• Mesh import/export (CGNS, MED, GMSH via MEDcoupling, HDF5)
• Linear algebra (PETSc, Hypre, MUMPS, AMGX)
• In‐situ post (Catalyst, Melissa)
• Coupling frameworks (FMI, SYRTHES, code_aster)
6. Post-Processing & Visualization
• File output modules (EnSight, CGNS, MED writers)
• In‐situ adapters
b. Relationships & Interactions
• UI ↔ Python API: user commands → case definition → XML and control files
• Python API → Core Engine: invokes solver binary with MPI, passing configuration
• Core Engine → Modules: orchestrates mesh import, discretization, solve loops, physics modules
• Core Engine ↔ External libs: calls MPI, solver libraries, I/O libraries, Catalyst/Melissa
• Core Engine → Output modules → Post‐processing data
• Python study‐manager → post‐processing scripts, plotting
c. Architectural Patterns & Principles
• Layered architecture: UI → API → Core → Modules → Libraries
• Plugin/modular physics modules loaded at runtime via XML configuration
• MVC pattern in Qt GUI
• Separation of concerns: mesh handling, numerical kernels, physics, I/O distinctly organized
• Parallel distributed-memory design via MPI and domain decomposition
d. Key Technologies
• C++17, CUDA (optional), Fortran for numerical kernels
• Python 3 with Qt5/4, PyQt or PySide
• XML for case description
• GNU Autotools / CMake build system
• MPI, PETSc, Hypre, MUMPS, AMGX
• CGNS, MED, HDF5, ParaView Catalyst, Melissa