faPatchField.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::faPatchField
29 
30 Description
31  faPatchField<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  faPatchField.C
44  newPatchField.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef faPatchField_H
49 #define faPatchField_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 areaMesh;
65 
66 template<class Type>
67 class faPatchField;
68 
69 template<class Type>
70 class calculatedFaPatchField;
71 
72 template<class Type>
73 Ostream& operator<<(Ostream&, const faPatchField<Type>&);
74 
75 /*---------------------------------------------------------------------------*\
76  Class faPatchField Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 template<class Type>
80 class faPatchField
81 :
82  public Field<Type>
83 {
84  // Private Data
85 
86  //- Reference to a patch
87  const faPatch& patch_;
88 
89  //- Reference to internal field
90  const DimensionedField<Type, areaMesh>& internalField_;
91 
92  //- Update index used so that updateCoeffs is called only once during
93  // the construction of the matrix
94  bool updated_;
95 
96  //- Optional patch type, used to allow specified boundary conditions
97  //- to be applied to constraint patches by providing the constraint
98  //- patch type as 'patchType'
99  word patchType_;
100 
101 
102 public:
103 
104  typedef faPatch Patch;
106 
107 
108  //- Runtime type information
109  TypeName("faPatchField");
110 
111  //- Debug switch to disallow the use of
112  static int disallowGenericFaPatchField;
113 
114 
115  // Declare run-time constructor selection tables
116 
118  (
119  tmp,
120  faPatchField,
121  patch,
122  (
123  const faPatch& p,
125  ),
126  (p, iF)
127  );
128 
130  (
131  tmp,
132  faPatchField,
133  patchMapper,
134  (
135  const faPatchField<Type>& ptf,
136  const faPatch& p,
138  const faPatchFieldMapper& m
139  ),
140  (dynamic_cast<const faPatchFieldType&>(ptf), p, iF, m)
141  );
142 
144  (
145  tmp,
146  faPatchField,
147  dictionary,
148  (
149  const faPatch& p,
151  const dictionary& dict
152  ),
153  (p, iF, dict)
154  );
155 
156 
157  // Constructors
158 
159  //- Construct from patch and internal field
161  (
162  const faPatch&,
164  );
165 
166  //- Construct from patch and internal field and patch field
168  (
169  const faPatch&,
171  const Field<Type>&
172  );
173 
174  //- Construct from patch, internal field and dictionary
176  (
177  const faPatch&,
179  const dictionary&
180  );
181 
182  //- Construct by mapping the given faPatchField onto a new patch
184  (
185  const faPatchField<Type>&,
186  const faPatch&,
188  const faPatchFieldMapper&
189  );
190 
191  //- Construct as copy
193 
194  //- Construct and return a clone
195  virtual tmp<faPatchField<Type>> clone() const
196  {
197  return tmp<faPatchField<Type>>(new faPatchField<Type>(*this));
198  }
199 
200  //- Construct as copy setting internal field reference
202  (
203  const faPatchField<Type>&,
205  );
206 
207  //- Construct and return a clone setting internal field reference
209  (
211  ) const
212  {
213  return tmp<faPatchField<Type>>(new faPatchField<Type>(*this, iF));
214  }
215 
216 
217  // Selectors
218 
219  //- Return a pointer to a new patchField created on freestore given
220  //- patch and internal field
221  // (does not set the patch field values)
223  (
224  const word& patchFieldType,
225  const word& actualPatchType,
226  const faPatch&,
228  );
229 
230  //- Return a pointer to a new patchField created on freestore given
231  //- patch and internal field
232  // (does not set the patch field values)
234  (
235  const word& patchFieldType,
236  const faPatch&,
238  );
239 
240  //- Return a pointer to a new patchField created on freestore from
241  //- a given faPatchField mapped onto a new patch
243  (
244  const faPatchField<Type>&,
245  const faPatch&,
247  const faPatchFieldMapper&
248  );
249 
250  //- Return a pointer to a new patchField created on freestore
251  //- from dictionary
253  (
254  const faPatch&,
256  const dictionary&
257  );
258 
259  //- Return a pointer to a new calculatedFaPatchField created on
260  //- freestore without setting patchField values
261  template<class Type2>
263  (
264  const faPatchField<Type2>&
265  );
266 
267 
268  //- Destructor
269  virtual ~faPatchField<Type>() = default;
270 
271 
272  // Member Functions
273 
274  // Access
275 
276  //- Return local objectRegistry
277  const objectRegistry& db() const;
278 
279  //- Return patch
280  const faPatch& patch() const
281  {
282  return patch_;
283  }
284 
285  //- Return dimensioned internal field reference
287  {
288  return internalField_;
289  }
290 
291  //- Return internal field reference
292  const Field<Type>& primitiveField() const
293  {
294  return internalField_;
295  }
296 
297  //- Optional patch type
298  const word& patchType() const
299  {
300  return patchType_;
301  }
302 
303  //- Optional patch type
304  word& patchType()
305  {
306  return patchType_;
307  }
308 
309  //- Return the type of the calculated for of faPatchField
310  static const word& calculatedType();
311 
312  //- Return true if this patch field fixes a value.
313  // Needed to check if a level has to be specified while solving
314  // Poissons equations.
315  virtual bool fixesValue() const
316  {
317  return false;
318  }
319 
320  //- Return true if this patch field is coupled
321  virtual bool coupled() const
322  {
323  return false;
324  }
325 
326  //- Return true if the boundary condition has already been updated
327  bool updated() const
328  {
329  return updated_;
330  }
331 
332 
333  // Mapping
334 
335  //- Map (and resize as needed) from self given a mapping object
336  virtual void autoMap
337  (
338  const faPatchFieldMapper&
339  );
340 
341  //- Reverse map the given faPatchField onto this faPatchField
342  virtual void rmap
343  (
344  const faPatchField<Type>&,
345  const labelList&
346  );
347 
348 
349  // Evaluation
350 
351  //- Return patch-normal gradient
352  virtual tmp<Field<Type>> snGrad() const;
353 
354  //- Update the coefficients associated with the patch field
355  // Sets Updated to true
356  virtual void updateCoeffs()
357  {
358  updated_ = true;
359  }
360 
361  //- Return internal field next to patch as patch field
362  virtual tmp<Field<Type>> patchInternalField() const;
363 
364  //- Return patchField on the opposite patch of a coupled patch
365  virtual tmp<Field<Type>> patchNeighbourField() const
366  {
368  return *this;
369  }
370 
371  //- Initialise the evaluation of the patch field
372  virtual void initEvaluate
373  (
374  const Pstream::commsTypes commsType =
376  )
377  {}
378 
379  //- Evaluate the patch field, sets Updated to false
380  virtual void evaluate
381  (
382  const Pstream::commsTypes commsType =
384  );
385 
386  //- Return the matrix diagonal coefficients corresponding to the
387  //- evaluation of the value of this patchField with given weights
389  (
390  const tmp<Field<scalar>>&
391  ) const
392  {
394  return *this;
395  }
396 
397  //- Return the matrix source coefficients corresponding to the
398  //- evaluation of the value of this patchField with given weights
400  (
401  const tmp<Field<scalar>>&
402  ) const
403  {
405  return *this;
406  }
407 
408  //- Return the matrix diagonal coefficients corresponding to the
409  //- evaluation of the gradient of this patchField
410  virtual tmp<Field<Type>> gradientInternalCoeffs() const
411  {
413  return *this;
414  }
415 
416  //- Return the matrix source coefficients corresponding to the
417  //- evaluation of the gradient of this patchField
418  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const
419  {
421  return *this;
422  }
423 
424 
425  // IO
426 
427  //- Write
428  virtual void write(Ostream&) const;
429 
430 
431  // Check
432 
433  //- Check faPatchField<Type> against given faPatchField<Type>
434  void check(const faPatchField<Type>&) const;
435 
436 
437  // Member Operators
438 
439  virtual void operator=(const UList<Type>&);
440 
441  virtual void operator=(const faPatchField<Type>&);
442  virtual void operator+=(const faPatchField<Type>&);
443  virtual void operator-=(const faPatchField<Type>&);
444  virtual void operator*=(const faPatchField<scalar>&);
445  virtual void operator/=(const faPatchField<scalar>&);
446 
447  virtual void operator+=(const Field<Type>&);
448  virtual void operator-=(const Field<Type>&);
449 
450  virtual void operator*=(const Field<scalar>&);
451  virtual void operator/=(const Field<scalar>&);
452 
453  virtual void operator=(const Type&);
454  virtual void operator+=(const Type&);
455  virtual void operator-=(const Type&);
456  virtual void operator*=(const scalar);
457  virtual void operator/=(const scalar);
458 
459 
460  // Force an assignment irrespective of form of patch
461 
462  virtual void operator==(const faPatchField<Type>&);
463  virtual void operator==(const Field<Type>&);
464  virtual void operator==(const Type&);
465 
466 
467  // Ostream operator
468 
469  friend Ostream& operator<< <Type>(Ostream&, const faPatchField<Type>&);
470 };
471 
472 
473 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
474 
475 } // End namespace Foam
476 
477 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
478 
479 #ifdef NoRepository
480  #include "faPatchField.C"
481  #include "calculatedFaPatchField.H"
482 #endif
483 
484 
485 #define addToFaPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
486  \
487 addToRunTimeSelectionTable \
488 ( \
489  PatchTypeField, typePatchTypeField, patch \
490 ); \
491  \
492 addToRunTimeSelectionTable \
493 ( \
494  PatchTypeField, \
495  typePatchTypeField, \
496  patchMapper \
497 ); \
498  \
499 addToRunTimeSelectionTable \
500 ( \
501  PatchTypeField, typePatchTypeField, dictionary \
502 );
503 
504 
505 #define makeFaPatchTypeFieldTypeName(typePatchTypeField) \
506  \
507 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
508 
509 
510 #define makeFaPatchFieldsTypeName(typePatchField) \
511  \
512 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchScalarField); \
513 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchVectorField); \
514 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSphericalTensorField); \
515 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSymmTensorField); \
516 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchTensorField);
517 
518 
519 #define makeFaPatchTypeField(PatchTypeField, typePatchTypeField) \
520  \
521 defineTypeNameAndDebug(typePatchTypeField, 0); \
522  \
523 addToFaPatchFieldRunTimeSelection \
524 ( \
525  PatchTypeField, typePatchTypeField \
526 );
527 
528 #define makeTemplateFaPatchTypeField(PatchTypeField, typePatchTypeField) \
529  \
530 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
531  \
532 addToFaPatchFieldRunTimeSelection \
533 ( \
534  PatchTypeField, typePatchTypeField \
535 );
536 
537 
538 #define makeFaPatchFields(type) \
539  \
540 makeTemplateFaPatchTypeField(faPatchScalarField, type##FaPatchScalarField); \
541 makeTemplateFaPatchTypeField(faPatchVectorField, type##FaPatchVectorField); \
542 makeTemplateFaPatchTypeField \
543 ( \
544  faPatchSphericalTensorField, \
545  type##FaPatchSphericalTensorField \
546 ); \
547 makeTemplateFaPatchTypeField \
548 ( \
549  faPatchSymmTensorField, \
550  type##FaPatchSymmTensorField \
551 ); \
552 makeTemplateFaPatchTypeField \
553 ( \
554  faPatchTensorField, \
555  type##FaPatchTensorField \
556 );
557 
558 
559 #define makeFaPatchTypeFieldTypedefs(type) \
560  \
561 typedef type##FaPatchField<scalar> type##FaPatchScalarField; \
562 typedef type##FaPatchField<vector> type##FaPatchVectorField; \
563 typedef type##FaPatchField<sphericalTensor> \
564  type##FaPatchSphericalTensorField; \
565 typedef type##FaPatchField<symmTensor> type##FaPatchSymmTensorField; \
566 typedef type##FaPatchField<tensor> type##FaPatchTensorField;
567 
568 
569 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
570 
571 #endif
572 
573 // ************************************************************************* //
Foam::faPatchField::clone
virtual tmp< faPatchField< Type > > clone() const
Construct and return a clone.
Definition: faPatchField.H:194
Foam::faPatchField::faPatchField
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: faPatchField.C:36
Foam::faPatchField::operator*=
virtual void operator*=(const faPatchField< scalar > &)
Definition: faPatchField.C:265
Foam::faPatchField::internalField
const DimensionedField< Type, areaMesh > & internalField() const
Return dimensioned internal field reference.
Definition: faPatchField.H:285
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::faPatchField::write
virtual void write(Ostream &) const
Write.
Definition: faPatchField.C:207
Foam::faPatchField::primitiveField
const Field< Type > & primitiveField() const
Return internal field reference.
Definition: faPatchField.H:291
Foam::faPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:162
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::faPatchField::NewCalculatedType
static tmp< faPatchField< Type > > NewCalculatedType(const faPatchField< Type2 > &)
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faPatchField::Patch
faPatch Patch
Definition: faPatchField.H:103
Foam::faPatchField::check
void check(const faPatchField< Type > &) const
Check faPatchField<Type> against given faPatchField<Type>
Definition: faPatchField.C:150
Foam::faPatchField::Calculated
calculatedFaPatchField< Type > Calculated
Definition: faPatchField.H:104
DimensionedField.H
Foam::faPatchField::New
static tmp< faPatchField< Type > > New(const word &patchFieldType, const word &actualPatchType, const faPatch &, const DimensionedField< Type, areaMesh > &)
Definition: faPatchFieldNew.C:33
calculatedFaPatchField.H
Foam::faPatchField::operator-=
virtual void operator-=(const faPatchField< Type > &)
Definition: faPatchField.C:254
Foam::faPatchField::calculatedType
static const word & calculatedType()
Return the type of the calculated for of faPatchField.
Definition: calculatedFaPatchField.C:35
Foam::faPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: faPatchField.H:314
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
Foam::faPatchField::autoMap
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:177
Foam::faPatchField::operator/=
virtual void operator/=(const faPatchField< scalar > &)
Definition: faPatchField.C:282
Foam::faPatchField::initEvaluate
virtual void initEvaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Initialise the evaluation of the patch field.
Definition: faPatchField.H:372
Foam::faPatchField::updated
bool updated() const
Return true if the boundary condition has already been updated.
Definition: faPatchField.H:326
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::faPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< Field< scalar >> &) const
Definition: faPatchField.H:388
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::faPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: faPatchField.H:320
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::faPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< Field< scalar >> &) const
Definition: faPatchField.H:399
Foam::faPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Definition: faPatchField.H:409
Foam::calculatedFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: calculatedFaPatchField.H:54
Foam::faPatchField::disallowGenericFaPatchField
static int disallowGenericFaPatchField
Debug switch to disallow the use of.
Definition: faPatchField.H:111
Foam::faPatchField::patchInternalField
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: faPatchField.C:170
Foam::faPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: faPatchField.C:195
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
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return patchField on the opposite patch of a coupled patch.
Definition: faPatchField.H:364
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::faPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Definition: faPatchField.H:417
Foam::faPatchField::patchType
const word & patchType() const
Optional patch type.
Definition: faPatchField.H:297
Foam::List< label >
faPatch.H
Foam::UList< Type >
Foam::faPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: faPatchField.C:142
Foam::faPatchField::rmap
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:185
Foam::faPatchField::operator+=
virtual void operator+=(const faPatchField< Type > &)
Definition: faPatchField.C:243
Foam::faPatchField::patchType
word & patchType()
Optional patch type.
Definition: faPatchField.H:303
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
faPatchField.C
Foam::faPatchField::operator==
virtual void operator==(const faPatchField< Type > &)
Definition: faPatchField.C:389
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
Foam::faPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.H:355
Foam::faPatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: faPatchField.C:222
Foam::faPatchField::TypeName
TypeName("faPatchField")
Runtime type information.
Foam::faPatchField::patch
const faPatch & patch() const
Return patch.
Definition: faPatchField.H:279
Foam::faPatchField::declareRunTimeSelectionTable
declareRunTimeSelectionTable(tmp, faPatchField, patch,(const faPatch &p, const DimensionedField< Type, areaMesh > &iF),(p, iF))
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::UPstream::commsTypes::blocking