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 functions
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 functions
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 
387  //- Return the matrix diagonal coefficients corresponding to the
388  // evaluation of the value of this patchField with given weights
390  (
391  const tmp<Field<scalar>>&
392  ) const
393  {
395  return *this;
396  }
397 
398  //- Return the matrix source coefficients corresponding to the
399  // evaluation of the value of this patchField with given weights
401  (
402  const tmp<Field<scalar>>&
403  ) const
404  {
406  return *this;
407  }
408 
409  //- Return the matrix diagonal coefficients corresponding to the
410  // evaluation of the gradient of this patchField
411  virtual tmp<Field<Type>> gradientInternalCoeffs() const
412  {
414  return *this;
415  }
416 
417  //- Return the matrix source coefficients corresponding to the
418  // evaluation of the gradient of this patchField
419  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const
420  {
422  return *this;
423  }
424 
425 
426  //- Write
427  virtual void write(Ostream&) const;
428 
429 
430  // Check
431 
432  //- Check faPatchField<Type> against given faPatchField<Type>
433  void check(const faPatchField<Type>&) const;
434 
435 
436  // Member operators
437 
438  virtual void operator=(const UList<Type>&);
439 
440  virtual void operator=(const faPatchField<Type>&);
441  virtual void operator+=(const faPatchField<Type>&);
442  virtual void operator-=(const faPatchField<Type>&);
443  virtual void operator*=(const faPatchField<scalar>&);
444  virtual void operator/=(const faPatchField<scalar>&);
445 
446  virtual void operator+=(const Field<Type>&);
447  virtual void operator-=(const Field<Type>&);
448 
449  virtual void operator*=(const Field<scalar>&);
450  virtual void operator/=(const Field<scalar>&);
451 
452  virtual void operator=(const Type&);
453  virtual void operator+=(const Type&);
454  virtual void operator-=(const Type&);
455  virtual void operator*=(const scalar);
456  virtual void operator/=(const scalar);
457 
458 
459  // Force an assignment irrespective of form of patch
460 
461  virtual void operator==(const faPatchField<Type>&);
462  virtual void operator==(const Field<Type>&);
463  virtual void operator==(const Type&);
464 
465 
466  // Ostream operator
467 
468  friend Ostream& operator<< <Type>(Ostream&, const faPatchField<Type>&);
469 };
470 
471 
472 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
473 
474 } // End namespace Foam
475 
476 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
477 
478 #ifdef NoRepository
479  #include "faPatchField.C"
480  #include "calculatedFaPatchField.H"
481 #endif
482 
483 
484 #define addToFaPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
485  \
486 addToRunTimeSelectionTable \
487 ( \
488  PatchTypeField, typePatchTypeField, patch \
489 ); \
490  \
491 addToRunTimeSelectionTable \
492 ( \
493  PatchTypeField, \
494  typePatchTypeField, \
495  patchMapper \
496 ); \
497  \
498 addToRunTimeSelectionTable \
499 ( \
500  PatchTypeField, typePatchTypeField, dictionary \
501 );
502 
503 
504 #define makeFaPatchTypeFieldTypeName(typePatchTypeField) \
505  \
506 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
507 
508 
509 #define makeFaPatchFieldsTypeName(typePatchField) \
510  \
511 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchScalarField); \
512 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchVectorField); \
513 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSphericalTensorField); \
514 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSymmTensorField); \
515 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchTensorField);
516 
517 
518 #define makeFaPatchTypeField(PatchTypeField, typePatchTypeField) \
519  \
520 defineTypeNameAndDebug(typePatchTypeField, 0); \
521  \
522 addToFaPatchFieldRunTimeSelection \
523 ( \
524  PatchTypeField, typePatchTypeField \
525 );
526 
527 #define makeTemplateFaPatchTypeField(PatchTypeField, typePatchTypeField) \
528  \
529 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
530  \
531 addToFaPatchFieldRunTimeSelection \
532 ( \
533  PatchTypeField, typePatchTypeField \
534 );
535 
536 
537 #define makeFaPatchFields(type) \
538  \
539 makeTemplateFaPatchTypeField(faPatchScalarField, type##FaPatchScalarField); \
540 makeTemplateFaPatchTypeField(faPatchVectorField, type##FaPatchVectorField); \
541 makeTemplateFaPatchTypeField \
542 ( \
543  faPatchSphericalTensorField, \
544  type##FaPatchSphericalTensorField \
545 ); \
546 makeTemplateFaPatchTypeField \
547 ( \
548  faPatchSymmTensorField, \
549  type##FaPatchSymmTensorField \
550 ); \
551 makeTemplateFaPatchTypeField \
552 ( \
553  faPatchTensorField, \
554  type##FaPatchTensorField \
555 );
556 
557 
558 #define makeFaPatchTypeFieldTypedefs(type) \
559  \
560 typedef type##FaPatchField<scalar> type##FaPatchScalarField; \
561 typedef type##FaPatchField<vector> type##FaPatchVectorField; \
562 typedef type##FaPatchField<sphericalTensor> \
563  type##FaPatchSphericalTensorField; \
564 typedef type##FaPatchField<symmTensor> type##FaPatchSymmTensorField; \
565 typedef type##FaPatchField<tensor> type##FaPatchTensorField;
566 
567 
568 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
569 
570 #endif
571 
572 // ************************************************************************* //
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::UPstream::commsTypes::blocking
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:62
Foam::faPatchField::NewCalculatedType
static tmp< faPatchField< Type > > NewCalculatedType(const faPatchField< Type2 > &)
Return a pointer to a new calculatedFaPatchField created on.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
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 > &)
Return a pointer to a new patchField created on freestore given.
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:34
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
Return the matrix diagonal coefficients corresponding to the.
Definition: faPatchField.H:389
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
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
Return the matrix source coefficients corresponding to the.
Definition: faPatchField.H:400
Foam::faPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: faPatchField.H:410
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:121
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::faPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: faPatchField.H:418
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:66
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:65
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