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-2022 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  faePatchFieldBase.C
45  faePatchFieldNew.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef Foam_faePatchField_H
50 #define Foam_faePatchField_H
51 
52 #include "faPatch.H"
53 #include "DimensionedField.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 // Forward Declarations
61 
62 class objectRegistry;
63 class dictionary;
64 class faPatchFieldMapper;
65 class edgeMesh;
66 
67 template<class Type> class faePatchField;
68 template<class Type> class calculatedFaePatchField;
69 
70 template<class Type>
71 Ostream& operator<<(Ostream&, const faePatchField<Type>&);
72 
73 
74 /*---------------------------------------------------------------------------*\
75  Class faePatchFieldBase Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 //- Template invariant parts for faePatchField
80 {
81  // Private Data
82 
83  //- Reference to patch
84  const faPatch& patch_;
85 
86 protected:
87 
88  // Protected Member Functions
89 
90  //- Read dictionary entries.
91  // Useful when initially constructed without a dictionary
92  virtual void readDict(const dictionary& dict);
93 
94 
95 public:
96 
97  //- Debug switch to disallow the use of generic faePatchField
98  static int disallowGenericPatchField;
99 
100  //- Runtime type information
101  TypeName("faePatchField");
103 
104  // Constructors
105 
106  //- Construct from patch
107  explicit faePatchFieldBase(const faPatch& p);
108 
109  //- Construct from patch and patch type
110  explicit faePatchFieldBase(const faPatch& p, const word& patchType);
111 
112  //- Construct from patch and dictionary
113  faePatchFieldBase(const faPatch& p, const dictionary& dict);
114 
115  //- Copy construct with new patch
116  faePatchFieldBase(const faePatchFieldBase& rhs, const faPatch& p);
117 
118  //- Copy construct
120 
121 
122  //- Destructor
123  virtual ~faePatchFieldBase() = default;
124 
125 
126  // Member Functions
127 
128  // Access
129 
130  //- The associated objectRegistry
132 
133  //- Return the patch
134  const faPatch& patch() const noexcept
135  {
136  return patch_;
137  }
138 
139 
140  // Check
141 
142  //- Check that patches are identical
143  void checkPatch(const faePatchFieldBase& rhs) const;
144 };
145 
146 
147 /*---------------------------------------------------------------------------*\
148  Class faePatchField Declaration
149 \*---------------------------------------------------------------------------*/
150 
151 template<class Type>
152 class faePatchField
153 :
154  public faePatchFieldBase,
155  public Field<Type>
156 {
157  // Private Data
158 
159  //- Reference to internal field
160  const DimensionedField<Type, edgeMesh>& internalField_;
161 
162 
163 public:
164 
165  //- The internal field type associated with the patch field
167 
168  //- The patch type for the patch field
169  typedef faPatch Patch;
170 
171  //- Type for a \em calculated patch
173 
174 
175  // Declare run-time constructor selection tables
176 
178  (
179  tmp,
181  patch,
182  (
183  const faPatch& p,
185  ),
186  (p, iF)
187  );
188 
190  (
191  tmp,
193  patchMapper,
194  (
196  const faPatch& p,
198  const faPatchFieldMapper& m
199  ),
200  (dynamic_cast<const faePatchFieldType&>(ptf), p, iF, m)
201  );
202 
204  (
207  dictionary,
208  (
209  const faPatch& p,
211  const dictionary& dict
212  ),
213  (p, iF, dict)
214  );
215 
216 
217  // Constructors
218 
219  //- Construct from patch and internal field
221  (
222  const faPatch&,
224  );
225 
226  //- Construct from patch and internal field and patch field
228  (
229  const faPatch&,
231  const Field<Type>&
232  );
233 
234  //- Construct from patch, internal field and dictionary
236  (
237  const faPatch&,
239  const dictionary&
240  );
241 
242  //- Construct by mapping the given faePatchField onto a new patch
244  (
245  const faePatchField<Type>&,
246  const faPatch&,
248  const faPatchFieldMapper&
249  );
250 
251  //- Construct as copy
253 
254  //- Construct as copy setting internal field reference
256  (
257  const faePatchField<Type>&,
259  );
260 
261  //- Construct and return a clone
262  virtual tmp<faePatchField<Type>> clone() const
263  {
264  return tmp<faePatchField<Type>>(new faePatchField<Type>(*this));
265  }
266 
267  //- Construct and return a clone setting internal field reference
269  (
271  ) const
272  {
274  (
275  new faePatchField<Type>(*this, iF)
276  );
277  }
278 
279 
280  //- Destructor
281  virtual ~faePatchField() = default;
282 
283 
284  // Selectors
285 
286  //- Return a pointer to a new patchField created on freestore given
287  // patch and internal field
288  // (does not set the patch field values)
289  static tmp<faePatchField<Type>> New
290  (
291  const word& patchFieldType,
292  const faPatch&,
293  const DimensionedField<Type, edgeMesh>&
294  );
295 
296  //- Return a pointer to a new patchField created on freestore given
297  // patch and internal field
298  // (does not set the patch field values)
299  // Allows override of constraint type
300  static tmp<faePatchField<Type>> New
301  (
302  const word& patchFieldType,
303  const word& actualPatchType,
304  const faPatch&,
305  const DimensionedField<Type, edgeMesh>&
306  );
307 
308  //- Return a pointer to a new patchField created on freestore from
309  // a given faePatchField mapped onto a new patch
311  (
312  const faePatchField<Type>&,
313  const faPatch&,
315  const faPatchFieldMapper&
316  );
317 
318  //- Return a pointer to a new patchField created on freestore
319  // from dictionary
321  (
322  const faPatch&,
324  const dictionary&
325  );
326 
327  //- Return a pointer to a new calculatedFaePatchField created on
328  // freestore without setting patchField values
329  template<class Type2>
331  (
332  const faePatchField<Type2>&
333  );
334 
335 
336  // Member Functions
337 
338  //- The type name for calculated patch fields
339  static const word& calculatedType();
340 
341 
342  // Attributes
343 
344  //- True if this patch field fixes a value.
345  // Needed to check if a level has to be specified while solving
346  // Poissons equations.
347  virtual bool fixesValue() const
348  {
349  return false;
350  }
351 
352  //- True if this patch field is coupled
353  virtual bool coupled() const
354  {
355  return false;
356  }
357 
358 
359  // Access
360 
361  //- Return local objectRegistry
362  const objectRegistry& db() const;
363 
364  //- Return dimensioned internal field reference
365  const DimensionedField<Type, edgeMesh>& internalField()
366  const noexcept
367  {
368  return internalField_;
369  }
370 
371  //- Return internal field reference
372  const Field<Type>& primitiveField() const noexcept
373  {
374  return internalField_;
375  }
376 
377 
378  // Mapping
379 
380  //- Map (and resize as needed) from self given a mapping object
381  virtual void autoMap
382  (
383  const faPatchFieldMapper&
384  );
385 
386  //- Reverse map the given faePatchField onto this faePatchField
387  virtual void rmap
388  (
389  const faePatchField<Type>&,
390  const labelList&
391  );
392 
393 
394  //- Write
395  virtual void write(Ostream&) const;
396 
397 
398  // Check
399 
400  //- Check faePatchField<Type> against given faePatchField<Type>
401  void check(const faePatchField<Type>&) const;
402 
403 
404  // Member Operators
405 
406  virtual void operator=(const UList<Type>&);
407 
408  virtual void operator=(const faePatchField<Type>&);
409  virtual void operator+=(const faePatchField<Type>&);
410  virtual void operator-=(const faePatchField<Type>&);
411  virtual void operator*=(const faePatchField<scalar>&);
412  virtual void operator/=(const faePatchField<scalar>&);
413 
414  virtual void operator+=(const Field<Type>&);
415  virtual void operator-=(const Field<Type>&);
416 
417  virtual void operator*=(const Field<scalar>&);
418  virtual void operator/=(const Field<scalar>&);
419 
420  virtual void operator=(const Type&);
421  virtual void operator+=(const Type&);
422  virtual void operator-=(const Type&);
423  virtual void operator*=(const scalar);
424  virtual void operator/=(const scalar);
425 
427  // Force an assignment irrespective of form of patch
428 
429  virtual void operator==(const faePatchField<Type>&);
430  virtual void operator==(const Field<Type>&);
431  virtual void operator==(const Type&);
432 
433 
434  // Ostream Operator
435 
436  friend Ostream& operator<< <Type>(Ostream&, const faePatchField<Type>&);
437 };
438 
439 
440 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441 
442 } // End namespace Foam
443 
444 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
445 
446 #ifdef NoRepository
447  #include "faePatchField.C"
448  #include "calculatedFaePatchField.H"
449 #endif
450 
452 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
453 // Runtime selection macros
454 
455 #define makeFaePatchTypeFieldTypeName(typePatchTypeField) \
456  \
457 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
458 
459 #define makeFaePatchFieldsTypeName(typePatchField) \
460  \
461 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchScalarField); \
462 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchVectorField); \
463 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchSphericalTensorField); \
464 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchSymmTensorField); \
465 makeFaePatchTypeFieldTypeName(typePatchField##FaePatchTensorField);
466 
467 
468 #define makeFaePatchTypeField(PatchTypeField, typePatchTypeField) \
469  \
470 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
471  \
472 addToRunTimeSelectionTable \
473 ( \
474  PatchTypeField, typePatchTypeField, patch \
475 ); \
476  \
477 addToRunTimeSelectionTable \
478 ( \
479  PatchTypeField, \
480  typePatchTypeField, \
481  patchMapper \
482 ); \
483  \
484 addToRunTimeSelectionTable \
485 ( \
486  PatchTypeField, typePatchTypeField, dictionary \
487 );
488 
489 
490 #define makeFaePatchFields(type) \
491  \
492 makeFaePatchTypeField(faePatchScalarField, type##FaePatchScalarField); \
493 makeFaePatchTypeField(faePatchVectorField, type##FaePatchVectorField); \
494 makeFaePatchTypeField \
495 ( \
496  faePatchSphericalTensorField, \
497  type##FaePatchSphericalTensorField \
498 ); \
499 makeFaePatchTypeField(faePatchSymmTensorField, type##FaePatchSymmTensorField); \
500 makeFaePatchTypeField(faePatchTensorField, type##FaePatchTensorField);
501 
502 
503 #define makeFaePatchTypeFieldTypedefs(type) \
504  \
505 typedef type##FaePatchField<scalar> type##FaePatchScalarField; \
506 typedef type##FaePatchField<vector> type##FaePatchVectorField; \
507 typedef type##FaePatchField<sphericalTensor> \
508  type##FaePatchSphericalTensorField; \
509 typedef type##FaePatchField<symmTensor> type##FaePatchSymmTensorField; \
510 typedef type##FaePatchField<tensor> type##FaePatchTensorField;
511 
512 
513 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
514 
515 #endif
516 
517 // ************************************************************************* //
dictionary dict
const objectRegistry & db() const
Return local objectRegistry.
virtual void readDict(const dictionary &dict)
Read dictionary entries.
virtual bool coupled() const
True if this patch field is coupled.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
Template invariant parts for faePatchField.
Definition: faePatchField.H:76
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual ~faePatchField()=default
Destructor.
virtual bool fixesValue() const
True if this patch field fixes a value.
const DimensionedField< Type, edgeMesh > & internalField() const noexcept
Return dimensioned internal field reference.
declareRunTimeSelectionTable(tmp, faePatchField, patch,(const faPatch &p, const DimensionedField< Type, edgeMesh > &iF),(p, iF))
Generic templated field type.
Definition: Field.H:61
faPatch Patch
The patch type for the patch field.
DimensionedField< Type, edgeMesh > Internal
The internal field type associated with the patch field.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void operator*=(const faePatchField< scalar > &)
virtual tmp< faePatchField< Type > > clone() const
Construct and return a clone.
const faPatch & patch() const noexcept
The associated objectRegistry.
faePatchFieldBase(const faPatch &p)
Construct from patch.
virtual void write(Ostream &) const
Write.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
virtual void rmap(const faePatchField< Type > &, const labelList &)
Reverse map the given faePatchField onto this faePatchField.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
static tmp< faePatchField< Type > > NewCalculatedType(const faePatchField< Type2 > &)
Return a pointer to a new calculatedFaePatchField created on.
virtual ~faePatchFieldBase()=default
Destructor.
virtual void operator=(const UList< Type > &)
void check(const faePatchField< Type > &) const
Check faePatchField<Type> against given faePatchField<Type>
calculatedFaePatchField< Type > Calculated
Type for a calculated patch.
virtual void operator/=(const faePatchField< scalar > &)
TypeName("faePatchField")
Runtime type information.
virtual void operator==(const faePatchField< Type > &)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
faePatchField(const faPatch &, const DimensionedField< Type, edgeMesh > &)
Construct from patch and internal field.
Definition: faePatchField.C:29
static tmp< faePatchField< Type > > New(const word &patchFieldType, const faPatch &, const DimensionedField< Type, edgeMesh > &)
Return a pointer to a new patchField created on freestore given.
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:46
virtual void operator+=(const faePatchField< Type > &)
List< label > labelList
A List of labels.
Definition: List.H:62
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static int disallowGenericPatchField
Debug switch to disallow the use of generic faePatchField.
A FieldMapper for finite-area patch fields.
void checkPatch(const faePatchFieldBase &rhs) const
Check that patches are identical.
virtual void operator-=(const faePatchField< Type > &)
static const word & calculatedType()
The type name for calculated patch fields.
const Field< Type > & primitiveField() const noexcept
Return internal field reference.
Namespace for OpenFOAM.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.