Loading...
Searching...
No Matches
DILUSmoother.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 "DILUSmoother.H"
30#include "DILUPreconditioner.H"
32#include <algorithm>
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
39
40 lduMatrix::smoother::addasymMatrixConstructorToTable<DILUSmoother>
42}
43
44
45// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46
48(
49 const word& fieldName,
50 const lduMatrix& matrix,
51 const FieldField<Field, scalar>& interfaceBouCoeffs,
52 const FieldField<Field, scalar>& interfaceIntCoeffs,
53 const lduInterfaceFieldPtrsList& interfaces,
54 const dictionary& solverControls
55)
56:
57 lduMatrix::smoother
58 (
59 fieldName,
60 matrix,
61 interfaceBouCoeffs,
62 interfaceIntCoeffs,
63 interfaces
64 ),
65 rD_(matrix_.diag().size())
66{
67 const scalarField& diag = matrix_.diag();
68 std::copy(diag.begin(), diag.end(), rD_.begin());
71}
72
73
74// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75
77(
79 const scalarField& source,
80 const direction cmpt,
81 const label nSweeps
82) const
83{
84 const solveScalar* const __restrict__ rDPtr = rD_.begin();
85
86 const label* const __restrict__ uPtr =
87 matrix_.lduAddr().upperAddr().begin();
88 const label* const __restrict__ lPtr =
89 matrix_.lduAddr().lowerAddr().begin();
90
91 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
92 const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
93
94 // Temporary storage for the residual
95 solveScalarField rA(rD_.size());
96 solveScalar* __restrict__ rAPtr = rA.begin();
97
98 for (label sweep=0; sweep<nSweeps; sweep++)
99 {
100 matrix_.residual
101 (
102 rA,
103 psi,
104 source,
105 interfaceBouCoeffs_,
106 interfaces_,
107 cmpt
108 );
109
110 forAll(rA, i)
111 {
112 rA[i] *= rD_[i];
113 }
114
115 const label nFaces = matrix_.upper().size();
116 for (label face=0; face<nFaces; face++)
117 {
118 const label u = uPtr[face];
119 rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
120 }
121
122 const label nFacesM1 = nFaces - 1;
123 for (label face=nFacesM1; face>=0; face--)
124 {
125 const label l = lPtr[face];
126 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
128
129 psi += rA;
130 }
131}
132
133
135(
137 const solveScalarField& source,
138 const direction cmpt,
139 const label nSweeps
140) const
141{
142 smooth
143 (
144 psi,
146 cmpt,
147 nSweeps
148 );
149}
150
151
152// ************************************************************************* //
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 LU smoother for asymmetric matrices.
void smooth(solveScalarField &psi, const scalarField &source, const direction cmpt, const label nSweeps) const
Smooth the solution for a given number of sweeps.
DILUSmoother(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.
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 scalarField & diag() const
Definition lduMatrix.C:195
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
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
lduMatrix::smoother::addasymMatrixConstructorToTable< DILUSmoother > addDILUSmootherAsymMatrixConstructorToTable_
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299