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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "DILUSmoother.H"
27 #include "DILUPreconditioner.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(DILUSmoother, 0);
35 lduSmoother::addasymMatrixConstructorToTable<DILUSmoother>
36 addDILUSmootherAsymMatrixConstructorToTable_;
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::DILUSmoother::DILUSmoother
44 const lduMatrix& matrix,
45 const FieldField<Field, scalar>& coupleBouCoeffs,
46 const FieldField<Field, scalar>& coupleIntCoeffs,
47 const lduInterfaceFieldPtrsList& interfaces
59 DILUPreconditioner::calcReciprocalD(rD_, matrix_);
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 void Foam::DILUSmoother::smooth
68 const scalarField& source,
73 const scalar* const __restrict__ rDPtr = rD_.begin();
75 const label* const __restrict__ uPtr =
76 matrix_.lduAddr().upperAddr().begin();
77 const label* const __restrict__ lPtr =
78 matrix_.lduAddr().lowerAddr().begin();
80 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
81 const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
83 // Temporary storage for the residual
84 scalarField rA(rD_.size());
85 scalar* __restrict__ rAPtr = rA.begin();
87 for (label sweep=0; sweep<nSweeps; sweep++)
101 register label nFaces = matrix_.upper().size();
102 for (register label face=0; face<nFaces; face++)
104 register label u = uPtr[face];
105 rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
108 register label nFacesM1 = nFaces - 1;
109 for (register label face=nFacesM1; face>=0; face--)
111 register label l = lPtr[face];
112 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
120 // ************************************************************************* //