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 solveScalarField& psiInternal,
197  const scalarField& coeffs,
198  const direction cmpt,
199  const Pstream::commsTypes commsType
200  ) const;
201 
202  //- Update result field based on interface functionality
203  virtual void updateInterfaceMatrix
204  (
205  solveScalarField& result,
206  const bool add,
207  const solveScalarField& psiInternal,
208  const scalarField& coeffs,
209  const direction cmpt,
210  const Pstream::commsTypes commsType
211  ) const;
212 
213  //- Initialise neighbour matrix update
214  virtual void initInterfaceMatrixUpdate
215  (
216  Field<Type>& result,
217  const bool add,
218  const Field<Type>&,
219  const scalarField& coeffs,
220  const Pstream::commsTypes commsType
221  ) const;
222 
223  //- Update result field based on interface functionality
224  virtual void updateInterfaceMatrix
225  (
226  Field<Type>& result,
227  const bool add,
228  const Field<Type>&,
229  const scalarField& coeffs,
230  const Pstream::commsTypes commsType
231  ) const;
232 
233  //- Processor coupled interface functions
234 
235  //- Return communicator used for comms
236  virtual label comm() const
237  {
238  return UPstream::worldComm;
239  }
240 
241  //- Return processor number
242  virtual int myProcNo() const
243  {
244  return procPatch_.myProcNo();
245  }
246 
247  //- Return neighbour processor number
248  virtual int neighbProcNo() const
249  {
250  return procPatch_.neighbProcNo();
251  }
252 
253  //- Does the patch field perform the transformation
254  virtual bool doTransform() const
255  {
256  return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
257  }
258 
259  //- Return face transformation tensor
260  virtual const tensorField& forwardT() const
261  {
262  return procPatch_.forwardT();
263  }
264 
265  //- Return rank of component for transform
266  virtual int rank() const
267  {
268  return pTraits<Type>::rank;
269  }
270 };
271 
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 } // End namespace Foam
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #ifdef NoRepository
280  #include "processorFaPatchField.C"
281 #endif
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************************************************************* //
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:226
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::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:235
Foam::processorFaPatchField::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: processorFaPatchField.H:241
processorFaPatch.H
Foam::processorFaPatchField::processorFaPatchField
processorFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: processorFaPatchField.C:39
Foam::UPstream::parRun
static bool & parRun()
Test if this a parallel run, or allow modify access.
Definition: UPstream.H:434
processorLduInterfaceField.H
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::processorFaPatch::myProcNo
int myProcNo() const
Return processor number.
Definition: processorFaPatch.H:185
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
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:55
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:253
Foam::processorFaPatch::neighbProcNo
int neighbProcNo() const
Return neighbour processor number.
Definition: processorFaPatch.H:191
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::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::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::processorFaPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFaPatchField.H:259
areaFaMesh.H
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
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:295
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:54
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:265
Foam::processorFaPatchField::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: processorFaPatchField.H:247
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::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54