1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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>&,
170 //- Construct by mapping the given fvsPatchField onto a new patch
173 const fvsPatchField<Type>&,
175 const DimensionedField<Type, surfaceMesh>&,
176 const fvPatchFieldMapper&
179 //- Construct as copy
180 fvsPatchField(const fvsPatchField<Type>&);
182 //- Construct and return a clone
183 virtual tmp<fvsPatchField<Type> > clone() const
185 return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
188 //- Construct as copy setting internal field reference
191 const fvsPatchField<Type>&,
192 const DimensionedField<Type, surfaceMesh>&
195 //- Construct and return a clone setting internal field reference
196 virtual tmp<fvsPatchField<Type> > clone
198 const DimensionedField<Type, surfaceMesh>& iF
201 return tmp<fvsPatchField<Type> >
203 new fvsPatchField<Type>(*this, iF)
210 //- Return a pointer to a new patchField created on freestore given
211 // patch and internal field
212 // (does not set the patch field values)
213 static tmp<fvsPatchField<Type> > New
217 const DimensionedField<Type, surfaceMesh>&
220 //- Return a pointer to a new patchField created on freestore from
221 // a given fvsPatchField mapped onto a new patch
222 static tmp<fvsPatchField<Type> > New
224 const fvsPatchField<Type>&,
226 const DimensionedField<Type, surfaceMesh>&,
227 const fvPatchFieldMapper&
230 //- Return a pointer to a new patchField created on freestore
232 static tmp<fvsPatchField<Type> > New
235 const DimensionedField<Type, surfaceMesh>&,
239 //- Return a pointer to a new calculatedFvsPatchField created on
240 // freestore without setting patchField values
241 template<class Type2>
242 static tmp<fvsPatchField<Type> > NewCalculatedType
244 const fvsPatchField<Type2>&
250 virtual ~fvsPatchField<Type>()
258 //- Return local objectRegistry
259 const objectRegistry& db() const;
262 const fvPatch& patch() const
267 //- Return dimensioned internal field reference
268 const DimensionedField<Type, surfaceMesh>&
269 dimensionedInternalField() const
271 return internalField_;
274 //- Return internal field reference
275 const Field<Type>& internalField() const
277 return internalField_;
280 //- Return the type of the calculated for of fvsPatchField
281 static const word& calculatedType();
283 //- Return true if this patch field fixes a value.
284 // Needed to check if a level has to be specified while solving
285 // Poissons equations.
286 virtual bool fixesValue() const
291 //- Return true if this patch field is coupled
292 virtual bool coupled() const
300 //- Map (and resize as needed) from self given a mapping object
303 const fvPatchFieldMapper&
306 //- Reverse map the given fvsPatchField onto this fvsPatchField
309 const fvsPatchField<Type>&,
315 virtual void write(Ostream&) const;
320 //- Check fvsPatchField<Type> against given fvsPatchField<Type>
321 void check(const fvsPatchField<Type>&) const;
326 virtual void operator=(const UList<Type>&);
328 virtual void operator=(const fvsPatchField<Type>&);
329 virtual void operator+=(const fvsPatchField<Type>&);
330 virtual void operator-=(const fvsPatchField<Type>&);
331 virtual void operator*=(const fvsPatchField<scalar>&);
332 virtual void operator/=(const fvsPatchField<scalar>&);
334 virtual void operator+=(const Field<Type>&);
335 virtual void operator-=(const Field<Type>&);
337 virtual void operator*=(const Field<scalar>&);
338 virtual void operator/=(const Field<scalar>&);
340 virtual void operator=(const Type&);
341 virtual void operator+=(const Type&);
342 virtual void operator-=(const Type&);
343 virtual void operator*=(const scalar);
344 virtual void operator/=(const scalar);
347 // Force an assignment irrespective of form of patch
349 virtual void operator==(const fvsPatchField<Type>&);
350 virtual void operator==(const Field<Type>&);
351 virtual void operator==(const Type&);
356 friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 } // End namespace Foam
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 # include "fvsPatchField.C"
368 # include "calculatedFvsPatchField.H"
372 #define makeFvsPatchTypeFieldTypeName(type) \
374 defineNamedTemplateTypeNameAndDebug(type, 0);
376 #define makeFvsPatchFieldsTypeName(type) \
378 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
379 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
380 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
381 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
382 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
384 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
386 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
388 addToRunTimeSelectionTable \
390 PatchTypeField, typePatchTypeField, patch \
393 addToRunTimeSelectionTable \
396 typePatchTypeField, \
400 addToRunTimeSelectionTable \
402 PatchTypeField, typePatchTypeField, dictionary \
406 #define makeFvsPatchFields(type) \
408 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
409 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
410 makeFvsPatchTypeField \
412 fvsPatchSphericalTensorField, \
413 type##FvsPatchSphericalTensorField \
415 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
416 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
419 #define makeFvsPatchTypeFieldTypedefs(type) \
421 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
422 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
423 typedef type##FvsPatchField<sphericalTensor> \
424 type##FvsPatchSphericalTensorField; \
425 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
426 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
429 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
433 // ************************************************************************* //