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
105 declareRunTimeSelectionTable
112 const DimensionedField<Type, surfaceMesh>& iF
117 declareRunTimeSelectionTable
123 const fvsPatchField<Type>& ptf,
125 const DimensionedField<Type, surfaceMesh>& iF,
126 const fvPatchFieldMapper& m
128 (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
131 declareRunTimeSelectionTable
138 const DimensionedField<Type, surfaceMesh>& iF,
139 const dictionary& dict
147 //- Construct from patch and internal field
151 const DimensionedField<Type, surfaceMesh>&
154 //- Construct from patch and internal field and patch field
158 const DimensionedField<Type, surfaceMesh>&,
162 //- Construct from patch, internal field and dictionary
166 const DimensionedField<Type, surfaceMesh>&,
168 const bool valueRequired = false
171 //- Construct by mapping the given fvsPatchField onto a new patch
174 const fvsPatchField<Type>&,
176 const DimensionedField<Type, surfaceMesh>&,
177 const fvPatchFieldMapper&
180 //- Construct as copy
181 fvsPatchField(const fvsPatchField<Type>&);
183 //- Construct and return a clone
184 virtual tmp<fvsPatchField<Type> > clone() const
186 return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
189 //- Construct as copy setting internal field reference
192 const fvsPatchField<Type>&,
193 const DimensionedField<Type, surfaceMesh>&
196 //- Construct and return a clone setting internal field reference
197 virtual tmp<fvsPatchField<Type> > clone
199 const DimensionedField<Type, surfaceMesh>& iF
202 return tmp<fvsPatchField<Type> >
204 new fvsPatchField<Type>(*this, iF)
211 //- Return a pointer to a new patchField created on freestore given
212 // patch and internal field
213 // (does not set the patch field values)
214 static tmp<fvsPatchField<Type> > New
218 const DimensionedField<Type, surfaceMesh>&
221 //- Return a pointer to a new patchField created on freestore from
222 // a given fvsPatchField mapped onto a new patch
223 static tmp<fvsPatchField<Type> > New
225 const fvsPatchField<Type>&,
227 const DimensionedField<Type, surfaceMesh>&,
228 const fvPatchFieldMapper&
231 //- Return a pointer to a new patchField created on freestore
233 static tmp<fvsPatchField<Type> > New
236 const DimensionedField<Type, surfaceMesh>&,
240 //- Return a pointer to a new calculatedFvsPatchField created on
241 // freestore without setting patchField values
242 template<class Type2>
243 static tmp<fvsPatchField<Type> > NewCalculatedType
245 const fvsPatchField<Type2>&
251 virtual ~fvsPatchField<Type>()
259 //- Return local objectRegistry
260 const objectRegistry& db() const;
263 const fvPatch& patch() const
268 //- Return dimensioned internal field reference
269 const DimensionedField<Type, surfaceMesh>&
270 dimensionedInternalField() const
272 return internalField_;
275 //- Return internal field reference
276 const Field<Type>& internalField() const
278 return internalField_;
281 //- Return the type of the calculated for of fvsPatchField
282 static const word& calculatedType();
284 //- Return true if this patch field fixes a value.
285 // Needed to check if a level has to be specified while solving
286 // Poissons equations.
287 virtual bool fixesValue() const
292 //- Return true if this patch field is coupled
293 virtual bool coupled() const
301 //- Map (and resize as needed) from self given a mapping object
304 const fvPatchFieldMapper&
307 //- Reverse map the given fvsPatchField onto this fvsPatchField
310 const fvsPatchField<Type>&,
316 virtual void write(Ostream&) const;
321 //- Check fvsPatchField<Type> against given fvsPatchField<Type>
322 void check(const fvsPatchField<Type>&) const;
327 virtual void operator=(const UList<Type>&);
329 virtual void operator=(const fvsPatchField<Type>&);
330 virtual void operator+=(const fvsPatchField<Type>&);
331 virtual void operator-=(const fvsPatchField<Type>&);
332 virtual void operator*=(const fvsPatchField<scalar>&);
333 virtual void operator/=(const fvsPatchField<scalar>&);
335 virtual void operator+=(const Field<Type>&);
336 virtual void operator-=(const Field<Type>&);
338 virtual void operator*=(const Field<scalar>&);
339 virtual void operator/=(const Field<scalar>&);
341 virtual void operator=(const Type&);
342 virtual void operator+=(const Type&);
343 virtual void operator-=(const Type&);
344 virtual void operator*=(const scalar);
345 virtual void operator/=(const scalar);
348 // Force an assignment irrespective of form of patch
350 virtual void operator==(const fvsPatchField<Type>&);
351 virtual void operator==(const Field<Type>&);
352 virtual void operator==(const Type&);
357 friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363 } // End namespace Foam
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 # include "fvsPatchField.C"
369 # include "calculatedFvsPatchField.H"
373 #define makeFvsPatchTypeFieldTypeName(type) \
375 defineNamedTemplateTypeNameAndDebug(type, 0);
377 #define makeFvsPatchFieldsTypeName(type) \
379 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
380 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
381 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
382 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
383 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
385 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
387 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
389 addToRunTimeSelectionTable \
391 PatchTypeField, typePatchTypeField, patch \
394 addToRunTimeSelectionTable \
397 typePatchTypeField, \
401 addToRunTimeSelectionTable \
403 PatchTypeField, typePatchTypeField, dictionary \
407 #define makeFvsPatchFields(type) \
409 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
410 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
411 makeFvsPatchTypeField \
413 fvsPatchSphericalTensorField, \
414 type##FvsPatchSphericalTensorField \
416 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
417 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
420 #define makeFvsPatchTypeFieldTypedefs(type) \
422 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
423 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
424 typedef type##FvsPatchField<sphericalTensor> \
425 type##FvsPatchSphericalTensorField; \
426 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
427 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
434 // ************************************************************************* //