processorFaPatchField.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) 2016-2017 Wikki Ltd
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
30#include "processorFaPatch.H"
31#include "transformField.H"
32
33// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34
35template<class Type>
37(
38 const faPatch& p,
40)
41:
42 coupledFaPatchField<Type>(p, iF),
43 procPatch_(refCast<const processorFaPatch>(p))
44{}
45
46
47template<class Type>
49(
50 const faPatch& p,
52 const Field<Type>& f
53)
54:
55 coupledFaPatchField<Type>(p, iF, f),
56 procPatch_(refCast<const processorFaPatch>(p))
57{}
58
59
60template<class Type>
62(
64 const faPatch& p,
66 const faPatchFieldMapper& mapper
67)
68:
69 coupledFaPatchField<Type>(ptf, p, iF, mapper),
70 procPatch_(refCast<const processorFaPatch>(p))
71{
72 if (!isType<processorFaPatch>(this->patch()))
73 {
75 << "\n patch type '" << p.type()
76 << "' not constraint type '" << typeName << "'"
77 << "\n for patch " << p.name()
78 << " of field " << this->internalField().name()
79 << " in file " << this->internalField().objectPath()
80 << exit(FatalError);
81 }
82}
83
84
85template<class Type>
87(
88 const faPatch& p,
90 const dictionary& dict
91)
92:
93 coupledFaPatchField<Type>(p, iF, dict),
94 procPatch_(refCast<const processorFaPatch>(p, dict))
95{
96 if (!isType<processorFaPatch>(p))
97 {
99 << "\n patch type '" << p.type()
100 << "' not constraint type '" << typeName << "'"
101 << "\n for patch " << p.name()
102 << " of field " << this->internalField().name()
103 << " in file " << this->internalField().objectPath()
104 << exit(FatalIOError);
105 }
106}
107
108
109template<class Type>
111(
113)
114:
116 coupledFaPatchField<Type>(ptf),
117 procPatch_(refCast<const processorFaPatch>(ptf.patch()))
118{}
119
120
121template<class Type>
123(
126)
127:
128 coupledFaPatchField<Type>(ptf, iF),
129 procPatch_(refCast<const processorFaPatch>(ptf.patch()))
130{}
131
132
133// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
134
135template<class Type>
137{}
138
139
140// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141
142template<class Type>
145{
146 return *this;
147}
148
149
150template<class Type>
152(
153 const Pstream::commsTypes commsType
154)
155{
156 if (Pstream::parRun())
157 {
158 procPatch_.send(commsType, this->patchInternalField()());
159 }
160}
161
162
163template<class Type>
165(
166 const Pstream::commsTypes commsType
167)
168{
169 if (Pstream::parRun())
170 {
171 procPatch_.receive<Type>(commsType, *this);
172
173 if (doTransform())
174 {
175 transform(*this, procPatch_.forwardT(), *this);
176 }
177 }
178}
179
180
181template<class Type>
183{
184 return this->patch().deltaCoeffs()*(*this - this->patchInternalField());
185}
186
187
188template<class Type>
190(
191 solveScalarField& result,
192 const bool add,
193 const lduAddressing& lduAddr,
194 const label patchId,
195 const solveScalarField& psiInternal,
196 const scalarField& coeffs,
197 const direction,
198 const Pstream::commsTypes commsType
199) const
200{
201 procPatch_.send
202 (
203 commsType,
204 this->patch().patchInternalField(psiInternal)()
205 );
206}
207
208
209template<class Type>
211(
212 solveScalarField& result,
213 const bool add,
214 const lduAddressing& lduAddr,
215 const label patchId,
216 const solveScalarField&,
217 const scalarField& coeffs,
218 const direction cmpt,
219 const Pstream::commsTypes commsType
220) const
221{
223 (
224 procPatch_.receive<solveScalar>(commsType, this->size())()
225 );
226
227 // Transform according to the transformation tensor
228 transformCoupleField(pnf, cmpt);
229
230 // Multiply the field by coefficients and add into the result
231
232 const labelUList& edgeFaces = this->patch().edgeFaces();
233
234 if (add)
235 {
236 forAll(edgeFaces, elemI)
237 {
238 result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI];
239 }
240 }
241 else
242 {
243 forAll(edgeFaces, elemI)
244 {
245 result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI];
246 }
247 }
248}
249
250
251template<class Type>
253(
254 Field<Type>& result,
255 const bool add,
256 const lduAddressing& lduAddr,
257 const label patchId,
258 const Field<Type>& psiInternal,
259 const scalarField& coeffs,
260 const Pstream::commsTypes commsType
261) const
262{
263 procPatch_.send
264 (
265 commsType,
266 this->patch().patchInternalField(psiInternal)()
267 );
268}
269
270
271template<class Type>
273(
274 Field<Type>& result,
275 const bool add,
276 const lduAddressing& lduAddr,
277 const label patchId,
278 const Field<Type>&,
279 const scalarField& coeffs,
280 const Pstream::commsTypes commsType
281) const
282{
283 Field<Type> pnf
284 (
285 procPatch_.receive<Type>(commsType, this->size())()
286 );
287
288 // Multiply the field by coefficients and add into the result
289
290 const labelUList& edgeFaces = this->patch().edgeFaces();
291
292 if (add)
293 {
294 forAll(edgeFaces, elemI)
295 {
296 result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI];
297 }
298 }
299 else
300 {
301 forAll(edgeFaces, elemI)
302 {
303 result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI];
304 }
305 }
306}
307
308
309// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static const char *const typeName
Typename for Field.
Definition: FieldBase.H:59
Generic templated field type.
Definition: Field.H:82
void evaluate()
Evaluate boundary conditions.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
commsTypes
Types of communications.
Definition: UPstream.H:67
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-area patch fields.
const faPatch & patch() const
Return patch.
Definition: faPatchField.H:286
const DimensionedField< Type, areaMesh > & internalField() const
Return dimensioned internal field reference.
Definition: faPatchField.H:292
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
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.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
Abstract base class for processor coupled interfaces.
A class for managing temporary objects.
Definition: tmp.H:65
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
label patchId(-1)
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
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
IOerror FatalIOError
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
labelList f(nPoints)
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Spatial transformation functions for primitive fields.