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 | Copyright (C) 2011-2016 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 proceedures, 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  //- Construct as copy
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  //- Construct as copy 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  virtual void autoMap
323  (
324  const fvPatchFieldMapper&
325  );
326 
327  //- Reverse map the given fvsPatchField onto this fvsPatchField
328  virtual void rmap
329  (
330  const fvsPatchField<Type>&,
331  const labelList&
332  );
333 
334 
335  //- Write
336  virtual void write(Ostream&) const;
337 
338 
339  // Check
340 
341  //- Check fvsPatchField<Type> against given fvsPatchField<Type>
342  void check(const fvsPatchField<Type>&) const;
343 
344 
345  // Member operators
346 
347  virtual void operator=(const UList<Type>&);
348 
349  virtual void operator=(const fvsPatchField<Type>&);
350  virtual void operator+=(const fvsPatchField<Type>&);
351  virtual void operator-=(const fvsPatchField<Type>&);
352  virtual void operator*=(const fvsPatchField<scalar>&);
353  virtual void operator/=(const fvsPatchField<scalar>&);
354 
355  virtual void operator+=(const Field<Type>&);
356  virtual void operator-=(const Field<Type>&);
357 
358  virtual void operator*=(const Field<scalar>&);
359  virtual void operator/=(const Field<scalar>&);
360 
361  virtual void operator=(const Type&);
362  virtual void operator+=(const Type&);
363  virtual void operator-=(const Type&);
364  virtual void operator*=(const scalar);
365  virtual void operator/=(const scalar);
366 
367 
368  // Force an assignment irrespective of form of patch
369 
370  virtual void operator==(const fvsPatchField<Type>&);
371  virtual void operator==(const Field<Type>&);
372  virtual void operator==(const Type&);
373 
374 
375  // Ostream operator
376 
377  friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
378 };
379 
380 
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382 
383 } // End namespace Foam
384 
385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
386 
387 #ifdef NoRepository
388  #include "fvsPatchField.C"
389  #include "calculatedFvsPatchField.H"
390 #endif
391 
393 #define makeFvsPatchTypeFieldTypeName(type) \
394  \
395 defineNamedTemplateTypeNameAndDebug(type, 0);
397 #define makeFvsPatchFieldsTypeName(type) \
398  \
399 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
400 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
401 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
402 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
403 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
405 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
406  \
407 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
408  \
409 addToRunTimeSelectionTable \
410 ( \
411  PatchTypeField, typePatchTypeField, patch \
412 ); \
413  \
414 addToRunTimeSelectionTable \
415 ( \
416  PatchTypeField, \
417  typePatchTypeField, \
418  patchMapper \
419 ); \
420  \
421 addToRunTimeSelectionTable \
422 ( \
423  PatchTypeField, typePatchTypeField, dictionary \
424 );
425 
427 #define makeFvsPatchFields(type) \
428  \
429 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
430 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
431 makeFvsPatchTypeField \
432 ( \
433  fvsPatchSphericalTensorField, \
434  type##FvsPatchSphericalTensorField \
435 ); \
436 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
437 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
438 
440 #define makeFvsPatchTypeFieldTypedefs(type) \
441  \
442 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
443 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
444 typedef type##FvsPatchField<sphericalTensor> \
445  type##FvsPatchSphericalTensorField; \
446 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
447 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
448 
449 
450 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
451 
452 #endif
453 
454 // ************************************************************************* //
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:137
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:57
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.