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-2019 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  //- Copy constructor
184 
185  //- Construct and return a clone
186  virtual tmp<fvsPatchField<Type>> clone() const
187  {
188  return tmp<fvsPatchField<Type>>(new fvsPatchField<Type>(*this));
189  }
190 
191  //- Copy constructor setting internal field reference
193  (
194  const fvsPatchField<Type>&,
196  );
197 
198  //- Construct and return a clone setting internal field reference
200  (
202  ) const
203  {
205  (
206  new fvsPatchField<Type>(*this, iF)
207  );
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>()
272  {}
273 
274 
275  // Member Functions
276 
277  // Access
278 
279  //- Return local objectRegistry
280  const objectRegistry& db() const;
281 
282  //- Return patch
283  const fvPatch& patch() const
284  {
285  return patch_;
286  }
287 
288  //- Return dimensioned internal field reference
290  internalField() const
291  {
292  return internalField_;
293  }
294 
295  //- Return internal field reference
296  const Field<Type>& primitiveField() const
297  {
298  return internalField_;
299  }
300 
301  //- Return the type of the calculated for of fvsPatchField
302  static const word& calculatedType();
303 
304  //- Return true if this patch field fixes a value.
305  // Needed to check if a level has to be specified while solving
306  // Poissons equations.
307  virtual bool fixesValue() const
308  {
309  return false;
310  }
311 
312  //- Return true if this patch field is coupled
313  virtual bool coupled() const
314  {
315  return false;
316  }
317 
318 
319  // Mapping functions
320 
321  //- Map (and resize as needed) from self given a mapping object
322  // Used to update fields following mesh topology change
323  virtual void autoMap(const fvPatchFieldMapper&);
324 
325  //- Reverse map the given fvsPatchField onto this fvsPatchField
326  // Used to reconstruct fields
327  virtual void rmap(const fvsPatchField<Type>&, const labelList&);
328 
329 
330  //- Write
331  virtual void write(Ostream&) const;
332 
333 
334  // Check
335 
336  //- Check fvsPatchField<Type> against given fvsPatchField<Type>
337  void check(const fvsPatchField<Type>&) const;
338 
339 
340  // Member Operators
341 
342  virtual void operator=(const UList<Type>&);
343 
344  virtual void operator=(const fvsPatchField<Type>&);
345  virtual void operator+=(const fvsPatchField<Type>&);
346  virtual void operator-=(const fvsPatchField<Type>&);
347  virtual void operator*=(const fvsPatchField<scalar>&);
348  virtual void operator/=(const fvsPatchField<scalar>&);
349 
350  virtual void operator+=(const Field<Type>&);
351  virtual void operator-=(const Field<Type>&);
352 
353  virtual void operator*=(const Field<scalar>&);
354  virtual void operator/=(const Field<scalar>&);
355 
356  virtual void operator=(const Type&);
357  virtual void operator+=(const Type&);
358  virtual void operator-=(const Type&);
359  virtual void operator*=(const scalar);
360  virtual void operator/=(const scalar);
361 
362 
363  // Force an assignment irrespective of form of patch
364 
365  virtual void operator==(const fvsPatchField<Type>&);
366  virtual void operator==(const Field<Type>&);
367  virtual void operator==(const Type&);
368 
369 
370  // Ostream operator
371 
372  friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
373 };
374 
375 
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 
378 } // End namespace Foam
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 #ifdef NoRepository
383  #include "fvsPatchField.C"
384  #include "calculatedFvsPatchField.H"
385 #endif
386 
388 #define makeFvsPatchTypeFieldTypeName(type) \
389  \
390 defineNamedTemplateTypeNameAndDebug(type, 0);
392 #define makeFvsPatchFieldsTypeName(type) \
393  \
394 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
395 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
396 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
397 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
398 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
400 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
401  \
402 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
403  \
404 addToRunTimeSelectionTable \
405 ( \
406  PatchTypeField, typePatchTypeField, patch \
407 ); \
408  \
409 addToRunTimeSelectionTable \
410 ( \
411  PatchTypeField, \
412  typePatchTypeField, \
413  patchMapper \
414 ); \
415  \
416 addToRunTimeSelectionTable \
417 ( \
418  PatchTypeField, typePatchTypeField, dictionary \
419 );
420 
422 #define makeFvsPatchFields(type) \
423  \
424 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
425 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
426 makeFvsPatchTypeField \
427 ( \
428  fvsPatchSphericalTensorField, \
429  type##FvsPatchSphericalTensorField \
430 ); \
431 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
432 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
433 
435 #define makeFvsPatchTypeFieldTypedefs(type) \
436  \
437 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
438 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
439 typedef type##FvsPatchField<sphericalTensor> \
440  type##FvsPatchSphericalTensorField; \
441 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
442 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
443 
444 
445 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
446 
447 #endif
448 
449 // ************************************************************************* //
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:158
virtual void operator==(const fvsPatchField< Type > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
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
virtual bool coupled() const
Return true if this patch field is coupled.
A class for handling words, derived from string.
Definition: word.H:59
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:53
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 > &)
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.
virtual tmp< fvsPatchField< Type > > clone() const
Construct and return a clone.
Namespace for OpenFOAM.