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(FatalIOError);
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 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 
209 template<class Type>
211 (
212  solveScalarField& result,
213  const bool add,
214  const solveScalarField&,
215  const scalarField& coeffs,
216  const direction cmpt,
217  const Pstream::commsTypes commsType
218 ) const
219 {
220  solveScalarField pnf
221  (
222  procPatch_.receive<solveScalar>(commsType, this->size())()
223  );
224 
225  // Transform according to the transformation tensor
226  transformCoupleField(pnf, cmpt);
227 
228  // Multiply the field by coefficients and add into the result
229 
230  const labelUList& edgeFaces = this->patch().edgeFaces();
231 
232  if (add)
233  {
234  forAll(edgeFaces, elemI)
235  {
236  result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI];
237  }
238  }
239  else
240  {
241  forAll(edgeFaces, elemI)
242  {
243  result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI];
244  }
245  }
246 }
247 
248 
249 template<class Type>
251 (
252  Field<Type>& result,
253  const bool add,
254  const Field<Type>& psiInternal,
255  const scalarField& coeffs,
256  const Pstream::commsTypes commsType
257 ) const
258 {
259  procPatch_.send
260  (
261  commsType,
262  this->patch().patchInternalField(psiInternal)()
263  );
264 }
265 
266 
267 template<class Type>
269 (
270  Field<Type>& result,
271  const bool add,
272  const Field<Type>&,
273  const scalarField& coeffs,
274  const Pstream::commsTypes commsType
275 ) const
276 {
277  Field<Type> pnf
278  (
279  procPatch_.receive<Type>(commsType, this->size())()
280  );
281 
282  // Multiply the field by coefficients and add into the result
283 
284  const labelUList& edgeFaces = this->patch().edgeFaces();
285 
286  if (add)
287  {
288  forAll(edgeFaces, elemI)
289  {
290  result[edgeFaces[elemI]] += coeffs[elemI]*pnf[elemI];
291  }
292  }
293  else
294  {
295  forAll(edgeFaces, elemI)
296  {
297  result[edgeFaces[elemI]] -= coeffs[elemI]*pnf[elemI];
298  }
299  }
300 }
301 
302 
303 // ************************************************************************* //
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::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:519
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::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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::processorFaPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: processorFaPatchField.C:211
Foam::processorFaPatchField::initInterfaceMatrixUpdate
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
Definition: processorFaPatchField.C:192
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::coupledFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: coupledFaPatchField.H:57
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
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:401
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:68
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