DILUSmoother.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "DILUSmoother.H"
27 #include "DILUPreconditioner.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(DILUSmoother, 0);
34 
35  lduMatrix::smoother::addasymMatrixConstructorToTable<DILUSmoother>
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  const word& fieldName,
45  const lduMatrix& matrix,
46  const FieldField<Field, scalar>& interfaceBouCoeffs,
47  const FieldField<Field, scalar>& interfaceIntCoeffs,
48  const lduInterfaceFieldPtrsList& interfaces
49 )
50 :
52  (
53  fieldName,
54  matrix,
55  interfaceBouCoeffs,
56  interfaceIntCoeffs,
57  interfaces
58  ),
59  rD_(matrix_.diag())
60 {
62 }
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
68 (
69  scalarField& psi,
70  const scalarField& source,
71  const direction cmpt,
72  const label nSweeps
73 ) const
74 {
75  const scalar* const __restrict__ rDPtr = rD_.begin();
76 
77  const label* const __restrict__ uPtr =
78  matrix_.lduAddr().upperAddr().begin();
79  const label* const __restrict__ lPtr =
80  matrix_.lduAddr().lowerAddr().begin();
81 
82  const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
83  const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
84 
85  // Temporary storage for the residual
86  scalarField rA(rD_.size());
87  scalar* __restrict__ rAPtr = rA.begin();
88 
89  for (label sweep=0; sweep<nSweeps; sweep++)
90  {
91  matrix_.residual
92  (
93  rA,
94  psi,
95  source,
96  interfaceBouCoeffs_,
97  interfaces_,
98  cmpt
99  );
100 
101  rA *= rD_;
102 
103  label nFaces = matrix_.upper().size();
104  for (label face=0; face<nFaces; face++)
105  {
106  label u = uPtr[face];
107  rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
108  }
109 
110  label nFacesM1 = nFaces - 1;
111  for (label face=nFacesM1; face>=0; face--)
112  {
113  label l = lPtr[face];
114  rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
115  }
116 
117  psi += rA;
118  }
119 }
120 
121 
122 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
DILUSmoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces)
Construct from matrix components.
Definition: DILUSmoother.C:43
uint8_t direction
Definition: direction.H:45
Generic field type.
Definition: FieldField.H:51
void sweep(volScalarField &field, const volScalarField &alpha, const label nLayers, const scalar alphaDiff=0.2)
Definition: fvcSmooth.C:222
Abstract base-class for lduMatrix smoothers.
Definition: lduMatrix.H:270
A class for handling words, derived from string.
Definition: word.H:59
iterator begin()
Return an iterator to begin traversing the UList.
Definition: UListI.H:216
defineTypeNameAndDebug(combustionModel, 0)
lduMatrix::smoother::addasymMatrixConstructorToTable< DILUSmoother > addDILUSmootherAsymMatrixConstructorToTable_
Definition: DILUSmoother.C:36
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: lduMatrix.H:79
void smooth(scalarField &psi, const scalarField &source, const direction cmpt, const label nSweeps) const
Smooth the solution for a given number of sweeps.
Definition: DILUSmoother.C:68
static void calcReciprocalD(scalarField &rD, const lduMatrix &matrix)
Calculate the reciprocal of the preconditioned diagonal.
Namespace for OpenFOAM.