fvsPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fvsPatchField
26 
27 Description
28  An abstract base class with a fat-interface to all derived classes
29  covering all possible ways in which they might be used.
30 
31  The first level of derivation is to basic patchFields which cover
32  zero-gradient, fixed-gradient, fixed-value and mixed conditions.
33 
34  The next level of derivation covers all the specialised typed with
35  specific evaluation procedures, particularly with respect to specific
36  fields.
37 
38 SourceFiles
39  fvsPatchField.C
40  fvsPatchFieldNew.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef fvsPatchField_H
45 #define fvsPatchField_H
46 
47 #include "fvPatch.H"
48 #include "DimensionedField.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 
57 class objectRegistry;
58 class dictionary;
59 class fvPatchFieldMapper;
60 class surfaceMesh;
61 
62 
63 // Forward declaration of friend functions and operators
64 
65 template<class Type>
66 class fvsPatchField;
67 
68 template<class Type>
70 
71 template<class Type>
72 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
73 
74 
75 /*---------------------------------------------------------------------------*\
76  Class patch Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 template<class Type>
80 class fvsPatchField
81 :
82  public Field<Type>
83 {
84  // Private Data
85 
86  //- Reference to patch
87  const fvPatch& patch_;
88 
89  //- Reference to internal field
90  const DimensionedField<Type, surfaceMesh>& internalField_;
91 
92 
93 public:
94 
95  typedef fvPatch Patch;
97 
98 
99  //- Runtime type information
100  TypeName("fvsPatchField");
101 
102  //- Debug switch to disallow the use of genericFvsPatchField
103  static int disallowGenericFvsPatchField;
104 
105 
106  // Declare run-time constructor selection tables
107 
109  (
110  tmp,
112  patch,
113  (
114  const fvPatch& p,
116  ),
117  (p, iF)
118  );
119 
121  (
122  tmp,
124  patchMapper,
125  (
126  const fvsPatchField<Type>& ptf,
127  const fvPatch& p,
129  const fvPatchFieldMapper& m
130  ),
131  (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
132  );
133 
135  (
136  tmp,
138  dictionary,
139  (
140  const fvPatch& p,
142  const dictionary& dict
143  ),
144  (p, iF, dict)
145  );
146 
147 
148  // Constructors
149 
150  //- Construct from patch and internal field
152  (
153  const fvPatch&,
155  );
156 
157  //- Construct from patch and internal field and patch field
159  (
160  const fvPatch&,
162  const Field<Type>&
163  );
164 
165  //- Construct from patch, internal field and dictionary
167  (
168  const fvPatch&,
170  const dictionary&
171  );
172 
173  //- Construct by mapping the given fvsPatchField onto a new patch
175  (
176  const fvsPatchField<Type>&,
177  const fvPatch&,
179  const fvPatchFieldMapper&
180  );
181 
182  //- Disallow copy without setting internal field reference
183  fvsPatchField(const fvsPatchField<Type>&) = delete;
184 
185  //- Disallow clone without setting internal field reference
187  {
188  // Temporarily reinstate the clone() function pending a rewrite of
189  // the mapping of surfaceFields in fvMeshDistribute
191  (
192  new fvsPatchField<Type>(*this, internalField_)
193  );
194 
195  // NotImplemented;
196  // return tmp<fvsPatchField<Type>>(nullptr);
197  }
198 
199  //- Copy constructor setting internal field reference
201  (
202  const fvsPatchField<Type>&,
204  );
205 
206  //- Construct and return a clone setting internal field reference
208  (
210  ) const
211  {
213  (
214  new fvsPatchField<Type>(*this, iF)
215  );
216  }
217 
218 
219  // Selectors
220 
221  //- Return a pointer to a new patchField created on freestore given
222  // patch and internal field
223  // (does not set the patch field values)
225  (
226  const word&,
227  const fvPatch&,
229  );
230 
231  //- Return a pointer to a new patchField created on freestore given
232  // patch and internal field
233  // (does not set the patch field values)
234  // Allows override of constraint type
236  (
237  const word&,
238  const word& actualPatchType,
239  const fvPatch&,
241  );
242 
243  //- Return a pointer to a new patchField created on freestore from
244  // a given fvsPatchField mapped onto a new patch
246  (
247  const fvsPatchField<Type>&,
248  const fvPatch&,
250  const fvPatchFieldMapper&
251  );
252 
253  //- Return a pointer to a new patchField created on freestore
254  // from dictionary
256  (
257  const fvPatch&,
259  const dictionary&
260  );
261 
262  //- Return a pointer to a new calculatedFvsPatchField created on
263  // freestore without setting patchField values
265  (
266  const fvPatch&
267  );
268 
269  //- Return a pointer to a new calculatedFvsPatchField created on
270  // freestore without setting patchField values
271  template<class Type2>
273  (
274  const fvsPatchField<Type2>&
275  );
276 
277 
278  //- Destructor
279  virtual ~fvsPatchField<Type>()
280  {}
281 
282 
283  // Member Functions
284 
285  // Attributes
286 
287  //- Return the type of the calculated for of fvsPatchField
288  static const word& calculatedType();
289 
290  //- Return true if this patch field fixes a value.
291  // Needed to check if a level has to be specified while solving
292  // Poissons equations.
293  virtual bool fixesValue() const
294  {
295  return false;
296  }
297 
298  //- Return true if this patch field is coupled
299  virtual bool coupled() const
300  {
301  return false;
302  }
303 
304  //- Return true if this overrides the underlying constraint type
305  bool overridesConstraint() const
306  {
307  if (type() == patch_.type())
308  {
309  return false;
310  }
311 
312  typename patchConstructorTable::iterator patchTypeCstrIter
313  = patchConstructorTablePtr_->find(patch_.type());
314 
315  return
316  patchTypeCstrIter
317  != patchConstructorTablePtr_->end();
318  }
319 
320 
321  // Access
322 
323  //- Return local objectRegistry
324  const objectRegistry& db() const;
325 
326  //- Return patch
327  const fvPatch& patch() const
328  {
329  return patch_;
330  }
331 
332  //- Return dimensioned internal field reference
334  internalField() const
335  {
336  return internalField_;
337  }
338 
339  //- Return internal field reference
340  const Field<Type>& primitiveField() const
341  {
342  return internalField_;
343  }
344 
345 
346  // Mapping functions
347 
348  //- Map (and resize as needed) from self given a mapping object
349  // Used to update fields following mesh topology change
350  virtual void autoMap(const fvPatchFieldMapper&);
351 
352  //- Reverse map the given fvsPatchField onto this fvsPatchField
353  // Used to reconstruct fields
354  virtual void rmap(const fvsPatchField<Type>&, const labelList&);
355 
356 
357  //- Write
358  virtual void write(Ostream&) const;
359 
360 
361  // Check
362 
363  //- Check fvsPatchField<Type> against given fvsPatchField<Type>
364  void check(const fvsPatchField<Type>&) const;
365 
366 
367  // Member Operators
368 
369  virtual void operator=(const UList<Type>&);
370 
371  virtual void operator=(const fvsPatchField<Type>&);
372  virtual void operator+=(const fvsPatchField<Type>&);
373  virtual void operator-=(const fvsPatchField<Type>&);
374  virtual void operator*=(const fvsPatchField<scalar>&);
375  virtual void operator/=(const fvsPatchField<scalar>&);
376 
377  virtual void operator+=(const Field<Type>&);
378  virtual void operator-=(const Field<Type>&);
379 
380  virtual void operator*=(const Field<scalar>&);
381  virtual void operator/=(const Field<scalar>&);
382 
383  virtual void operator=(const Type&);
384  virtual void operator+=(const Type&);
385  virtual void operator-=(const Type&);
386  virtual void operator*=(const scalar);
387  virtual void operator/=(const scalar);
388 
389 
390  // Force an assignment irrespective of form of patch
391 
392  virtual void operator==(const fvsPatchField<Type>&);
393  virtual void operator==(const Field<Type>&);
394  virtual void operator==(const Type&);
395 
396 
397  // Ostream operator
398 
399  friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
400 };
401 
402 
403 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
404 
405 } // End namespace Foam
406 
407 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
408 
409 #ifdef NoRepository
410  #include "fvsPatchField.C"
411  #include "calculatedFvsPatchField.H"
412 #endif
413 
415 #define makeFvsPatchField(fvsPatchTypeField) \
416  \
417 defineNamedTemplateTypeNameAndDebug(fvsPatchTypeField, 0); \
418 template<> \
419 int fvsPatchTypeField::disallowGenericFvsPatchField \
420 ( \
421  debug::debugSwitch("disallowGenericFvsPatchField", 0) \
422 ); \
423 defineTemplateRunTimeSelectionTable(fvsPatchTypeField, patch); \
424 defineTemplateRunTimeSelectionTable(fvsPatchTypeField, patchMapper); \
425 defineTemplateRunTimeSelectionTable(fvsPatchTypeField, dictionary);
426 
428 #define addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
429  addToRunTimeSelectionTable \
430  ( \
431  PatchTypeField, \
432  typePatchTypeField, \
433  patch \
434  ); \
435  addToRunTimeSelectionTable \
436  ( \
437  PatchTypeField, \
438  typePatchTypeField, \
439  patchMapper \
440  ); \
441  addToRunTimeSelectionTable \
442  ( \
443  PatchTypeField, \
444  typePatchTypeField, \
445  dictionary \
446  );
447 
448 
449 // For non-templated patch fields
450 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
451  defineTypeNameAndDebug(typePatchTypeField, 0); \
452  addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
453 
454 // For templated patch fields
455 #define makeTemplateFvsPatchTypeField(fieldType, type) \
456  defineNamedTemplateTypeNameAndDebug \
457  ( \
458  CAT4(type, FvsPatch, CAPITALIZE(fieldType), Field), \
459  0 \
460  ); \
461  addToPatchFieldRunTimeSelection \
462  ( \
463  CAT3(fvsPatch, CAPITALIZE(fieldType), Field), \
464  CAT4(type, FvsPatch, CAPITALIZE(fieldType), Field) \
465  )
467 #define makeFvsPatchFields(type) \
468  FOR_ALL_FIELD_TYPES(makeTemplateFvsPatchTypeField, type)
470 #define makeFvsPatchFieldTypeName(fieldType, type) \
471  defineNamedTemplateTypeNameAndDebug \
472  ( \
473  CAT4(type, FvsPatch, CAPITALIZE(fieldType), Field), \
474  0 \
475  );
477 #define makeFvsPatchFieldTypeNames(type) \
478  FOR_ALL_FIELD_TYPES(makeFvsPatchFieldTypeName, type)
480 #define makeFvsPatchTypeFieldTypedef(fieldType, type) \
481  typedef type##FvsPatchField<fieldType> \
482  CAT4(type, FvsPatch, CAPITALIZE(fieldType), Field);
484 #define makeFvsPatchTypeFieldTypedefs(type) \
485  FOR_ALL_FIELD_TYPES(makeFvsPatchTypeFieldTypedef, type)
486 
487 
488 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
489 
490 #endif
491 
492 // ************************************************************************* //
virtual void operator*=(const fvsPatchField< scalar > &)
dictionary dict
virtual bool fixesValue() const
Return true if this patch field fixes a value.
virtual void write(Ostream &) const
Write.
TypeName("fvsPatchField")
Runtime type information.
const Field< Type > & primitiveField() const
Return internal field reference.
const objectRegistry & db() const
Return local objectRegistry.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void operator==(const fvsPatchField< Type > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
static tmp< fvsPatchField< Type > > NewCalculatedType(const fvPatch &)
Return a pointer to a new calculatedFvsPatchField created on.
calculatedFvsPatchField< Type > Calculated
Definition: fvsPatchField.H:95
virtual void operator/=(const fvsPatchField< scalar > &)
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
Pre-declare SubField and related Field type.
Definition: Field.H:56
tmp< fvsPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
virtual bool coupled() const
Return true if this patch field is coupled.
A class for handling words, derived from string.
Definition: word.H:59
bool overridesConstraint() const
Return true if this overrides the underlying constraint type.
void check(const fvsPatchField< Type > &) const
Check fvsPatchField<Type> against given fvsPatchField<Type>
Foam::fvPatchFieldMapper.
declareRunTimeSelectionTable(tmp, fvsPatchField, patch,(const fvPatch &p, const DimensionedField< Type, surfaceMesh > &iF),(p, iF))
fvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
Definition: fvsPatchField.C:35
virtual void operator-=(const fvsPatchField< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
const fvPatch & patch() const
Return patch.
virtual void operator+=(const fvsPatchField< Type > &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void operator=(const UList< Type > &)
Foam::calculatedFvsPatchField.
const DimensionedField< Type, surfaceMesh > & internalField() const
Return dimensioned internal field reference.
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
static const word & calculatedType()
Return the type of the calculated for of fvsPatchField.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
static int disallowGenericFvsPatchField
Debug switch to disallow the use of genericFvsPatchField.
Namespace for OpenFOAM.