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
25 \*---------------------------------------------------------------------------*/
27 #include "DILUSmoother.H"
28 #include "DILUPreconditioner.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(DILUSmoother, 0);
36 lduMatrix::smoother::addasymMatrixConstructorToTable<DILUSmoother>
37 addDILUSmootherAsymMatrixConstructorToTable_;
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 Foam::DILUSmoother::DILUSmoother
45 const word& fieldName,
46 const lduMatrix& matrix,
47 const FieldField<Field, scalar>& interfaceBouCoeffs,
48 const FieldField<Field, scalar>& interfaceIntCoeffs,
49 const lduInterfaceFieldPtrsList& interfaces
62 DILUPreconditioner::calcReciprocalD(rD_, matrix_);
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 void Foam::DILUSmoother::smooth
71 const scalarField& source,
76 const scalar* const __restrict__ rDPtr = rD_.begin();
78 const label* const __restrict__ uPtr =
79 matrix_.lduAddr().upperAddr().begin();
80 const label* const __restrict__ lPtr =
81 matrix_.lduAddr().lowerAddr().begin();
83 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
84 const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
86 // Temporary storage for the residual
87 scalarField rA(rD_.size());
88 scalar* __restrict__ rAPtr = rA.begin();
90 for (label sweep=0; sweep<nSweeps; sweep++)
104 register label nFaces = matrix_.upper().size();
105 for (register label face=0; face<nFaces; face++)
107 register label u = uPtr[face];
108 rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
111 register label nFacesM1 = nFaces - 1;
112 for (register label face=nFacesM1; face>=0; face--)
114 register label l = lPtr[face];
115 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
123 // ************************************************************************* //