1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 An abstract base class with a fat-interface to all derived classes
30 covering all possible ways in which they might be used.
32 The first level of derivation is to basic patchFields which cover
33 zero-gradient, fixed-gradient, fixed-value and mixed conditions.
35 The next level of derivation covers all the specialised typed with
36 specific evaluation proceedures, particularly with respect to specific
43 \*---------------------------------------------------------------------------*/
45 #ifndef fvsPatchField_H
46 #define fvsPatchField_H
49 #include "DimensionedField.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 // Forward declaration of classes
60 class fvPatchFieldMapper;
64 // Forward declaration of friend functions and operators
70 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
73 /*---------------------------------------------------------------------------*\
74 Class patch Declaration
75 \*---------------------------------------------------------------------------*/
84 //- Reference to patch
85 const fvPatch& patch_;
87 //- Reference to internal field
88 const DimensionedField<Type, surfaceMesh>& internalField_;
93 typedef fvPatch Patch;
96 //- Runtime type information
97 TypeName("fvsPatchField");
99 //- Debug switch to disallow the use of
100 static int disallowDefaultFvsPatchField;
103 // Declare run-time constructor selection tables
106 declareRunTimeSelectionTable
113 const DimensionedField<Type, surfaceMesh>& iF
118 declareRunTimeSelectionTable
124 const fvsPatchField<Type>& ptf,
126 const DimensionedField<Type, surfaceMesh>& iF,
127 const fvPatchFieldMapper& m
129 (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
132 declareRunTimeSelectionTable
139 const DimensionedField<Type, surfaceMesh>& iF,
140 const dictionary& dict
148 //- Construct from patch and internal field
152 const DimensionedField<Type, surfaceMesh>&
155 //- Construct from patch and internal field and patch field
159 const DimensionedField<Type, surfaceMesh>&,
163 //- Construct from patch, internal field and dictionary
167 const DimensionedField<Type, surfaceMesh>&,
169 const bool valueRequired = false
172 //- Construct by mapping the given fvsPatchField onto a new patch
175 const fvsPatchField<Type>&,
177 const DimensionedField<Type, surfaceMesh>&,
178 const fvPatchFieldMapper&
181 //- Construct as copy
182 fvsPatchField(const fvsPatchField<Type>&);
184 //- Construct and return a clone
185 virtual tmp<fvsPatchField<Type> > clone() const
187 return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
190 //- Construct as copy setting internal field reference
193 const fvsPatchField<Type>&,
194 const DimensionedField<Type, surfaceMesh>&
197 //- Construct and return a clone setting internal field reference
198 virtual tmp<fvsPatchField<Type> > clone
200 const DimensionedField<Type, surfaceMesh>& iF
203 return tmp<fvsPatchField<Type> >
205 new fvsPatchField<Type>(*this, iF)
212 //- Return a pointer to a new patchField created on freestore given
213 // patch and internal field
214 // (does not set the patch field values)
215 static tmp<fvsPatchField<Type> > New
219 const DimensionedField<Type, surfaceMesh>&
222 //- Return a pointer to a new patchField created on freestore from
223 // a given fvsPatchField mapped onto a new patch
224 static tmp<fvsPatchField<Type> > New
226 const fvsPatchField<Type>&,
228 const DimensionedField<Type, surfaceMesh>&,
229 const fvPatchFieldMapper&
232 //- Return a pointer to a new patchField created on freestore
234 static tmp<fvsPatchField<Type> > New
237 const DimensionedField<Type, surfaceMesh>&,
241 //- Return a pointer to a new calculatedFvsPatchField created on
242 // freestore without setting patchField values
243 template<class Type2>
244 static tmp<fvsPatchField<Type> > NewCalculatedType
246 const fvsPatchField<Type2>&
252 virtual ~fvsPatchField<Type>()
260 //- Return local objectRegistry
261 const objectRegistry& db() const;
264 const fvPatch& patch() const
269 //- Return dimensioned internal field reference
270 const DimensionedField<Type, surfaceMesh>&
271 dimensionedInternalField() const
273 return internalField_;
276 //- Return internal field reference
277 const Field<Type>& internalField() const
279 return internalField_;
282 //- Return the type of the calculated for of fvsPatchField
283 static const word& calculatedType();
285 //- Return true if this patch field fixes a value.
286 // Needed to check if a level has to be specified while solving
287 // Poissons equations.
288 virtual bool fixesValue() const
293 //- Return true if this patch field is coupled
294 virtual bool coupled() const
302 //- Map (and resize as needed) from self given a mapping object
305 const fvPatchFieldMapper&
308 //- Reverse map the given fvsPatchField onto this fvsPatchField
311 const fvsPatchField<Type>&,
317 virtual void write(Ostream&) const;
322 //- Check fvsPatchField<Type> against given fvsPatchField<Type>
323 void check(const fvsPatchField<Type>&) const;
328 virtual void operator=(const UList<Type>&);
330 virtual void operator=(const fvsPatchField<Type>&);
331 virtual void operator+=(const fvsPatchField<Type>&);
332 virtual void operator-=(const fvsPatchField<Type>&);
333 virtual void operator*=(const fvsPatchField<scalar>&);
334 virtual void operator/=(const fvsPatchField<scalar>&);
336 virtual void operator+=(const Field<Type>&);
337 virtual void operator-=(const Field<Type>&);
339 virtual void operator*=(const Field<scalar>&);
340 virtual void operator/=(const Field<scalar>&);
342 virtual void operator=(const Type&);
343 virtual void operator+=(const Type&);
344 virtual void operator-=(const Type&);
345 virtual void operator*=(const scalar);
346 virtual void operator/=(const scalar);
349 // Force an assignment irrespective of form of patch
351 virtual void operator==(const fvsPatchField<Type>&);
352 virtual void operator==(const Field<Type>&);
353 virtual void operator==(const Type&);
359 friend Ostream& operator<< <Type>
362 const fvsPatchField<Type>&
368 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 } // End namespace Foam
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 # include "fvsPatchField.C"
376 # include "calculatedFvsPatchField.H"
380 #define makeFvsPatchTypeFieldTypeName(type) \
382 defineNamedTemplateTypeNameAndDebug(type, 0);
384 #define makeFvsPatchFieldsTypeName(type) \
386 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
387 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
388 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
389 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
390 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
392 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
394 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
396 addToRunTimeSelectionTable \
398 PatchTypeField, typePatchTypeField, patch \
401 addToRunTimeSelectionTable \
404 typePatchTypeField, \
408 addToRunTimeSelectionTable \
410 PatchTypeField, typePatchTypeField, dictionary \
414 #define makeFvsPatchFields(type) \
416 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
417 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
418 makeFvsPatchTypeField \
420 fvsPatchSphericalTensorField, \
421 type##FvsPatchSphericalTensorField \
423 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
424 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
427 #define makeFvsPatchTypeFieldTypedefs(type) \
429 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
430 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
431 typedef type##FvsPatchField<sphericalTensor> \
432 type##FvsPatchSphericalTensorField; \
433 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
434 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
437 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441 // ************************************************************************* //