1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "DILUSmoother.H"
27 #include "DILUPreconditioner.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(DILUSmoother, 0);
35 lduMatrix::smoother::addasymMatrixConstructorToTable<DILUSmoother>
36 addDILUSmootherAsymMatrixConstructorToTable_;
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::DILUSmoother::DILUSmoother
44 const word& fieldName,
45 const lduMatrix& matrix,
46 const FieldField<Field, scalar>& interfaceBouCoeffs,
47 const FieldField<Field, scalar>& interfaceIntCoeffs,
48 const lduInterfaceFieldPtrsList& interfaces
61 DILUPreconditioner::calcReciprocalD(rD_, matrix_);
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 void Foam::DILUSmoother::smooth
70 const scalarField& source,
75 const scalar* const __restrict__ rDPtr = rD_.begin();
77 const label* const __restrict__ uPtr =
78 matrix_.lduAddr().upperAddr().begin();
79 const label* const __restrict__ lPtr =
80 matrix_.lduAddr().lowerAddr().begin();
82 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
83 const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
85 // Temporary storage for the residual
86 scalarField rA(rD_.size());
87 scalar* __restrict__ rAPtr = rA.begin();
89 for (label sweep=0; sweep<nSweeps; sweep++)
103 register label nFaces = matrix_.upper().size();
104 for (register label face=0; face<nFaces; face++)
106 register label u = uPtr[face];
107 rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
110 register label nFacesM1 = nFaces - 1;
111 for (register label face=nFacesM1; face>=0; face--)
113 register label l = lPtr[face];
114 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
122 // ************************************************************************* //