1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 AMG preconditioner for BlockLduMatrix
31 Klas Jareteg, 2013-04-15
33 \*---------------------------------------------------------------------------*/
35 #include "BlockAmgPrecon.H"
36 #include "fineBlockAmgLevel.H"
37 #include "addToRunTimeSelectionTable.H"
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 Foam::BlockAmgPrecon<Type>::BlockAmgPrecon
48 const BlockLduMatrix<Type>& matrix,
49 const dictionary& dict
56 cycle_(BlockAmgCycle<Type>::cycleNames_.read(dict.lookup("cycle"))),
57 nPreSweeps_(readLabel(dict.lookup("nPreSweeps"))),
58 nPostSweeps_(readLabel(dict.lookup("nPostSweeps"))),
59 nMaxLevels_(readLabel(dict.lookup("nMaxLevels"))),
60 scale_(dict.lookup("scale")),
63 new BlockAmgCycle<Type>
65 autoPtr<BlockAmgLevel<Type> >
67 new fineBlockAmgLevel<Type>
71 dict.lookup("coarseningType"),
72 readLabel(dict.lookup("groupSize")),
73 readLabel(dict.lookup("minCoarseEqns")),
74 dict.lookup("smoother")
79 xBuffer_(matrix.lduAddr().size())
82 amgPtr_->makeCoarseLevels(nMaxLevels_);
86 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 Foam::BlockAmgPrecon<Type>::~BlockAmgPrecon()
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 Foam::label Foam::BlockAmgPrecon<Type>::nLevels() const
98 return amgPtr_->nLevels();
103 const Foam::Field<Type>& Foam::BlockAmgPrecon<Type>::residual
105 const Field<Type>& x,
109 // Calculate residual
110 amgPtr_->residual(x, b, xBuffer_);
117 void Foam::BlockAmgPrecon<Type>::cycle
136 void Foam::BlockAmgPrecon<Type>::precondition
142 // Execute preconditioning
148 // ************************************************************************* //