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 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 fvPatchField_H
46 #define fvPatchField_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 fvPatchField<Type>&);
73 /*---------------------------------------------------------------------------*\
74 Class patch Declaration
75 \*---------------------------------------------------------------------------*/
84 //- Reference to patch
85 const fvPatch& patch_;
87 //- Reference to internal field
88 const DimensionedField<Type, volMesh>& internalField_;
90 //- Update index used so that updateCoeffs is called only once during
91 // the construction of the matrix
94 //- Optional patch type, used to allow specified boundary conditions
95 // to be applied to constraint patches by providing the constraint
96 // patch type as 'patchType'
102 typedef fvPatch Patch;
105 //- Runtime type information
106 TypeName("fvPatchField");
108 //- Debug switch to disallow the use of genericFvPatchField
109 static int disallowGenericFvPatchField;
112 // Declare run-time constructor selection tables
114 declareRunTimeSelectionTable
121 const DimensionedField<Type, volMesh>& iF
126 declareRunTimeSelectionTable
132 const fvPatchField<Type>& ptf,
134 const DimensionedField<Type, volMesh>& iF,
135 const fvPatchFieldMapper& m
137 (dynamic_cast<const fvPatchFieldType&>(ptf), p, iF, m)
140 declareRunTimeSelectionTable
147 const DimensionedField<Type, volMesh>& iF,
148 const dictionary& dict
156 //- Construct from patch and internal field
160 const DimensionedField<Type, volMesh>&
163 //- Construct from patch and internal field and patch field
167 const DimensionedField<Type, volMesh>&,
171 //- Construct from patch, internal field and dictionary
175 const DimensionedField<Type, volMesh>&,
177 const bool valueRequired=false
180 //- Construct by mapping the given fvPatchField onto a new patch
183 const fvPatchField<Type>&,
185 const DimensionedField<Type, volMesh>&,
186 const fvPatchFieldMapper&
189 //- Construct as copy
190 fvPatchField(const fvPatchField<Type>&);
192 //- Construct and return a clone
193 virtual tmp<fvPatchField<Type> > clone() const
195 return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this));
198 //- Construct as copy setting internal field reference
201 const fvPatchField<Type>&,
202 const DimensionedField<Type, volMesh>&
205 //- Construct and return a clone setting internal field reference
206 virtual tmp<fvPatchField<Type> > clone
208 const DimensionedField<Type, volMesh>& iF
211 return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this, iF));
217 //- Return a pointer to a new patchField created on freestore given
218 // patch and internal field
219 // (does not set the patch field values)
220 static tmp<fvPatchField<Type> > New
224 const DimensionedField<Type, volMesh>&
227 //- Return a pointer to a new patchField created on freestore from
228 // a given fvPatchField mapped onto a new patch
229 static tmp<fvPatchField<Type> > New
231 const fvPatchField<Type>&,
233 const DimensionedField<Type, volMesh>&,
234 const fvPatchFieldMapper&
237 //- Return a pointer to a new patchField created on freestore
239 static tmp<fvPatchField<Type> > New
242 const DimensionedField<Type, volMesh>&,
246 //- Return a pointer to a new calculatedFvPatchField created on
247 // freestore without setting patchField values
248 template<class Type2>
249 static tmp<fvPatchField<Type> > NewCalculatedType
251 const fvPatchField<Type2>&
257 virtual ~fvPatchField<Type>()
265 //- Return local objectRegistry
266 const objectRegistry& db() const;
269 const fvPatch& patch() const
274 //- Return dimensioned internal field reference
275 const DimensionedField<Type, volMesh>&
276 dimensionedInternalField() const
278 return internalField_;
281 //- Return internal field reference
282 const Field<Type>& internalField() const
284 return internalField_;
287 //- Return the type of the calculated for of fvPatchField
288 static const word& calculatedType();
290 //- Return true if this patch field fixes a value.
291 // Needed to check if a level has to be specified while solving
292 // Poissons equations.
293 virtual bool fixesValue() const
298 //- Return true if this patch field is coupled
299 virtual bool coupled() const
304 //- Return true if the boundary condition has already been updated
313 //- Map (and resize as needed) from self given a mapping object
316 const fvPatchFieldMapper&
319 //- Reverse map the given fvPatchField onto this fvPatchField
322 const fvPatchField<Type>&,
327 // Evaluation functions
329 //- Return patch-normal gradient
330 virtual tmp<Field<Type> > snGrad() const;
332 //- Update the coefficients associated with the patch field
333 // Sets Updated to true
334 virtual void updateCoeffs()
339 //- Return internal field next to patch as patch field
340 virtual tmp<Field<Type> > patchInternalField() const;
342 //- Return patchField on the opposite patch of a coupled patch
343 virtual tmp<Field<Type> > patchNeighbourField() const
345 notImplemented(type() + "patchNeighbourField()");
349 //- Initialise the evaluation of the patch field
350 virtual void initEvaluate
352 const Pstream::commsTypes commsType=Pstream::blocking
356 //- Evaluate the patch field, sets Updated to false
357 virtual void evaluate
359 const Pstream::commsTypes commsType=Pstream::blocking
363 //- Return the matrix diagonal coefficients corresponding to the
364 // evaluation of the value of this patchField with given weights
365 virtual tmp<Field<Type> > valueInternalCoeffs
367 const tmp<Field<scalar> >&
373 + "::valueInternalCoeffs(const tmp<Field<scalar> >&)"
378 //- Return the matrix source coefficients corresponding to the
379 // evaluation of the value of this patchField with given weights
380 virtual tmp<Field<Type> > valueBoundaryCoeffs
382 const tmp<Field<scalar> >&
388 + "::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
393 //- Return the matrix diagonal coefficients corresponding to the
394 // evaluation of the gradient of this patchField
395 virtual tmp<Field<Type> > gradientInternalCoeffs() const
397 notImplemented(type() + "::gradientInternalCoeffs()");
401 //- Return the matrix source coefficients corresponding to the
402 // evaluation of the gradient of this patchField
403 virtual tmp<Field<Type> > gradientBoundaryCoeffs() const
405 notImplemented(type() + "::gradientBoundaryCoeffs()");
411 virtual void write(Ostream&) const;
416 //- Check fvPatchField<Type> against given fvPatchField<Type>
417 void check(const fvPatchField<Type>&) const;
422 virtual void operator=(const UList<Type>&);
424 virtual void operator=(const fvPatchField<Type>&);
425 virtual void operator+=(const fvPatchField<Type>&);
426 virtual void operator-=(const fvPatchField<Type>&);
427 virtual void operator*=(const fvPatchField<scalar>&);
428 virtual void operator/=(const fvPatchField<scalar>&);
430 virtual void operator+=(const Field<Type>&);
431 virtual void operator-=(const Field<Type>&);
433 virtual void operator*=(const Field<scalar>&);
434 virtual void operator/=(const Field<scalar>&);
436 virtual void operator=(const Type&);
437 virtual void operator+=(const Type&);
438 virtual void operator-=(const Type&);
439 virtual void operator*=(const scalar);
440 virtual void operator/=(const scalar);
443 // Force an assignment irrespective of form of patch
445 virtual void operator==(const fvPatchField<Type>&);
446 virtual void operator==(const Field<Type>&);
447 virtual void operator==(const Type&);
452 friend Ostream& operator<< <Type>(Ostream&, const fvPatchField<Type>&);
456 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
458 } // End namespace Foam
460 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
463 # include "fvPatchField.C"
464 # include "calculatedFvPatchField.H"
468 #define makePatchTypeFieldTypeName(type) \
470 defineNamedTemplateTypeNameAndDebug(type, 0);
472 #define makePatchFieldsTypeName(type) \
474 makePatchTypeFieldTypeName(type##FvPatchScalarField); \
475 makePatchTypeFieldTypeName(type##FvPatchVectorField); \
476 makePatchTypeFieldTypeName(type##FvPatchSphericalTensorField); \
477 makePatchTypeFieldTypeName(type##FvPatchSymmTensorField); \
478 makePatchTypeFieldTypeName(type##FvPatchTensorField);
480 #define makePatchTypeField(PatchTypeField, typePatchTypeField) \
482 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
484 addToRunTimeSelectionTable \
486 PatchTypeField, typePatchTypeField, patch \
489 addToRunTimeSelectionTable \
492 typePatchTypeField, \
496 addToRunTimeSelectionTable \
498 PatchTypeField, typePatchTypeField, dictionary \
502 #define makePatchFields(type) \
504 makePatchTypeField(fvPatchScalarField, type##FvPatchScalarField); \
505 makePatchTypeField(fvPatchVectorField, type##FvPatchVectorField); \
508 fvPatchSphericalTensorField, \
509 type##FvPatchSphericalTensorField \
511 makePatchTypeField(fvPatchSymmTensorField, type##FvPatchSymmTensorField); \
512 makePatchTypeField(fvPatchTensorField, type##FvPatchTensorField);
515 #define makePatchTypeFieldTypedefs(type) \
517 typedef type##FvPatchField<scalar> type##FvPatchScalarField; \
518 typedef type##FvPatchField<vector> type##FvPatchVectorField; \
519 typedef type##FvPatchField<sphericalTensor> \
520 type##FvPatchSphericalTensorField; \
521 typedef type##FvPatchField<symmTensor> type##FvPatchSymmTensorField; \
522 typedef type##FvPatchField<tensor> type##FvPatchTensorField;
525 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
529 // ************************************************************************* //