Skip to main content

Crate tpt_sci_cfd_core

Crate tpt_sci_cfd_core 

Source
Expand description

§tpt-sci-cfd-core

A small, dependency-light incompressible Navier–Stokes solver built from scratch (no wrapped engine — pravash was audited and rejected, GPL-3.0-only) using a collocated finite-volume discretization on a uniform staggered grid with a fractional-step (Chorin) pressure projection.

It provides the foundation that the biomedical/earth-science crates (tpt-sci-hemodynamics, tpt-sci-ocean) build on. The core pieces:

  • A CollocatedGrid uniform grid with cell-centred velocity storage.
  • An explicit advection–diffusion update Step::momentum plus a pressure Poisson projection Step::project that enforces ∇·u = 0 (the fractional-step scheme).
  • Optional algebraic turbulence::eddy_viscosity (Smagorinsky) and a full two-equation komega_sst::KOmegaSst Menter SST closure.
  • An implicit simple::SimpleSolver pressure-correction (SIMPLE/PISO style) that solves the pressure Poisson equation with the sparse conjugate-gradient solver from tpt-sci-grid and corrects the velocity.
  • An additive unstructured::UnstructuredMesh finite-volume path (triangular cells in 2-D) with a gradient/reconstruction helper and a diffusion + upwind-advection residual assembly that can solve a steady Laplace/Poisson problem converging to the analytic solution.

The structured explicit Step and algebraic turbulence model remain the teaching / coupling primitive; the three additions above close the v1 “out of scope” items.

§Example

use tpt_sci_cfd_core::{CollocatedGrid, Step, Boundary};
use tpt_math_linalg::tpt_math_linalg_dense::DVector;

// 32×32 cavity, lid moving at u = 1.0 on the top wall.
let grid = CollocatedGrid::new(32, 32, 1.0, 1.0).unwrap();
let mut step = Step::new(grid, 1e-2, 0.01, 1.0);
step.set_boundary(Boundary::Top, 1.0);
// One fractional-step update (advect/diffuse + project).
let ok = step.advance();
assert!(ok);

Re-exports§

pub use komega_sst::KOmegaSst;
pub use scalar::ScalarTransport;
pub use simple::SimpleSolver;
pub use unstructured::Face;
pub use unstructured::UnstructuredMesh;

Modules§

komega_sst
Two-equation k-ω SST turbulence closure (Menter, 2003).
scalar
Scalar transport (species or temperature) on the collocated grid.
simple
SIMPLE-style implicit pressure-correction solver.
turbulence
Lightweight algebraic turbulence modelling for tpt-sci-cfd-core.
unstructured
Unstructured (triangular) finite-volume/finite-element solver.

Structs§

CollocatedGrid
A uniform 2-D collocated grid of nx × ny cells, physical size lx × ly. Velocities u, v are stored cell-centred.
Step
One fractional-step of the incompressible Navier–Stokes solver on a collocated grid.

Enums§

Boundary
Boundary walls of the rectangular domain.
CfdError
Errors raised by the CFD core solver.