calculatedProcessorGAMGInterfaceField.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) 2019-2021 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\*---------------------------------------------------------------------------*/
27
30#include "lduMatrix.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38 (
42 );
44 (
48 );
49}
50
51
52// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53
54Foam::calculatedProcessorGAMGInterfaceField::
55calculatedProcessorGAMGInterfaceField
56(
57 const GAMGInterface& GAMGCp,
58 const lduInterfaceField& fineInterface
59)
60:
61 GAMGInterfaceField(GAMGCp, fineInterface),
62 procInterface_(refCast<const calculatedProcessorGAMGInterface>(GAMGCp)),
63 doTransform_(false),
64 rank_(0)
65{
67 refCast<const processorLduInterfaceField>(fineInterface);
68
69 doTransform_ = p.doTransform();
70 rank_ = p.rank();
71}
72
73
74Foam::calculatedProcessorGAMGInterfaceField::
75calculatedProcessorGAMGInterfaceField
76(
77 const GAMGInterface& GAMGCp,
78 const bool doTransform,
79 const int rank
80)
81:
82 GAMGInterfaceField(GAMGCp, doTransform, rank),
83 procInterface_(refCast<const calculatedProcessorGAMGInterface>(GAMGCp)),
84 doTransform_(doTransform),
85 rank_(rank)
86{}
87
88
89// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90
92(
94 const bool add,
95 const lduAddressing& lduAddr,
96 const label patchId,
97 const solveScalarField& psiInternal,
98 const scalarField&,
99 const direction,
100 const Pstream::commsTypes commsType
101) const
102{
103 procInterface_.interfaceInternalField(psiInternal, scalarSendBuf_);
104
105 if
106 (
109 )
110 {
111 // Fast path.
112 scalarReceiveBuf_.setSize(scalarSendBuf_.size());
113 outstandingRecvRequest_ = UPstream::nRequests();
115 (
117 procInterface_.neighbProcNo(),
118 scalarReceiveBuf_.data_bytes(),
119 scalarReceiveBuf_.size_bytes(),
120 procInterface_.tag(),
121 comm()
122 );
123
124 outstandingSendRequest_ = UPstream::nRequests();
126 (
128 procInterface_.neighbProcNo(),
129 scalarSendBuf_.cdata_bytes(),
130 scalarSendBuf_.size_bytes(),
131 procInterface_.tag(),
132 comm()
133 );
134 }
135 else
136 {
137 procInterface_.compressedSend(commsType, scalarSendBuf_);
138 }
139
141 = false;
142}
143
144
146(
147 solveScalarField& result,
148 const bool add,
149 const lduAddressing& lduAddr,
150 const label patchId,
151 const solveScalarField&,
152 const scalarField& coeffs,
153 const direction cmpt,
154 const Pstream::commsTypes commsType
155) const
156{
157 if (updatedMatrix())
158 {
159 return;
160 }
161
162 const labelUList& faceCells = lduAddr.patchAddr(patchId);
163
164 if
165 (
168 )
169 {
170 // Fast path.
171 if
172 (
173 outstandingRecvRequest_ >= 0
174 && outstandingRecvRequest_ < Pstream::nRequests()
175 )
176 {
177 UPstream::waitRequest(outstandingRecvRequest_);
178 }
179 // Recv finished so assume sending finished as well.
180 outstandingSendRequest_ = -1;
181 outstandingRecvRequest_ = -1;
182
183 // Consume straight from scalarReceiveBuf_
184
185 // Transform according to the transformation tensor
186 transformCoupleField(scalarReceiveBuf_, cmpt);
187
188 // Multiply the field by coefficients and add into the result
189 addToInternalField(result, !add, faceCells, coeffs, scalarReceiveBuf_);
190 }
191 else
192 {
194 (
195 procInterface_.compressedReceive<solveScalar>
196 (
197 commsType,
198 this->size()
199 )()
200 );
201 transformCoupleField(pnf, cmpt);
202
203 addToInternalField(result, !add, faceCells, coeffs, pnf);
204 }
205
207 = true;
208}
209
210
211// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Abstract base class for GAMG agglomerated interface fields.
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:57
virtual bool read()
Re-read model coefficients if they have changed.
commsTypes
Types of communications.
Definition: UPstream.H:67
@ nonBlocking
"nonBlocking"
static bool floatTransfer
Definition: UPstream.H:275
static label nRequests()
Get number of outstanding requests.
Definition: UPstream.C:90
static void waitRequest(const label i)
Wait until request i has finished.
Definition: UPstream.C:104
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
GAMG agglomerated processor interface.
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
virtual bool write()
Write the output fields.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
bool updatedMatrix() const
Whether matrix has been updated.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:58
Abstract base class for processor coupled interfaces.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
label patchId(-1)
Namespace for OpenFOAM.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
uint8_t direction
Definition: direction.H:56