1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Geometric agglomerated algebraic multigrid solver.
32 - Requires positive definite, diagonally dominant matrix.
33 - Agglomeration algorithm: selectable and optionally cached.
34 - Restriction operator: summation.
35 - Prolongation operator: injection.
36 - Smoother: Gauss-Seidel.
37 - Coarse matrix creation: central coefficient: summation of fine grid
38 central coefficients with the removal of intra-cluster face;
39 off-diagonal coefficient: summation of off-diagonal faces.
40 - Coarse matrix scaling: performed by correction scaling, using steepest
42 - Type of cycle: V-cycle with optional pre-smoothing.
43 - Coarsest-level matrix solved using ICCG or BICCG.
47 GAMGSolverCalcAgglomeration.C
48 GAMGSolverMakeCoarseMatrix.C
49 GAMGSolverOperations.C
52 \*---------------------------------------------------------------------------*/
57 #include "GAMGAgglomeration.H"
58 #include "lduMatrix.H"
59 #include "labelField.H"
60 #include "primitiveFields.H"
61 #include "LUscalarMatrix.H"
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 /*---------------------------------------------------------------------------*\
70 Class GAMGSolver Declaration
71 \*---------------------------------------------------------------------------*/
75 public lduMatrix::solver
79 Switch cacheAgglomeration_;
81 //- Number of pre-smoothing sweeps
84 //- Number of post-smoothing sweeps
87 //- Number of smoothing sweeps on finest mesh
90 //- Choose if the corrections should be scaled.
91 // By default corrections for symmetric matrices are scaled
92 // but not for asymmetric matrices.
93 bool scaleCorrection_;
95 //- Direct or iteratively solve the coarsest level
96 bool directSolveCoarsest_;
99 const GAMGAgglomeration& agglomeration_;
101 //- Hierarchy of matrix levels
102 PtrList<lduMatrix> matrixLevels_;
104 //- Hierarchy of interfaces.
105 // Warning: Needs to be deleted explicitly.
106 PtrList<lduInterfaceFieldPtrsList> interfaceLevels_;
108 //- Hierarchy of interface boundary coefficients
109 PtrList<FieldField<Field, scalar> > interfaceLevelsBouCoeffs_;
111 //- Hierarchy of interface internal coefficients
112 PtrList<FieldField<Field, scalar> > interfaceLevelsIntCoeffs_;
114 //- LU decompsed coarsest matrix
115 autoPtr<LUscalarMatrix> coarsestLUMatrixPtr_;
118 // Private Member Functions
120 //- Read control parameters from the control dictionary
121 virtual void readControls();
123 //- Simplified access to interface level
124 const lduInterfaceFieldPtrsList& interfaceLevel
129 //- Simplified access to matrix level
130 const lduMatrix& matrixLevel(const label i) const;
132 //- Simplified access to interface boundary coeffs level
133 const FieldField<Field, scalar>& interfaceBouCoeffsLevel
138 //- Simplified access to interface internal coeffs level
139 const FieldField<Field, scalar>& interfaceIntCoeffsLevel
144 //- Agglomerate coarse matrix
145 void agglomerateMatrix(const label fineLevelIndex);
147 //- Calculate and return the scaling factor from Acf, coarseSource
149 // At the same time do a Jacobi iteration on the coarseField using
150 // the Acf provided after the coarseField values are used for the
155 const scalarField& source,
156 const scalarField& Acf,
160 //- Calculate Acf and calculate and return the scaling factor.
166 const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
167 const lduInterfaceFieldPtrsList& interfaceLevel,
168 const scalarField& source,
173 //- Initialise the data structures for the V-cycle
176 PtrList<scalarField>& coarseCorrFields,
177 PtrList<scalarField>& coarseSources,
178 PtrList<lduMatrix::smoother>& smoothers
182 //- Perform a single GAMG V-cycle with pre, post and finest smoothing.
185 const PtrList<lduMatrix::smoother>& smoothers,
187 const scalarField& source,
189 scalarField& finestCorrection,
190 scalarField& finestResidual,
191 PtrList<scalarField>& coarseCorrFields,
192 PtrList<scalarField>& coarseSources,
193 const direction cmpt=0
197 //- Solve the coarsest level with either an iterative or direct solver
198 void solveCoarsestLevel
200 scalarField& coarsestCorrField,
201 const scalarField& coarsestSource
207 friend class GAMGPreconditioner;
209 //- Runtime type information
215 //- Construct from lduMatrix and solver controls
218 const word& fieldName,
219 const lduMatrix& matrix,
220 const FieldField<Field, scalar>& interfaceBouCoeffs,
221 const FieldField<Field, scalar>& interfaceIntCoeffs,
222 const lduInterfaceFieldPtrsList& interfaces,
223 const dictionary& solverControls
229 virtual ~GAMGSolver();
235 virtual lduMatrix::solverPerformance solve
238 const scalarField& source,
239 const direction cmpt=0
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 } // End namespace Foam
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 // ************************************************************************* //