Loading...
Searching...
No Matches
distributedDILUPreconditioner.H
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) 2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::distributedDILUPreconditioner
28
29Group
30 grpLduMatrixPreconditioners
31
32Description
33 Version of DILUpreconditioner that uses preconditioning across processor
34 (and coupled) boundaries. Based on 'Parallel Preconditioners' chapter from
35 'Iterative Methods for Sparse Linear Systems' by Yousef Saad.
36
37 Leaves out the handling of boundary nodes after internal nodes since
38 probably not beneficial (so no overlap of comms and internal calculation)
39
40 By default preconditions across coupled boundaries (currently only
41 tested for cyclicAMI). This can be disabled with the 'coupled' setting
42
43 solver PCG;
44 preconditioner
45 {
46 preconditioner distributedDILU;
47 coupled false;
48 }
49
50 The cyclicAMI boundary behaviour will only work if
51 - running non-parallel or
52 - different sides of cyclicAMI run on different processors i.e.
53 there is no processor which has cells on both owner and neighbour
54 of the patch pair.
55
56See Also
57 Foam::DILUPreconditioner
58 Foam::distributedDICPreconditioner
59
60SourceFiles
61 distributedDILUPreconditioner.C
62
63\*---------------------------------------------------------------------------*/
64
65#ifndef Foam_distributedDILUPreconditioner_H
66#define Foam_distributedDILUPreconditioner_H
67
68#include "lduMatrix.H"
69
70// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71
72namespace Foam
73{
75/*---------------------------------------------------------------------------*\
76 Class distributedDILUPreconditioner Declaration
77\*---------------------------------------------------------------------------*/
78
80:
82{
83protected:
84
85 // Protected Data
86
87 //- Precondition across global coupled bc
88 const bool coupled_;
89
90
91 //- Processor interface buffers and colouring
92
93 //- Previous mesh
94 static const lduMesh* meshPtr_;
96 //- Previous processor colours
98
99 //- Buffers for sending and receiving data
103
104 //- Interfaces to lower coloured processors
108
109 //- Interfaces to higher coloured processors
115 //- Local (cell) colouring from global interfaces
116
117 //- Colour/zone per cell
120 //- Number of colours (in case of multiple disconnected regions
121 // in single mesh)
122 label nColours_;
123
124
125 //- Global interfaces. Per colour the interfaces that (might)
126 //- influence it
127
129
130 //- Interfaces to non-processor lower coupled interfaces
132
133 //- Interfaces to non-processor lower coupled interfaces
135
136 //- Corresponding destination colour (for lowerGlobal)
139 //- Interfaces to non-processor higher coupled interfaces
141
142 //- Interfaces to non-processor higher coupled interfaces
144
145 //- Corresponding destination colour (for higherGlobal)
147
148
149 //- The reciprocal preconditioned diagonal
152
153 // Private Member Functions
154
155 //- Variant of lduMatrix::updateMatrixInterfaces on selected interfaces
157 (
158 const bool add,
159 const FieldField<Field, scalar>& coupleCoeffs,
160 const labelList& selectedInterfaces,
161 const solveScalarField& psiif,
162 solveScalarField& result,
163 const direction cmpt
164 ) const;
165
166 //- Send (and store in colourBufs_[colouri]) the effect of
167 // doing selectedInterfaces
168 void sendGlobal
169 (
170 const labelList& selectedInterfaces,
172 const label colouri
173 ) const;
174
175 //- Start receiving in recvBufs_
177 (
178 const labelList& selectedInterfaces,
180 ) const;
181
182 //- Start sending sendBufs_
183 void send
184 (
185 const labelList& selectedInterfaces,
186 const solveScalarField& psiInternal,
188 ) const;
189
190 //- Wait for requests or cancel/free requests
191 void wait
192 (
194 const bool cancel = false
195 ) const;
196
197 //- Update diagonal for interface
198 virtual void addInterfaceDiag
199 (
201 const label inti,
202 const Field<solveScalar>& recvBuf
203 ) const;
204
205 //- Update diagonal for all faces of a certain colour
206 virtual void forwardInternalDiag
207 (
209 const label colouri
210 ) const;
211
212 //- Update preconditioned variable from interface
213 virtual void addInterface
214 (
216 const label inti,
217 const Field<solveScalar>& recvBuf
218 ) const;
219
220 //- Update preconditioned variable walking forward on internal faces
221 virtual void forwardInternal
222 (
224 const label colouri
225 ) const;
226
227 //- Update preconditioned variable walking backward on internal faces
228 virtual void backwardInternal
229 (
231 const label colouri
232 ) const;
233
234 //- Calculate reciprocal of diagonal
235 virtual void calcReciprocalD(solveScalarField& rD) const;
236
237
238public:
239
240 //- Runtime type information
241 TypeName("distributedDILU");
242
243
244 // Constructors
245
246 //- Construct from matrix components and preconditioner solver controls
248 (
249 const lduMatrix::solver&,
250 const dictionary& solverControlsUnused
251 );
252
253
254 //- Destructor
256
257
258 // Member Functions
259
260 //- Return wA the preconditioned form of residual rA
261 virtual void precondition
262 (
264 const solveScalarField& rA,
265 const direction cmpt=0
266 ) const;
267
268 //- Signal end of solver
269 virtual void setFinished(const solverPerformance& perf) const;
270};
271
272
273// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274
275} // End namespace Foam
276
277// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278
279#endif
280
281// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A field of fields is a PtrList of fields with reference counting.
Definition FieldField.H:77
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
virtual void addInterface(solveScalarField &wA, const label inti, const Field< solveScalar > &recvBuf) const
Update preconditioned variable from interface.
virtual void backwardInternal(solveScalarField &wA, const label colouri) const
Update preconditioned variable walking backward on internal faces.
void send(const labelList &selectedInterfaces, const solveScalarField &psiInternal, DynamicList< UPstream::Request > &requests) const
Start sending sendBufs_.
List< DynamicList< label > > higherGlobalSend_
Interfaces to non-processor higher coupled interfaces.
PtrList< FieldField< Field, solveScalar > > colourBufs_
Global interfaces. Per colour the interfaces that (might) influence it.
static autoPtr< labelList > procColoursPtr_
Previous processor colours.
virtual void setFinished(const solverPerformance &perf) const
Signal end of solver.
List< DynamicList< label > > lowerGlobalSend_
Interfaces to non-processor lower coupled interfaces.
const bool coupled_
Precondition across global coupled bc.
void updateMatrixInterfaces(const bool add, const FieldField< Field, scalar > &coupleCoeffs, const labelList &selectedInterfaces, const solveScalarField &psiif, solveScalarField &result, const direction cmpt) const
Variant of lduMatrix::updateMatrixInterfaces on selected interfaces.
autoPtr< labelList > cellColourPtr_
Local (cell) colouring from global interfaces.
DynamicList< label > lowerNbrs_
Interfaces to lower coloured processors.
List< DynamicList< label > > lowerGlobalRecv_
Interfaces to non-processor lower coupled interfaces.
virtual void forwardInternalDiag(solveScalarField &rD, const label colouri) const
Update diagonal for all faces of a certain colour.
label nColours_
Number of colours (in case of multiple disconnected regions.
virtual void precondition(solveScalarField &wA, const solveScalarField &rA, const direction cmpt=0) const
Return wA the preconditioned form of residual rA.
DynamicList< UPstream::Request > higherSendRequests_
TypeName("distributedDILU")
Runtime type information.
void sendGlobal(const labelList &selectedInterfaces, solveScalarField &psi, const label colouri) const
Send (and store in colourBufs_[colouri]) the effect of.
DynamicList< UPstream::Request > lowerSendRequests_
DynamicList< UPstream::Request > lowerRecvRequests_
List< label > lowerColour_
Corresponding destination colour (for lowerGlobal).
distributedDILUPreconditioner(const lduMatrix::solver &, const dictionary &solverControlsUnused)
Construct from matrix components and preconditioner solver controls.
void receive(const labelList &selectedInterfaces, DynamicList< UPstream::Request > &requests) const
Start receiving in recvBufs_.
virtual void addInterfaceDiag(solveScalarField &rD, const label inti, const Field< solveScalar > &recvBuf) const
Update diagonal for interface.
List< label > higherColour_
Corresponding destination colour (for higherGlobal).
DynamicList< label > higherNbrs_
Interfaces to higher coloured processors.
virtual void calcReciprocalD(solveScalarField &rD) const
Calculate reciprocal of diagonal.
static const lduMesh * meshPtr_
Processor interface buffers and colouring.
DynamicList< UPstream::Request > recvRequests_
virtual void forwardInternal(solveScalarField &wA, const label colouri) const
Update preconditioned variable walking forward on internal faces.
FieldField< Field, solveScalar > sendBufs_
Buffers for sending and receiving data.
solveScalarField rD_
The reciprocal preconditioned diagonal.
DynamicList< UPstream::Request > higherRecvRequests_
List< DynamicList< label > > higherGlobalRecv_
Interfaces to non-processor higher coupled interfaces.
void wait(DynamicList< UPstream::Request > &requests, const bool cancel=false) const
Wait for requests or cancel/free requests.
Abstract base-class for lduMatrix preconditioners.
Definition lduMatrix.H:578
Abstract base-class for lduMatrix solvers.
Definition lduMatrix.H:152
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition lduMesh.H:54
const volScalarField & psi
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
Field< solveScalar > solveScalarField
uint8_t direction
Definition direction.H:49
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68