Skip to main content

outram_foam_basic_lib/ldu_matrix/
mod.rs

1// SPDX-License-Identifier: GPL-3.0-only
2// Copyright (C) 2026 OUTRAM PARK contributors
3// Derived from OpenFOAM (www.openfoam.com)
4// Copyright (C) 2004-2023 OpenFOAM Foundation
5// Copyright (C) 2016-2023 OpenCFD Ltd.
6//
7// This file is part of OUTRAM PARK.
8//
9// OUTRAM PARK is free software: you can redistribute it and/or modify it
10// under the terms of the GNU General Public License as published by the
11// Free Software Foundation, either version 3 of the License, or (at your
12// option) any later version.
13//
14// OUTRAM PARK is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17// General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License along
20// with OUTRAM PARK.  If not, see <https://www.gnu.org/licenses/>.
21
22//! Sparse LDU (lower-diagonal-upper) linear algebra for implicit FV solves.
23//!
24//! Holds the face-addressed sparse matrix representation used by the
25//! finite-volume implicit operators and the iterative solvers that invert it:
26//!
27//! - [`ldu_matrix::LduMatrix`] — the raw sparse coefficients (diagonal + per-face
28//!   lower/upper off-diagonals) and matrix–vector / residual kernels.
29//! - [`FvMatrix`](crate::ldu_matrix::fv_matrix::FvMatrix) — a scalar equation `A·φ = b` for a `VolScalarField`,
30//!   assembled by the Layer-3 `fvm::` operators.
31//! - [`FvVectorMatrix`](crate::ldu_matrix::fv_vector_matrix::FvVectorMatrix) — the vector counterpart `A·U = b` with
32//!   scalar LDU coefficients and a `Field<Vector3>` source.
33//! - [`parallel`](crate::ldu_matrix::parallel) — the same sparse product and the
34//!   per-iteration vector operations on the hybrid execution backend
35//!   ([`HybridLdu`](crate::ldu_matrix::parallel::HybridLdu),
36//!   [`LduTopology`](crate::ldu_matrix::parallel::LduTopology)): one entry point
37//!   per operation taking a [`ComputeBackend`](crate::compute::ComputeBackend),
38//!   serial or multi-CPU, bit-for-bit identical either way.
39//! - [`solvers`](crate::ldu_matrix::solvers) — Gauss-Seidel, DIC-preconditioned conjugate gradient, GAMG
40//!   (algebraic multigrid), and the [`krylov_solve`](crate::ldu_matrix::solvers::krylov_solve()) adapter onto the asymmetric
41//!   BiCGStab / GMRES kernels in [`crate::krylov`].
42//!
43//! Belongs here: the sparse-matrix storage, its arithmetic, and the linear
44//! solvers. Field types, meshes, and the differential operators that build these
45//! matrices live in their own modules.
46
47pub mod fv_matrix;
48pub mod fv_vector_matrix;
49pub mod ldu_matrix;
50pub mod parallel;
51pub mod solvers;
52
53pub use fv_matrix::{FvMatrix, SolverPerformance, SolverSettings};
54pub use fv_vector_matrix::FvVectorMatrix;
55pub use ldu_matrix::LduMatrix;
56pub use parallel::{HybridLdu, LduTopology};
57pub use solvers::conjugate_gradient;
58pub use solvers::gamg;
59pub use solvers::gauss_seidel;
60pub use solvers::krylov_solve::{
61    krylov_solve, krylov_solve_prepared, KrylovMethod, KrylovOptions, PreconditionerKind,
62};