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 "DICSmoother.H"
27 #include "DICPreconditioner.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(DICSmoother, 0);
35 lduSmoother::addsymMatrixConstructorToTable<DICSmoother>
36 addDICSmootherSymMatrixConstructorToTable_;
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::DICSmoother::DICSmoother
44 const lduMatrix& matrix,
45 const FieldField<Field, scalar>& coupleBouCoeffs,
46 const FieldField<Field, scalar>& coupleIntCoeffs,
47 const lduInterfaceFieldPtrsList& interfaces
59 DICPreconditioner::calcReciprocalD(rD_, matrix_);
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 void Foam::DICSmoother::smooth
73 const scalar* const __restrict__ rDPtr = rD_.begin();
74 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
75 const label* const __restrict__ uPtr =
76 matrix_.lduAddr().upperAddr().begin();
78 const label* const __restrict__ lPtr =
79 matrix_.lduAddr().lowerAddr().begin();
81 // Temporary storage for the residual
82 scalarField rA(rD_.size());
83 scalar* __restrict__ rAPtr = rA.begin();
85 for (label sweep=0; sweep<nSweeps; sweep++)
99 register label nFaces = matrix_.upper().size();
100 for (register label face=0; face<nFaces; face++)
102 register label u = uPtr[face];
103 rAPtr[u] -= rDPtr[u]*upperPtr[face]*rAPtr[lPtr[face]];
106 register label nFacesM1 = nFaces - 1;
107 for (register label face=nFacesM1; face>=0; face--)
109 register label l = lPtr[face];
110 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
118 // ************************************************************************* //