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