Loading...
Searching...
No Matches
FDICSmoother.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "FDICSmoother.H"
31#include "PrecisionAdaptor.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
38
39 lduMatrix::smoother::addsymMatrixConstructorToTable<FDICSmoother>
41}
42
43
44// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45
47(
48 const word& fieldName,
49 const lduMatrix& matrix,
50 const FieldField<Field, scalar>& interfaceBouCoeffs,
51 const FieldField<Field, scalar>& interfaceIntCoeffs,
52 const lduInterfaceFieldPtrsList& interfaces,
53 const dictionary& solverControls
54)
55:
56 lduMatrix::smoother
57 (
58 fieldName,
59 matrix,
60 interfaceBouCoeffs,
61 interfaceIntCoeffs,
62 interfaces
63 ),
64 rD_(matrix_.diag().size()),
65 rDuUpper_(matrix_.upper().size()),
66 rDlUpper_(matrix_.upper().size())
67{
68 solveScalar* __restrict__ rDPtr = rD_.begin();
69 solveScalar* __restrict__ rDuUpperPtr = rDuUpper_.begin();
70 solveScalar* __restrict__ rDlUpperPtr = rDlUpper_.begin();
71
72 const label* const __restrict__ uPtr =
73 matrix_.lduAddr().upperAddr().begin();
74 const label* const __restrict__ lPtr =
75 matrix_.lduAddr().lowerAddr().begin();
76 const scalar* const __restrict__ upperPtr =
77 matrix_.upper().begin();
78
79 const label nFaces = matrix_.upper().size();
80
81 const scalarField& diag = matrix_.diag();
82 std::copy(diag.begin(), diag.end(), rD_.begin());
83
85
86 for (label face=0; face<nFaces; face++)
87 {
88 rDuUpperPtr[face] = rDPtr[uPtr[face]]*upperPtr[face];
89 rDlUpperPtr[face] = rDPtr[lPtr[face]]*upperPtr[face];
90 }
91}
92
93
94// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95
97(
99 const scalarField& source,
100 const direction cmpt,
101 const label nSweeps
102) const
103{
104 const solveScalar* const __restrict__ rDuUpperPtr = rDuUpper_.begin();
105 const solveScalar* const __restrict__ rDlUpperPtr = rDlUpper_.begin();
106
107 const label* const __restrict__ uPtr =
108 matrix_.lduAddr().upperAddr().begin();
109 const label* const __restrict__ lPtr =
110 matrix_.lduAddr().lowerAddr().begin();
111
112 // Temporary storage for the residual
113 solveScalarField rA(rD_.size());
114 solveScalar* __restrict__ rAPtr = rA.begin();
115
116 for (label sweep=0; sweep<nSweeps; sweep++)
117 {
118 matrix_.residual
119 (
120 rA,
121 psi,
122 source,
123 interfaceBouCoeffs_,
124 interfaces_,
125 cmpt
126 );
127
128 forAll(rA, i)
129 {
130 rA[i] *= rD_[i];
131 }
132
133 const label nFaces = matrix_.upper().size();
134 for (label face=0; face<nFaces; face++)
135 {
136 rAPtr[uPtr[face]] -= rDuUpperPtr[face]*rAPtr[lPtr[face]];
137 }
138
139 const label nFacesM1 = nFaces - 1;
140 for (label face=nFacesM1; face>=0; face--)
141 {
142 rAPtr[lPtr[face]] -= rDlUpperPtr[face]*rAPtr[uPtr[face]];
144
145 psi += rA;
146 }
147}
148
149
151(
153 const solveScalarField& source,
154 const direction cmpt,
155 const label nSweeps
156) const
157{
158 smooth
159 (
160 psi,
162 cmpt,
163 nSweeps
164 );
165}
166
167
168// ************************************************************************* //
A const Field/List wrapper with possible data conversion.
static void calcReciprocalD(solveScalarField &, const lduMatrix &)
Calculate the reciprocal of the preconditioned diagonal.
Simplified diagonal-based incomplete Cholesky smoother for symmetric matrices.
void smooth(solveScalarField &psi, const scalarField &source, const direction cmpt, const label nSweeps) const
Smooth the solution for a given number of sweeps.
FDICSmoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Construct from matrix components.
virtual void scalarSmooth(solveScalarField &psi, const solveScalarField &source, const direction cmpt, const label nSweeps) const
Smooth the solution for a given number of sweeps.
A field of fields is a PtrList of fields with reference counting.
Definition FieldField.H:77
iterator begin() noexcept
Return an iterator to begin traversing the UList.
Definition UListI.H:410
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition lduMatrix.H:538
const lduMatrix & matrix_
Definition lduMatrix.H:416
const lduInterfaceFieldPtrsList & interfaces_
Definition lduMatrix.H:419
smoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces)
Construct for given field name, matrix etc.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition lduMatrix.H:543
const FieldField< Field, scalar > & interfaceBouCoeffs_
Definition lduMatrix.H:417
const lduMatrix & matrix() const noexcept
Definition lduMatrix.H:528
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition lduMatrix.H:533
const word & fieldName() const noexcept
Definition lduMatrix.H:523
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition lduMatrix.H:81
const lduAddressing & lduAddr() const
Return the LDU addressing.
Definition lduMatrix.H:769
const scalarField & diag() const
Definition lduMatrix.C:195
const scalarField & upper() const
Definition lduMatrix.C:235
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
const volScalarField & psi
void smooth(volScalarField &field, const scalar coeff)
Definition fvcSmooth.C:37
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< solveScalar > solveScalarField
uint8_t direction
Definition direction.H:49
lduMatrix::smoother::addsymMatrixConstructorToTable< FDICSmoother > addFDICSmootherSymMatrixConstructorToTable_
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299