Loading...
Searching...
No Matches
distributedDICPreconditioner.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) 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
26\*---------------------------------------------------------------------------*/
29
30// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32namespace Foam
33{
35
36 lduMatrix::preconditioner::
37 addsymMatrixConstructorToTable<distributedDICPreconditioner>
39}
40
41
42// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43
45(
47 const label colouri
48) const
49{
50 // Add forward constributions to diagonal
51
52 const auto& matrix = solver_.matrix();
53 const auto& lduAddr = matrix.lduAddr();
54
55 const label* const __restrict__ uPtr = lduAddr.upperAddr().begin();
56 const label* const __restrict__ lPtr = lduAddr.lowerAddr().begin();
57 const scalar* const __restrict__ upperPtr = matrix.upper().begin();
58
59 const label nFaces = matrix.upper().size();
61 {
62 const auto& cellColour = *cellColourPtr_;
63 for (label face=0; face<nFaces; face++)
64 {
65 const label cell = lPtr[face];
66 if (cellColour[cell] == colouri)
67 {
68 rD[uPtr[face]] -= upperPtr[face]*upperPtr[face]/rD[cell];
69 }
70 }
71 }
72 else
73 {
74 for (label face=0; face<nFaces; face++)
75 {
76 rD[uPtr[face]] -= upperPtr[face]*upperPtr[face]/rD[lPtr[face]];
77 }
78 }
79}
80
81
83(
85 const label colouri
86) const
87{
88 const auto& matrix = solver_.matrix();
89 const auto& lduAddr = matrix.lduAddr();
90
91 solveScalar* __restrict__ wAPtr = wA.begin();
92 const solveScalar* __restrict__ rDPtr = rD_.begin();
93
94 const label* const __restrict__ uPtr = lduAddr.upperAddr().begin();
95 const label* const __restrict__ lPtr = lduAddr.lowerAddr().begin();
96 const scalar* const __restrict__ upperPtr = matrix.upper().begin();
97
98 const label nFaces = matrix.upper().size();
99 if (cellColourPtr_)
100 {
101 const auto& cellColour = *cellColourPtr_;
102 for (label face=0; face<nFaces; face++)
103 {
104 const label cell = lPtr[face];
105 if (cellColour[cell] == colouri)
106 {
107 wAPtr[uPtr[face]] -=
108 rDPtr[uPtr[face]]*upperPtr[face]*wAPtr[cell];
109 }
110 }
111 }
112 else
113 {
114 for (label face=0; face<nFaces; face++)
115 {
116 wAPtr[uPtr[face]] -=
117 rDPtr[uPtr[face]]*upperPtr[face]*wAPtr[lPtr[face]];
119 }
120}
121
122
123// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
124
126(
127 const lduMatrix::solver& sol,
128 const dictionary& dict
129)
130:
132{}
133
134
135// ************************************************************************* //
iterator begin() noexcept
Return an iterator to begin traversing the UList.
Definition UListI.H:410
A cell is defined as a list of faces with extra functionality.
Definition cell.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Version of DICpreconditioner that uses preconditioning across processor (and coupled) boundaries....
distributedDICPreconditioner(const lduMatrix::solver &, const dictionary &solverControlsUnused)
Construct from matrix components and preconditioner solver controls.
virtual void forwardInternalDiag(solveScalarField &rD, const label colouri) const
Update diagonal for colour.
virtual void forwardInternal(solveScalarField &wA, const label colouri) const
Update preconditioned variable walking forward on internal faces.
Version of DILUpreconditioner that uses preconditioning across processor (and coupled) boundaries....
autoPtr< labelList > cellColourPtr_
Local (cell) colouring from global interfaces.
distributedDILUPreconditioner(const lduMatrix::solver &, const dictionary &solverControlsUnused)
Construct from matrix components and preconditioner solver controls.
solveScalarField rD_
The reciprocal preconditioned diagonal.
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
virtual const labelUList & upperAddr() const =0
Return upper addressing.
const solver & solver_
Reference to the base-solver this preconditioner is used with.
Definition lduMatrix.H:586
Abstract base-class for lduMatrix solvers.
Definition lduMatrix.H:152
const lduMatrix & matrix() const noexcept
Definition lduMatrix.H:328
const lduAddressing & lduAddr() const
Return the LDU addressing.
Definition lduMatrix.H:769
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
Namespace for OpenFOAM.
lduMatrix::preconditioner::addsymMatrixConstructorToTable< distributedDICPreconditioner > adddistributedDICPreconditionerSymMatrixConstructorToTable_
Field< solveScalar > solveScalarField
dictionary dict