processorFaPatchField.H
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 Class
28  Foam::processorFaPatchField
29 
30 Description
31 
32 Author
33  Zeljko Tukovic, FMENA
34  Hrvoje Jasak, Wikki Ltd.
35 
36 SourceFiles
37  processorFaPatchField.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef processorFaPatchField_H
42 #define processorFaPatchField_H
43 
44 #include "coupledFaPatchField.H"
46 #include "processorFaPatch.H"
47 #include "areaFaMesh.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class processorFaPatchField Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type>
60 :
62  public coupledFaPatchField<Type>
63 {
64  // Private data
65 
66  //- Local reference cast into the processor patch
67  const processorFaPatch& procPatch_;
68 
69 
70 public:
71 
72  //- Runtime type information
73  TypeName(processorFaPatch::typeName_());
74 
75 
76  // Constructors
77 
78  //- Construct from patch and internal field
80  (
81  const faPatch&,
83  );
84 
85  //- Construct from patch and internal field and patch field
87  (
88  const faPatch&,
90  const Field<Type>&
91  );
92 
93  //- Construct from patch, internal field and dictionary
95  (
96  const faPatch&,
98  const dictionary&
99  );
100 
101  //- Construct by mapping given processorFaPatchField onto a new patch
103  (
105  const faPatch&,
107  const faPatchFieldMapper&
108  );
109 
110  //- Construct as copy
112 
113  //- Construct and return a clone
114  virtual tmp<faPatchField<Type>> clone() const
115  {
116  return tmp<faPatchField<Type>>
117  (
118  new processorFaPatchField<Type>(*this)
119  );
120  }
121 
122  //- Construct as copy setting internal field reference
124  (
127  );
128 
129  //- Construct and return a clone setting internal field reference
131  (
133  ) const
134  {
135  return tmp<faPatchField<Type>>
136  (
137  new processorFaPatchField<Type>(*this, iF)
138  );
139  }
140 
141 
142  // Destructor
143 
145 
146 
147  // Member functions
148 
149  // Access
150 
151  //- Return true if running parallel
152  virtual bool coupled() const
153  {
154  if (Pstream::parRun())
155  {
156  return true;
157  }
158  else
159  {
160  return false;
161  }
162  }
163 
164  //- Return neighbour field given internal field
166 
167 
168  // Evaluation functions
169 
170  //- Initialise the evaluation of the patch field
171  virtual void initEvaluate(const Pstream::commsTypes commsType);
172 
173  //- Evaluate the patch field
174  virtual void evaluate(const Pstream::commsTypes commsType);
175 
176  //- Return patch-normal gradient
177  virtual tmp<Field<Type>> snGrad() const;
178 
179  // Coupled interface functionality
180 
181  //- Transform neighbour field
182  virtual void transformCoupleField
183  (
185  const direction cmpt
186  ) const
187  {
189  }
190 
191  //- Initialise neighbour matrix update
192  virtual void initInterfaceMatrixUpdate
193  (
194  solveScalarField& result,
195  const bool add,
196  const lduAddressing& lduAddr,
197  const label patchId,
198  const solveScalarField& psiInternal,
199  const scalarField& coeffs,
200  const direction cmpt,
201  const Pstream::commsTypes commsType
202  ) const;
203 
204  //- Update result field based on interface functionality
205  virtual void updateInterfaceMatrix
206  (
207  solveScalarField& result,
208  const bool add,
209  const lduAddressing& lduAddr,
210  const label patchId,
211  const solveScalarField& psiInternal,
212  const scalarField& coeffs,
213  const direction cmpt,
214  const Pstream::commsTypes commsType
215  ) const;
216 
217  //- Initialise neighbour matrix update
218  virtual void initInterfaceMatrixUpdate
219  (
220  Field<Type>& result,
221  const bool add,
222  const lduAddressing& lduAddr,
223  const label patchId,
224  const Field<Type>&,
225  const scalarField& coeffs,
226  const Pstream::commsTypes commsType
227  ) const;
228 
229  //- Update result field based on interface functionality
230  virtual void updateInterfaceMatrix
231  (
232  Field<Type>& result,
233  const bool add,
234  const lduAddressing& lduAddr,
235  const label patchId,
236  const Field<Type>&,
237  const scalarField& coeffs,
238  const Pstream::commsTypes commsType
239  ) const;
240 
241  //- Processor coupled interface functions
242 
243  //- Return communicator used for comms
244  virtual label comm() const
245  {
246  return UPstream::worldComm;
247  }
248 
249  //- Return processor number
250  virtual int myProcNo() const
251  {
252  return procPatch_.myProcNo();
253  }
254 
255  //- Return neighbour processor number
256  virtual int neighbProcNo() const
257  {
258  return procPatch_.neighbProcNo();
259  }
260 
261  //- Does the patch field perform the transformation
262  virtual bool doTransform() const
263  {
264  return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
265  }
266 
267  //- Return face transformation tensor
268  virtual const tensorField& forwardT() const
269  {
270  return procPatch_.forwardT();
271  }
272 
273  //- Return rank of component for transform
274  virtual int rank() const
275  {
276  return pTraits<Type>::rank;
277  }
278 };
279 
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 } // End namespace Foam
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #ifdef NoRepository
288  #include "processorFaPatchField.C"
289 #endif
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #endif
294 
295 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::processorFaPatchField::coupled
virtual bool coupled() const
Return true if running parallel.
Definition: processorFaPatchField.H:151
Foam::processorFaPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFaPatch.H:219
Foam::processorLduInterfaceField::transformCoupleField
void transformCoupleField(Field< Type > &f) const
Transform given patch field.
Definition: processorLduInterfaceField.H:117
Foam::processorFaPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: processorFaPatchField.C:184
Foam::coupledFaPatch::parallel
bool parallel() const
Are the cyclic planes parallel.
Definition: coupledFaPatch.H:198
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
Foam::processorFaPatchField::comm
virtual label comm() const
Processor coupled interface functions.
Definition: processorFaPatchField.H:243
Foam::processorFaPatchField::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: processorFaPatchField.H:249
processorFaPatch.H
Foam::processorFaPatchField::processorFaPatchField
processorFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: processorFaPatchField.C:39
processorLduInterfaceField.H
Foam::processorFaPatch::neighbProcNo
int neighbProcNo() const noexcept
Return neighbour processor number.
Definition: processorFaPatch.H:191
Foam::processorFaPatchField::TypeName
TypeName(processorFaPatch::typeName_())
Runtime type information.
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::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
Foam::processorFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: processorFaPatchField.H:58
Foam::processorFaPatchField::~processorFaPatchField
~processorFaPatchField()
Definition: processorFaPatchField.C:138
Foam::processorFaPatch
Processor patch.
Definition: processorFaPatch.H:56
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
Foam::processorFaPatchField::clone
virtual tmp< faPatchField< Type > > clone() const
Construct and return a clone.
Definition: processorFaPatchField.H:113
coupledFaPatchField.H
Foam::processorFaPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: processorFaPatchField.H:261
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::processorFaPatchField::transformCoupleField
virtual void transformCoupleField(solveScalarField &f, const direction cmpt) const
Transform neighbour field.
Definition: processorFaPatchField.H:182
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::processorFaPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFaPatchField.H:267
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
areaFaMesh.H
Foam::coupledFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: coupledFaPatchField.H:57
Foam::processorFaPatchField::patchNeighbourField
tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
Definition: processorFaPatchField.C:146
f
labelList f(nPoints)
Foam::UPstream::worldComm
static label worldComm
Default communicator (all processors)
Definition: UPstream.H:293
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::processorFaPatch::myProcNo
int myProcNo() const noexcept
Return processor number.
Definition: processorFaPatch.H:185
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
processorFaPatchField.C
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::processorFaPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: processorFaPatchField.H:273
Foam::processorFaPatchField::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: processorFaPatchField.H:255
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::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54