/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Class Foam::GAMGSolver Group grpLduMatrixSolvers Description Geometric agglomerated algebraic multigrid solver. Characteristics: - Requires positive definite, diagonally dominant matrix. - Agglomeration algorithm: selectable and optionally cached. - Restriction operator: summation. - Prolongation operator: injection. - Smoother: Gauss-Seidel. - Coarse matrix creation: central coefficient: summation of fine grid central coefficients with the removal of intra-cluster face; off-diagonal coefficient: summation of off-diagonal faces. - Coarse matrix scaling: performed by correction scaling, using steepest descent optimisation. - Type of cycle: V-cycle with optional pre-smoothing. - Coarsest-level matrix solved using any lduSolver (PCG, PBiCGStab, smoothSolver) or direct solver on master processor SourceFiles GAMGSolver.C GAMGSolverAgglomerateMatrix.C GAMGSolverInterpolate.C GAMGSolverScale.C GAMGSolverSolve.C \*---------------------------------------------------------------------------*/ #ifndef Foam_GAMGSolver_H #define Foam_GAMGSolver_H #include "GAMGAgglomeration.H" #include "lduMatrix.H" #include "primitiveFields.H" #include "LUscalarMatrix.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class GAMGSolver Declaration \*---------------------------------------------------------------------------*/ class GAMGSolver : public lduMatrix::solver { // Private Data //- Number of pre-smoothing sweeps label nPreSweeps_; //- Lever multiplier for the number of pre-smoothing sweeps label preSweepsLevelMultiplier_; //- Maximum number of pre-smoothing sweeps label maxPreSweeps_; //- Number of post-smoothing sweeps label nPostSweeps_; //- Lever multiplier for the number of post-smoothing sweeps label postSweepsLevelMultiplier_; //- Maximum number of post-smoothing sweeps label maxPostSweeps_; //- Number of smoothing sweeps on finest mesh label nFinestSweeps_; //- Cache the agglomeration (default: true) bool cacheAgglomeration_; //- Choose if the corrections should be interpolated after injection. // By default corrections are not interpolated. bool interpolateCorrection_; //- Choose if the corrections should be scaled. // By default corrections for symmetric matrices are scaled // but not for asymmetric matrices. bool scaleCorrection_; //- Direct or iteratively solve the coarsest level bool directSolveCoarsest_; //- The agglomeration const GAMGAgglomeration& agglomeration_; //- Hierarchy of matrix levels PtrList matrixLevels_; //- Hierarchy of interfaces. PtrList> primitiveInterfaceLevels_; //- Hierarchy of interfaces in lduInterfaceFieldPtrs form PtrList interfaceLevels_; //- Hierarchy of interface boundary coefficients PtrList> interfaceLevelsBouCoeffs_; //- Hierarchy of interface internal coefficients PtrList> interfaceLevelsIntCoeffs_; //- LU decomposed coarsest matrix autoPtr coarsestLUMatrixPtr_; //- Sparse coarsest matrix solver autoPtr coarsestSolverPtr_; // Private Member Functions //- Read control parameters from the control dictionary virtual void readControls(); //- Simplified access to interface level const lduInterfaceFieldPtrsList& interfaceLevel ( const label i ) const; //- Simplified access to matrix level const lduMatrix& matrixLevel(const label i) const; //- Simplified access to interface boundary coeffs level const FieldField& interfaceBouCoeffsLevel ( const label i ) const; //- Simplified access to interface internal coeffs level const FieldField& interfaceIntCoeffsLevel ( const label i ) const; //- Agglomerate coarse matrix. Supply mesh to use - so we can // construct temporary matrix on the fine mesh (instead of the coarse // mesh) void agglomerateMatrix ( const label fineLevelIndex, const lduMesh& coarseMesh, const lduInterfacePtrsList& coarseMeshInterfaces ); //- Agglomerate coarse interface coefficients void agglomerateInterfaceCoefficients ( const label fineLevelIndex, const lduInterfacePtrsList& coarseMeshInterfaces, PtrList& coarsePrimInterfaces, lduInterfaceFieldPtrsList& coarseInterfaces, FieldField& coarseInterfaceBouCoeffs, FieldField& coarseInterfaceIntCoeffs ) const; //- Collect matrices from other processors void gatherMatrices ( const label destLevel, const label comm, const lduMatrix& mat, const FieldField& interfaceBouCoeffs, const FieldField& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, PtrList& otherMats, PtrList>& otherBouCoeffs, PtrList>& otherIntCoeffs, PtrList>& otherInterfaces ) const; //- Agglomerate processor matrices void procAgglomerateMatrix ( // Agglomeration information const labelList& procAgglomMap, const List