fvsPatchField.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) 2011-2016 OpenFOAM Foundation
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::fvsPatchField
29 
30 Description
31  An abstract base class with a fat-interface to all derived classes
32  covering all possible ways in which they might be used.
33 
34  The first level of derivation is to basic patchFields which cover
35  zero-gradient, fixed-gradient, fixed-value and mixed conditions.
36 
37  The next level of derivation covers all the specialised typed with
38  specific evaluation procedures, particularly with respect to specific
39  fields.
40 
41 SourceFiles
42  fvsPatchField.C
43  fvsPatchFieldNew.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef fvsPatchField_H
48 #define fvsPatchField_H
49 
50 #include "fvPatch.H"
51 #include "DimensionedField.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward declaration of classes
59 
60 class objectRegistry;
61 class dictionary;
62 class fvPatchFieldMapper;
63 class surfaceMesh;
64 
65 
66 // Forward declaration of friend functions and operators
67 
68 template<class Type>
69 class fvsPatchField;
70 
71 template<class Type>
73 
74 template<class Type>
76 
77 
78 /*---------------------------------------------------------------------------*\
79  Class patch Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 template<class Type>
83 class fvsPatchField
84 :
85  public Field<Type>
86 {
87  // Private data
88 
89  //- Reference to patch
90  const fvPatch& patch_;
91 
92  //- Reference to internal field
93  const DimensionedField<Type, surfaceMesh>& internalField_;
94 
95 
96 public:
97 
98  typedef fvPatch Patch;
100 
101 
102  //- Runtime type information
103  TypeName("fvsPatchField");
104 
105  //- Debug switch to disallow the use of genericFvsPatchField
106  static int disallowGenericFvsPatchField;
107 
108 
109  // Declare run-time constructor selection tables
110 
112  (
113  tmp,
115  patch,
116  (
117  const fvPatch& p,
119  ),
120  (p, iF)
121  );
122 
124  (
125  tmp,
127  patchMapper,
128  (
129  const fvsPatchField<Type>& ptf,
130  const fvPatch& p,
132  const fvPatchFieldMapper& m
133  ),
134  (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
135  );
136 
138  (
139  tmp,
141  dictionary,
142  (
143  const fvPatch& p,
145  const dictionary& dict
146  ),
147  (p, iF, dict)
148  );
149 
150 
151  // Constructors
152 
153  //- Construct from patch and internal field
155  (
156  const fvPatch&,
158  );
159 
160  //- Construct from patch and internal field and patch field
162  (
163  const fvPatch&,
165  const Field<Type>&
166  );
167 
168  //- Construct from patch, internal field and dictionary
170  (
171  const fvPatch&,
173  const dictionary&
174  );
175 
176  //- Construct by mapping the given fvsPatchField onto a new patch
178  (
179  const fvsPatchField<Type>&,
180  const fvPatch&,
182  const fvPatchFieldMapper&
183  );
184 
185  //- Construct as copy
187 
188  //- Construct and return a clone
189  virtual tmp<fvsPatchField<Type>> clone() const
190  {
191  return tmp<fvsPatchField<Type>>::New(*this);
192  }
193 
194  //- Construct as copy setting internal field reference
196  (
197  const fvsPatchField<Type>&,
199  );
200 
201  //- Construct and return a clone setting internal field reference
203  (
205  ) const
206  {
207  return tmp<fvsPatchField<Type>>::New(*this, iF);
208  }
209 
210 
211  // Selectors
212 
213  //- Return a pointer to a new patchField created on freestore given
214  // patch and internal field
215  // (does not set the patch field values)
217  (
218  const word&,
219  const fvPatch&,
221  );
222 
223  //- Return a pointer to a new patchField created on freestore given
224  // patch and internal field
225  // (does not set the patch field values)
226  // Allows override of constraint type
228  (
229  const word&,
230  const word& actualPatchType,
231  const fvPatch&,
233  );
234 
235  //- Return a pointer to a new patchField created on freestore from
236  // a given fvsPatchField mapped onto a new patch
238  (
239  const fvsPatchField<Type>&,
240  const fvPatch&,
242  const fvPatchFieldMapper&
243  );
244 
245  //- Return a pointer to a new patchField created on freestore
246  // from dictionary
248  (
249  const fvPatch&,
251  const dictionary&
252  );
253 
254  //- Return a pointer to a new calculatedFvsPatchField created on
255  // freestore without setting patchField values
257  (
258  const fvPatch&
259  );
260 
261  //- Return a pointer to a new calculatedFvsPatchField created on
262  // freestore without setting patchField values
263  template<class Type2>
265  (
266  const fvsPatchField<Type2>&
267  );
268 
269 
270  //- Destructor
271  virtual ~fvsPatchField<Type>() = default;
272 
273 
274  // Member functions
275 
276  // Access
277 
278  //- Return local objectRegistry
279  const objectRegistry& db() const;
280 
281  //- Return patch
282  const fvPatch& patch() const
283  {
284  return patch_;
285  }
286 
287  //- Return dimensioned internal field reference
289  {
290  return internalField_;
291  }
292 
293  //- Return internal field reference
294  const Field<Type>& primitiveField() const
295  {
296  return internalField_;
297  }
298 
299  //- Return the type of the calculated for of fvsPatchField
300  static const word& calculatedType();
301 
302  //- Return true if this patch field fixes a value.
303  // Needed to check if a level has to be specified while solving
304  // Poissons equations.
305  virtual bool fixesValue() const
306  {
307  return false;
308  }
309 
310  //- Return true if this patch field is coupled
311  virtual bool coupled() const
312  {
313  return false;
314  }
315 
316 
317  // Mapping functions
318 
319  //- Map (and resize as needed) from self given a mapping object
320  virtual void autoMap
321  (
322  const fvPatchFieldMapper&
323  );
324 
325  //- Reverse map the given fvsPatchField onto this fvsPatchField
326  virtual void rmap
327  (
328  const fvsPatchField<Type>&,
329  const labelList&
330  );
331 
332 
333  //- Write
334  virtual void write(Ostream&) const;
335 
336 
337  // Check
338 
339  //- Check fvsPatchField<Type> against given fvsPatchField<Type>
340  void check(const fvsPatchField<Type>&) const;
341 
342 
343  // Member operators
344 
345  virtual void operator=(const UList<Type>&);
346 
347  virtual void operator=(const fvsPatchField<Type>&);
348  virtual void operator+=(const fvsPatchField<Type>&);
349  virtual void operator-=(const fvsPatchField<Type>&);
350  virtual void operator*=(const fvsPatchField<scalar>&);
351  virtual void operator/=(const fvsPatchField<scalar>&);
352 
353  virtual void operator+=(const Field<Type>&);
354  virtual void operator-=(const Field<Type>&);
355 
356  virtual void operator*=(const Field<scalar>&);
357  virtual void operator/=(const Field<scalar>&);
358 
359  virtual void operator=(const Type&);
360  virtual void operator+=(const Type&);
361  virtual void operator-=(const Type&);
362  virtual void operator*=(const scalar);
363  virtual void operator/=(const scalar);
364 
365 
366  // Force an assignment irrespective of form of patch
367 
368  virtual void operator==(const fvsPatchField<Type>&);
369  virtual void operator==(const Field<Type>&);
370  virtual void operator==(const Type&);
371 
372 
373  // Ostream operator
374 
375  friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
376 };
377 
378 
379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 
381 } // End namespace Foam
382 
383 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
384 
385 #ifdef NoRepository
386  #include "fvsPatchField.C"
387  #include "calculatedFvsPatchField.H"
388 #endif
389 
390 
391 #define makeFvsPatchTypeFieldTypeName(type) \
392  \
393 defineNamedTemplateTypeNameAndDebug(type, 0);
394 
395 #define makeFvsPatchFieldsTypeName(type) \
396  \
397 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
398 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
399 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
400 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
401 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
402 
403 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
404  \
405 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
406  \
407 addToRunTimeSelectionTable \
408 ( \
409  PatchTypeField, typePatchTypeField, patch \
410 ); \
411  \
412 addToRunTimeSelectionTable \
413 ( \
414  PatchTypeField, \
415  typePatchTypeField, \
416  patchMapper \
417 ); \
418  \
419 addToRunTimeSelectionTable \
420 ( \
421  PatchTypeField, typePatchTypeField, dictionary \
422 );
423 
424 
425 #define makeFvsPatchFields(type) \
426  \
427 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
428 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
429 makeFvsPatchTypeField \
430 ( \
431  fvsPatchSphericalTensorField, \
432  type##FvsPatchSphericalTensorField \
433 ); \
434 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
435 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
436 
437 
438 #define makeFvsPatchTypeFieldTypedefs(type) \
439  \
440 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
441 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
442 typedef type##FvsPatchField<sphericalTensor> \
443  type##FvsPatchSphericalTensorField; \
444 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
445 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
446 
447 
448 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
449 
450 #endif
451 
452 // ************************************************************************* //
Foam::fvsPatchField::operator==
virtual void operator==(const fvsPatchField< Type > &)
Definition: fvsPatchField.C:347
Foam::fvsPatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: fvsPatchField.C:181
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::fvsPatchField::calculatedType
static const word & calculatedType()
Return the type of the calculated for of fvsPatchField.
Definition: calculatedFvsPatchField.C:35
Foam::fvsPatchField::operator-=
virtual void operator-=(const fvsPatchField< Type > &)
Definition: fvsPatchField.C:213
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fvsPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvsPatchField.C:132
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
DimensionedField.H
Foam::fvsPatchField::Patch
fvPatch Patch
Definition: fvsPatchField.H:97
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
Foam::calculatedFvsPatchField
Foam::calculatedFvsPatchField.
Definition: calculatedFvsPatchField.H:51
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::fvsPatchField::internalField
const DimensionedField< Type, surfaceMesh > & internalField() const
Return dimensioned internal field reference.
Definition: fvsPatchField.H:287
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvsPatchField::disallowGenericFvsPatchField
static int disallowGenericFvsPatchField
Debug switch to disallow the use of genericFvsPatchField.
Definition: fvsPatchField.H:105
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fvsPatchField::Calculated
calculatedFvsPatchField< Type > Calculated
Definition: fvsPatchField.H:98
calculatedFvsPatchField.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvsPatchField::clone
virtual tmp< fvsPatchField< Type > > clone() const
Construct and return a clone.
Definition: fvsPatchField.H:188
Foam::fvsPatchField::New
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
Definition: fvsPatchFieldNew.C:74
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvsPatchField::operator+=
virtual void operator+=(const fvsPatchField< Type > &)
Definition: fvsPatchField.C:202
Foam::fvsPatchField::fvsPatchField
fvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
Definition: fvsPatchField.C:39
Foam::fvsPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvsPatchField.C:170
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvsPatchField::primitiveField
const Field< Type > & primitiveField() const
Return internal field reference.
Definition: fvsPatchField.H:293
Foam::fvsPatchField::declareRunTimeSelectionTable
declareRunTimeSelectionTable(tmp, fvsPatchField, patch,(const fvPatch &p, const DimensionedField< Type, surfaceMesh > &iF),(p, iF))
Foam::fvsPatchField::TypeName
TypeName("fvsPatchField")
Runtime type information.
fvsPatchField.C
Foam::fvsPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvsPatchField.H:281
Foam::List< label >
Foam::fvsPatchField::rmap
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
Definition: fvsPatchField.C:160
Foam::UList< Type >
Foam::fvsPatchField::NewCalculatedType
static tmp< fvsPatchField< Type > > NewCalculatedType(const fvPatch &)
Return a pointer to a new calculatedFvsPatchField created on.
Definition: calculatedFvsPatchField.C:102
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
fvPatch.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fvsPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvsPatchField.C:151
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:310
Foam::fvsPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: fvsPatchField.H:304
Foam::fvsPatchField::operator/=
virtual void operator/=(const fvsPatchField< scalar > &)
Definition: fvsPatchField.C:241
Foam::fvsPatchField::check
void check(const fvsPatchField< Type > &) const
Check fvsPatchField<Type> against given fvsPatchField<Type>
Definition: fvsPatchField.C:139
Foam::fvsPatchField::operator*=
virtual void operator*=(const fvsPatchField< scalar > &)
Definition: fvsPatchField.C:224
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54