faePatchField.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::faePatchField
29 
30 Description
31  faePatchField<Type> abstract base class. This class gives a fat-interface
32  to all derived classes covering all possible ways in which they might be
33  used. The first level of derivation is to basic patchFields which cover
34  zero-gradient, fixed-gradient, fixed-value and mixed conditions. The next
35  level of derivation covers all the specialised typed with specific
36  evaluation procedures, particularly with respect to specific fields.
37 
38 Author
39  Zeljko Tukovic, FMENA
40  Hrvoje Jasak, Wikki Ltd.
41 
42 SourceFiles
43  faePatchField.C
44  newPatchField.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef faePatchField_H
49 #define faePatchField_H
50 
51 #include "faPatch.H"
52 #include "DimensionedField.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward Declarations
60 
61 class objectRegistry;
62 class dictionary;
63 class faPatchFieldMapper;
64 class edgeMesh;
65 
66 template<class Type>
67 class faePatchField;
68 
69 template<class Type>
70 class calculatedFaePatchField;
71 
72 template<class Type>
73 Ostream& operator<<(Ostream&, const faePatchField<Type>&);
74 
75 
76 /*---------------------------------------------------------------------------*\
77  Class faePatchField Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Type>
81 class faePatchField
82 :
83  public Field<Type>
84 {
85  // Private data
86 
87  //- Reference to a patch
88  const faPatch& patch_;
89 
90  //- Reference to internal field
91  const DimensionedField<Type, edgeMesh>& internalField_;
92 
93 
94 public:
95 
96  typedef faPatch Patch;
98 
99 
100  //- Runtime type information
101  TypeName("faePatchField");
102 
103  //- Debug switch to disallow the use of
104  static int disallowGenericFaePatchField;
105 
106 
107  // Declare run-time constructor selection tables
108 
110  (
111  tmp,
113  patch,
114  (
115  const faPatch& p,
117  ),
118  (p, iF)
119  );
120 
122  (
123  tmp,
125  patchMapper,
126  (
127  const faePatchField<Type>& ptf,
128  const faPatch& p,
130  const faPatchFieldMapper& m
131  ),
132  (dynamic_cast<const faePatchFieldType&>(ptf), p, iF, m)
133  );
134 
136  (
137  tmp,
139  dictionary,
140  (
141  const faPatch& p,
143  const dictionary& dict
144  ),
145  (p, iF, dict)
146  );
147 
148 
149  // Constructors
150 
151  //- Construct from patch and internal field
153  (
154  const faPatch&,
156  );
157 
158  //- Construct from patch and internal field and patch field
160  (
161  const faPatch&,
163  const Field<Type>&
164  );
165 
166  //- Construct from patch, internal field and dictionary
168  (
169  const faPatch&,
171  const dictionary&
172  );
173 
174  //- Construct by mapping the given faePatchField onto a new patch
176  (
177  const faePatchField<Type>&,
178  const faPatch&,
180  const faPatchFieldMapper&
181  );
182 
183  //- Construct as copy
185 
186  //- Construct and return a clone
187  virtual tmp<faePatchField<Type>> clone() const
188  {
189  return tmp<faePatchField<Type>>(new faePatchField<Type>(*this));
190  }
191 
192  //- Construct as copy setting internal field reference
194  (
195  const faePatchField<Type>&,
197  );
198 
199  //- Construct and return a clone setting internal field reference
201  (
203  ) const
204  {
206  (
207  new faePatchField<Type>(*this, iF)
208  );
209  }
210 
211 
212  //- Destructor
213  virtual ~faePatchField() = default;
214 
215 
216  // Selectors
217 
218  //- Return a pointer to a new patchField created on freestore given
219  // patch and internal field
220  // (does not set the patch field values)
222  (
223  const word&,
224  const faPatch&,
226  );
227 
228  //- Return a pointer to a new patchField created on freestore from
229  // a given faePatchField mapped onto a new patch
231  (
232  const faePatchField<Type>&,
233  const faPatch&,
235  const faPatchFieldMapper&
236  );
237 
238  //- Return a pointer to a new patchField created on freestore
239  // from dictionary
241  (
242  const faPatch&,
244  const dictionary&
245  );
246 
247  //- Return a pointer to a new calculatedFaePatchField created on
248  // freestore without setting patchField values
249  template<class Type2>
251  (
252  const faePatchField<Type2>&
253  );
254 
255 
256  // Member functions
257 
258  // Access
259 
260  //- Return local objectRegistry
261  const objectRegistry& db() const;
262 
263  //- Return patch
264  const faPatch& patch() const
265  {
266  return patch_;
267  }
268 
269  //- Return dimensioned internal field reference
271  {
272  return internalField_;
273  }
274 
275  //- Return internal field reference
276  const Field<Type>& primitiveField() const
277  {
278  return internalField_;
279  }
280 
281  //- Return the type of the calculated for of faePatchField
282  static const word& calculatedType();
283 
284  //- Return true if this patch field fixes a value.
285  // Needed to check if a level has to be specified while solving
286  // Poissons equations.
287  virtual bool fixesValue() const
288  {
289  return false;
290  }
291 
292  //- Return true if this patch field is coupled
293  virtual bool coupled() const
294  {
295  return false;
296  }
297 
298 
299  // Mapping functions
300 
301  //- Map (and resize as needed) from self given a mapping object
302  virtual void autoMap
303  (
304  const faPatchFieldMapper&
305  );
306 
307  //- Reverse map the given faePatchField onto this faePatchField
308  virtual void rmap
309  (
310  const faePatchField<Type>&,
311  const labelList&
312  );
313 
314 
315  //- Write
316  virtual void write(Ostream&) const;
317 
318 
319  // Check
320 
321  //- Check faePatchField<Type> against given faePatchField<Type>
322  void check(const faePatchField<Type>&) const;
323 
324 
325  // Member operators
326 
327  virtual void operator=(const UList<Type>&);
328 
329  virtual void operator=(const faePatchField<Type>&);
330  virtual void operator+=(const faePatchField<Type>&);
331  virtual void operator-=(const faePatchField<Type>&);
332  virtual void operator*=(const faePatchField<scalar>&);
333  virtual void operator/=(const faePatchField<scalar>&);
334 
335  virtual void operator+=(const Field<Type>&);
336  virtual void operator-=(const Field<Type>&);
337 
338  virtual void operator*=(const Field<scalar>&);
339  virtual void operator/=(const Field<scalar>&);
340 
341  virtual void operator=(const Type&);
342  virtual void operator+=(const Type&);
343  virtual void operator-=(const Type&);
344  virtual void operator*=(const scalar);
345  virtual void operator/=(const scalar);
346 
347 
348  // Force an assignment irrespective of form of patch
349 
350  virtual void operator==(const faePatchField<Type>&);
351  virtual void operator==(const Field<Type>&);
352  virtual void operator==(const Type&);
353 
354 
355  // Ostream operator
356 
357  friend Ostream& operator<< <Type>(Ostream&, const faePatchField<Type>&);
358 };
359 
360 
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 
363 } // End namespace Foam
364 
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
366 
367 #ifdef NoRepository
368  #include "faePatchField.C"
369  #include "calculatedFaePatchField.H"
370 #endif
371 
372 
373 #define makeFaePatchTypeFieldTypeName(typePatchTypeField) \
374  \
375 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
376 
377 #define makeFaePatchFieldsTypeName(typePatchField) \
378  \
379 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchScalarField); \
380 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchVectorField); \
381 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchSphericalTensorField); \
382 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchSymmTensorField); \
383 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchTensorField);
384 
385 
386 #define makeFaePatchTypeField(PatchTypeField, typePatchTypeField) \
387  \
388 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
389  \
390 addToRunTimeSelectionTable \
391 ( \
392  PatchTypeField, typePatchTypeField, patch \
393 ); \
394  \
395 addToRunTimeSelectionTable \
396 ( \
397  PatchTypeField, \
398  typePatchTypeField, \
399  patchMapper \
400 ); \
401  \
402 addToRunTimeSelectionTable \
403 ( \
404  PatchTypeField, typePatchTypeField, dictionary \
405 );
406 
407 
408 #define makeFaePatchFields(type) \
409  \
410 makeFaePatchTypeField(faePatchScalarField, type##FaePatchScalarField); \
411 makeFaePatchTypeField(faePatchVectorField, type##FaePatchVectorField); \
412 makeFaePatchTypeField \
413 ( \
414  faePatchSphericalTensorField, \
415  type##FaePatchSphericalTensorField \
416 ); \
417 makeFaePatchTypeField(faePatchSymmTensorField, type##FaePatchSymmTensorField); \
418 makeFaePatchTypeField(faePatchTensorField, type##FaePatchTensorField);
419 
420 
421 #define makeFaePatchTypeFieldTypedefs(type) \
422  \
423 typedef type##FaePatchField<scalar> type##FaePatchScalarField; \
424 typedef type##FaePatchField<vector> type##FaePatchVectorField; \
425 typedef type##FaePatchField<sphericalTensor> \
426  type##FaePatchSphericalTensorField; \
427 typedef type##FaePatchField<symmTensor> type##FaePatchSymmTensorField; \
428 typedef type##FaePatchField<tensor> type##FaePatchTensorField;
429 
430 
431 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
432 
433 #endif
434 
435 // ************************************************************************* //
Foam::faePatchField::operator==
virtual void operator==(const faePatchField< Type > &)
Definition: faePatchField.C:347
Foam::faePatchField::check
void check(const faePatchField< Type > &) const
Check faePatchField<Type> against given faePatchField<Type>
Definition: faePatchField.C:137
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faePatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: faePatchField.C:129
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::faePatchField
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:49
Foam::faePatchField::write
virtual void write(Ostream &) const
Write.
Definition: faePatchField.C:170
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faePatchField::calculatedType
static const word & calculatedType()
Return the type of the calculated for of faePatchField.
Definition: calculatedFaePatchField.C:35
DimensionedField.H
Foam::faePatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: faePatchField.H:286
Foam::faePatchField::operator/=
virtual void operator/=(const faePatchField< scalar > &)
Definition: faePatchField.C:240
Foam::faePatchField::New
static tmp< faePatchField< Type > > New(const word &, const faPatch &, const DimensionedField< Type, edgeMesh > &)
Return a pointer to a new patchField created on freestore given.
Definition: faePatchFieldNew.C:33
Foam::faePatchField::operator*=
virtual void operator*=(const faePatchField< scalar > &)
Definition: faePatchField.C:223
Foam::faePatchField::clone
virtual tmp< faePatchField< Type > > clone() const
Construct and return a clone.
Definition: faePatchField.H:186
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
Foam::faePatchField::declareRunTimeSelectionTable
declareRunTimeSelectionTable(tmp, faePatchField, patch,(const faPatch &p, const DimensionedField< Type, edgeMesh > &iF),(p, iF))
Foam::faePatchField::internalField
const DimensionedField< Type, edgeMesh > & internalField() const
Return dimensioned internal field reference.
Definition: faePatchField.H:269
Foam::faePatchField::NewCalculatedType
static tmp< faePatchField< Type > > NewCalculatedType(const faePatchField< Type2 > &)
Return a pointer to a new calculatedFaePatchField created on.
Foam::faePatchField::primitiveField
const Field< Type > & primitiveField() const
Return internal field reference.
Definition: faePatchField.H:275
Foam::faePatchField::TypeName
TypeName("faePatchField")
Runtime type information.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::faePatchField::autoMap
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faePatchField.C:150
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::faePatchField::rmap
virtual void rmap(const faePatchField< Type > &, const labelList &)
Reverse map the given faePatchField onto this faePatchField.
Definition: faePatchField.C:160
Foam::faePatchField::patch
const faPatch & patch() const
Return patch.
Definition: faePatchField.H:263
Foam::faePatchField::~faePatchField
virtual ~faePatchField()=default
Destructor.
Foam::faePatchField::operator-=
virtual void operator-=(const faePatchField< Type > &)
Definition: faePatchField.C:212
calculatedFaePatchField.H
Foam::faePatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: faePatchField.H:292
Foam::faePatchField::faePatchField
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &)
Construct from patch and internal field.
Definition: faePatchField.C:35
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:123
Foam::faePatchField::Calculated
calculatedFaePatchField< Type > Calculated
Definition: faePatchField.H:96
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faePatchField::disallowGenericFaePatchField
static int disallowGenericFaePatchField
Debug switch to disallow the use of.
Definition: faePatchField.H:103
Foam::faePatchField::Patch
faPatch Patch
Definition: faePatchField.H:95
Foam::faePatchField::operator+=
virtual void operator+=(const faePatchField< Type > &)
Definition: faePatchField.C:201
Foam::List< label >
Foam::calculatedFaePatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: calculatedFaePatchField.H:55
faPatch.H
Foam::UList< Type >
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
faePatchField.C
Foam::faePatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: faePatchField.C:180
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54