1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | 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 Incmplete Cholesky preconditioning with no fill-in
31 Hrvoje Jasak, Wikki Ltd. All rights reserved
33 \*---------------------------------------------------------------------------*/
36 #include "addToRunTimeSelectionTable.H"
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(ILU0, 0);
45 addasymMatrixConstructorToTable<ILU0>
46 addILU0ditionerAsymMatrixConstructorToTable_;
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 void Foam::ILU0::calcPreconDiag()
54 if (matrix_.asymmetric())
56 const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
57 const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
59 // Get off-diagonal matrix coefficients
60 const scalarField& upper = matrix_.upper();
61 const scalarField& lower = matrix_.lower();
63 forAll (upper, coeffI)
65 preconDiag_[upperAddr[coeffI]] -=
66 upper[coeffI]*lower[coeffI]/preconDiag_[lowerAddr[coeffI]];
70 // Invert the diagonal for future use
71 forAll (preconDiag_, i)
73 preconDiag_[i] = 1.0/preconDiag_[i];
78 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
82 const lduMatrix& matrix,
83 const FieldField<Field, scalar>& coupleBouCoeffs,
84 const FieldField<Field, scalar>& coupleIntCoeffs,
85 const lduInterfaceFieldPtrsList& interfaces,
86 const dictionary& dict
96 preconDiag_(matrix_.diag())
104 const lduMatrix& matrix,
105 const FieldField<Field, scalar>& coupleBouCoeffs,
106 const FieldField<Field, scalar>& coupleIntCoeffs,
107 const lduInterfaceFieldPtrsList& interfaces
117 preconDiag_(matrix_.diag())
123 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 void Foam::ILU0::precondition
134 const scalarField& b,
140 x[i] = b[i]*preconDiag_[i];
143 if (matrix_.asymmetric())
145 const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
146 const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
147 const unallocLabelList& losortAddr = matrix_.lduAddr().losortAddr();
149 // Get off-diagonal matrix coefficients
150 const scalarField& upper = matrix_.upper();
151 const scalarField& lower = matrix_.lower();
155 forAll (lower, coeffI)
157 losortCoeff = losortAddr[coeffI];
159 x[upperAddr[losortCoeff]] -=
160 preconDiag_[upperAddr[losortCoeff]]*
161 lower[losortCoeff]*x[lowerAddr[losortCoeff]];
164 forAllReverse (upper, coeffI)
166 x[lowerAddr[coeffI]] -=
167 preconDiag_[lowerAddr[coeffI]]*
168 upper[coeffI]*x[upperAddr[coeffI]];
174 void Foam::ILU0::preconditionT
177 const scalarField& b,
183 x[i] = b[i]*preconDiag_[i];
186 if (matrix_.asymmetric())
188 const unallocLabelList& upperAddr = matrix_.lduAddr().upperAddr();
189 const unallocLabelList& lowerAddr = matrix_.lduAddr().lowerAddr();
190 const unallocLabelList& losortAddr = matrix_.lduAddr().losortAddr();
192 // Get off-diagonal matrix coefficients
193 const scalarField& upper = matrix_.upper();
194 const scalarField& lower = matrix_.lower();
198 forAll (lower, coeffI)
200 // Transpose multiplication. HJ, 19/Jan/2009
201 x[upperAddr[coeffI]] -=
202 preconDiag_[upperAddr[coeffI]]*
203 upper[coeffI]*x[lowerAddr[coeffI]];
206 forAllReverse (upper, coeffI)
208 losortCoeff = losortAddr[coeffI];
210 // Transpose multiplication. HJ, 19/Jan/2009
211 x[lowerAddr[losortCoeff]] -=
212 preconDiag_[lowerAddr[losortCoeff]]*
213 lower[losortCoeff]*x[upperAddr[losortCoeff]];
219 // ************************************************************************* //