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-2012 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 
72 /*---------------------------------------------------------------------------*\
73  Class patch Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class Type>
77 class fvsPatchField
78 :
79  public Field<Type>
80 {
81  // Private data
82 
83  //- Reference to patch
84  const fvPatch& patch_;
85 
86  //- Reference to internal field
88 
89 
90 public:
91 
92  typedef fvPatch Patch;
93 
94 
95  //- Runtime type information
96  TypeName("fvsPatchField");
97 
98  //- Debug switch to disallow the use of genericFvsPatchField
100 
101 
102  // Declare run-time constructor selection tables
103 
105  (
106  tmp,
108  patch,
109  (
110  const fvPatch& p,
112  ),
113  (p, iF)
114  );
115 
117  (
118  tmp,
120  patchMapper,
121  (
122  const fvsPatchField<Type>& ptf,
123  const fvPatch& p,
125  const fvPatchFieldMapper& m
126  ),
127  (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
128  );
129 
131  (
132  tmp,
134  dictionary,
135  (
136  const fvPatch& p,
138  const dictionary& dict
139  ),
140  (p, iF, dict)
141  );
142 
143 
144  // Constructors
145 
146  //- Construct from patch and internal field
148  (
149  const fvPatch&,
151  );
152 
153  //- Construct from patch and internal field and patch field
155  (
156  const fvPatch&,
158  const Field<Type>&
159  );
160 
161  //- Construct from patch, internal field and dictionary
163  (
164  const fvPatch&,
166  const dictionary&
167  );
168 
169  //- Construct by mapping the given fvsPatchField onto a new patch
171  (
172  const fvsPatchField<Type>&,
173  const fvPatch&,
175  const fvPatchFieldMapper&
176  );
177 
178  //- Construct as copy
180 
181  //- Construct and return a clone
182  virtual tmp<fvsPatchField<Type> > clone() const
183  {
184  return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
185  }
186 
187  //- Construct as copy setting internal field reference
189  (
190  const fvsPatchField<Type>&,
192  );
193 
194  //- Construct and return a clone setting internal field reference
196  (
198  ) const
199  {
200  return tmp<fvsPatchField<Type> >
201  (
202  new fvsPatchField<Type>(*this, iF)
203  );
204  }
205 
206 
207  // Selectors
208 
209  //- Return a pointer to a new patchField created on freestore given
210  // patch and internal field
211  // (does not set the patch field values)
213  (
214  const word&,
215  const fvPatch&,
217  );
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)
222  // Allows override of constraint type
224  (
225  const word&,
226  const word& actualPatchType,
227  const fvPatch&,
229  );
230 
231  //- Return a pointer to a new patchField created on freestore from
232  // a given fvsPatchField mapped onto a new patch
234  (
235  const fvsPatchField<Type>&,
236  const fvPatch&,
238  const fvPatchFieldMapper&
239  );
240 
241  //- Return a pointer to a new patchField created on freestore
242  // from dictionary
244  (
245  const fvPatch&,
247  const dictionary&
248  );
249 
250  //- Return a pointer to a new calculatedFvsPatchField created on
251  // freestore without setting patchField values
253  (
254  const fvPatch&
255  );
256 
257  //- Return a pointer to a new calculatedFvsPatchField created on
258  // freestore without setting patchField values
259  template<class Type2>
261  (
262  const fvsPatchField<Type2>&
263  );
264 
265 
266  //- Destructor
267  virtual ~fvsPatchField<Type>()
268  {}
269 
270 
271  // Member functions
272 
273  // Access
274 
275  //- Return local objectRegistry
276  const objectRegistry& db() const;
277 
278  //- Return patch
279  const fvPatch& patch() const
280  {
281  return patch_;
282  }
283 
284  //- Return dimensioned internal field reference
287  {
288  return internalField_;
289  }
290 
291  //- Return internal field reference
292  const Field<Type>& internalField() const
293  {
294  return internalField_;
295  }
296 
297  //- Return the type of the calculated for of fvsPatchField
298  static const word& calculatedType();
299 
300  //- Return true if this patch field fixes a value.
301  // Needed to check if a level has to be specified while solving
302  // Poissons equations.
303  virtual bool fixesValue() const
304  {
305  return false;
306  }
307 
308  //- Return true if this patch field is coupled
309  virtual bool coupled() const
310  {
311  return false;
312  }
313 
314 
315  // Mapping functions
316 
317  //- Map (and resize as needed) from self given a mapping object
318  virtual void autoMap
319  (
320  const fvPatchFieldMapper&
321  );
322 
323  //- Reverse map the given fvsPatchField onto this fvsPatchField
324  virtual void rmap
325  (
326  const fvsPatchField<Type>&,
327  const labelList&
328  );
329 
330 
331  //- Write
332  virtual void write(Ostream&) const;
333 
334 
335  // Check
336 
337  //- Check fvsPatchField<Type> against given fvsPatchField<Type>
338  void check(const fvsPatchField<Type>&) const;
339 
340 
341  // Member operators
342 
343  virtual void operator=(const UList<Type>&);
344 
345  virtual void operator=(const fvsPatchField<Type>&);
346  virtual void operator+=(const fvsPatchField<Type>&);
347  virtual void operator-=(const fvsPatchField<Type>&);
348  virtual void operator*=(const fvsPatchField<scalar>&);
349  virtual void operator/=(const fvsPatchField<scalar>&);
350 
351  virtual void operator+=(const Field<Type>&);
352  virtual void operator-=(const Field<Type>&);
353 
354  virtual void operator*=(const Field<scalar>&);
355  virtual void operator/=(const Field<scalar>&);
356 
357  virtual void operator=(const Type&);
358  virtual void operator+=(const Type&);
359  virtual void operator-=(const Type&);
360  virtual void operator*=(const scalar);
361  virtual void operator/=(const scalar);
362 
363 
364  // Force an assignment irrespective of form of patch
365 
366  virtual void operator==(const fvsPatchField<Type>&);
367  virtual void operator==(const Field<Type>&);
368  virtual void operator==(const Type&);
369 
370 
371  // Ostream operator
372 
373  friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
374 };
375 
376 
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378 
379 } // End namespace Foam
380 
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382 
383 #ifdef NoRepository
384 # include "fvsPatchField.C"
385 # include "calculatedFvsPatchField.H"
386 #endif
387 
388 
389 #define makeFvsPatchTypeFieldTypeName(type) \
390  \
391 defineNamedTemplateTypeNameAndDebug(type, 0);
392 
393 #define makeFvsPatchFieldsTypeName(type) \
394  \
395 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
396 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
397 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
398 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
399 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
400 
401 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
402  \
403 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
404  \
405 addToRunTimeSelectionTable \
406 ( \
407  PatchTypeField, typePatchTypeField, patch \
408 ); \
409  \
410 addToRunTimeSelectionTable \
411 ( \
412  PatchTypeField, \
413  typePatchTypeField, \
414  patchMapper \
415 ); \
416  \
417 addToRunTimeSelectionTable \
418 ( \
419  PatchTypeField, typePatchTypeField, dictionary \
420 );
421 
422 
423 #define makeFvsPatchFields(type) \
424  \
425 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
426 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
427 makeFvsPatchTypeField \
428 ( \
429  fvsPatchSphericalTensorField, \
430  type##FvsPatchSphericalTensorField \
431 ); \
432 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
433 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
434 
435 
436 #define makeFvsPatchTypeFieldTypedefs(type) \
437  \
438 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
439 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
440 typedef type##FvsPatchField<sphericalTensor> \
441  type##FvsPatchSphericalTensorField; \
442 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
443 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
444 
445 
446 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
447 
448 #endif
449 
450 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvsPatchField::patch_
const fvPatch & patch_
Reference to patch.
Definition: fvsPatchField.H:83
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::fvsPatchField::operator-=
virtual void operator-=(const fvsPatchField< Type > &)
DimensionedField.H
Foam::fvsPatchField::Patch
fvPatch Patch
Definition: fvsPatchField.H:91
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::fvsPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvsPatchField.C:138
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::fvsPatchField::calculatedType
static const word & calculatedType()
Return the type of the calculated for of fvsPatchField.
Definition: calculatedFvsPatchField.C:35
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fvsPatchField::disallowGenericFvsPatchField
static int disallowGenericFvsPatchField
Debug switch to disallow the use of genericFvsPatchField.
Definition: fvsPatchField.H:98
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
calculatedFvsPatchField.H
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.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvsPatchField::clone
virtual tmp< fvsPatchField< Type > > clone() const
Construct and return a clone.
Definition: fvsPatchField.H:181
Foam::fvsPatchField::internalField_
const DimensionedField< Type, surfaceMesh > & internalField_
Reference to internal field.
Definition: fvsPatchField.H:86
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fvsPatchField::internalField
const Field< Type > & internalField() const
Return internal field reference.
Definition: fvsPatchField.H:291
Foam::fvsPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::fvsPatchField::fvsPatchField
fvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
Foam::fvsPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvsPatchField.C:181
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fvsPatchField::dimensionedInternalField
const DimensionedField< Type, surfaceMesh > & dimensionedInternalField() const
Return dimensioned internal field reference.
Definition: fvsPatchField.H:285
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:278
Foam::fvsPatchField::operator/=
virtual void operator/=(const fvsPatchField< scalar > &)
Foam::fvsPatchField::NewCalculatedType
static tmp< fvsPatchField< Type > > NewCalculatedType(const fvPatch &)
Return a pointer to a new calculatedFvsPatchField created on.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::fvsPatchField::rmap
virtual void rmap(const fvsPatchField< Type > &, const labelList &)
Reverse map the given fvsPatchField onto this fvsPatchField.
Definition: fvsPatchField.C:170
Foam::UList< Type >
Foam::fvsPatchField::operator==
virtual void operator==(const fvsPatchField< Type > &)
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
fvPatch.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fvsPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvsPatchField.C:159
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:308
Foam::fvsPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: fvsPatchField.H:302
Foam::fvsPatchField::check
void check(const fvsPatchField< Type > &) const
Check fvsPatchField<Type> against given fvsPatchField<Type>
Definition: fvsPatchField.C:145
Foam::fvsPatchField::operator*=
virtual void operator*=(const fvsPatchField< scalar > &)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::fvsPatchField::operator+=
virtual void operator+=(const fvsPatchField< Type > &)