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 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 types 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
73 Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
76 /*---------------------------------------------------------------------------*\
77 Class patch Declaration
78 \*---------------------------------------------------------------------------*/
87 //- Reference to patch
88 const fvPatch& patch_;
90 //- Reference to internal field
91 const DimensionedField<Type, volMesh>& internalField_;
93 //- Update index used so that updateCoeffs is called only once during
94 // the construction of the matrix
97 //- Optional patch type, used to allow specified boundary conditions
98 // to be applied to constraint patches by providing the constraint
99 // patch type as 'patchType'
105 typedef fvPatch Patch;
108 //- Runtime type information
109 TypeName("fvPatchField");
111 //- Debug switch to disallow the use of genericFvPatchField
112 static int disallowGenericFvPatchField;
115 // Declare run-time constructor selection tables
117 declareRunTimeSelectionTable
124 const DimensionedField<Type, volMesh>& iF
129 declareRunTimeSelectionTable
135 const fvPatchField<Type>& ptf,
137 const DimensionedField<Type, volMesh>& iF,
138 const fvPatchFieldMapper& m
140 (dynamic_cast<const fvPatchFieldType&>(ptf), p, iF, m)
143 declareRunTimeSelectionTable
150 const DimensionedField<Type, volMesh>& iF,
151 const dictionary& dict
159 //- Construct from patch and internal field
163 const DimensionedField<Type, volMesh>&
166 //- Construct from patch and internal field and patch field
170 const DimensionedField<Type, volMesh>&,
174 //- Construct from patch, internal field and dictionary
178 const DimensionedField<Type, volMesh>&,
180 const bool valueRequired = false
183 //- Construct by mapping the given fvPatchField onto a new patch
186 const fvPatchField<Type>&,
188 const DimensionedField<Type, volMesh>&,
189 const fvPatchFieldMapper&
192 //- Construct as copy
193 fvPatchField(const fvPatchField<Type>&);
195 //- Construct and return a clone
196 virtual tmp<fvPatchField<Type> > clone() const
198 return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this));
201 //- Construct as copy setting internal field reference
204 const fvPatchField<Type>&,
205 const DimensionedField<Type, volMesh>&
208 //- Construct and return a clone setting internal field reference
209 virtual tmp<fvPatchField<Type> > clone
211 const DimensionedField<Type, volMesh>& iF
214 return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this, iF));
220 //- Return a pointer to a new patchField created on freestore given
221 // patch and internal field
222 // (does not set the patch field values)
223 static tmp<fvPatchField<Type> > New
227 const DimensionedField<Type, volMesh>&
230 //- Return a pointer to a new patchField created on freestore from
231 // a given fvPatchField mapped onto a new patch
232 static tmp<fvPatchField<Type> > New
234 const fvPatchField<Type>&,
236 const DimensionedField<Type, volMesh>&,
237 const fvPatchFieldMapper&
240 //- Return a pointer to a new patchField created on freestore
242 static tmp<fvPatchField<Type> > New
245 const DimensionedField<Type, volMesh>&,
249 //- Return a pointer to a new calculatedFvPatchField created on
250 // freestore without setting patchField values
251 template<class Type2>
252 static tmp<fvPatchField<Type> > NewCalculatedType
254 const fvPatchField<Type2>&
260 virtual ~fvPatchField<Type>()
268 //- Return local objectRegistry
269 const objectRegistry& db() const;
272 const fvPatch& patch() const
277 //- Return dimensioned internal field reference
278 const DimensionedField<Type, volMesh>&
279 dimensionedInternalField() const
281 return internalField_;
284 //- Return internal field reference
285 const Field<Type>& internalField() const
287 return internalField_;
290 //- Return the type of the calculated for of fvPatchField
291 static const word& calculatedType();
293 //- Return true if this patch field fixes a value.
294 // Needed to check if a level has to be specified while solving
295 // Poissons equations.
296 virtual bool fixesValue() const
301 //- Return true if this patch field is coupled
302 virtual bool coupled() const
307 //- Return true if the boundary condition has already been updated
316 //- Map (and resize as needed) from self given a mapping object
319 const fvPatchFieldMapper&
322 //- Reverse map the given fvPatchField onto this fvPatchField
325 const fvPatchField<Type>&,
330 // Evaluation functions
332 //- Return patch-normal gradient
333 virtual tmp<Field<Type> > snGrad() const;
335 //- Update the coefficients associated with the patch field
336 // Sets Updated to true
337 virtual void updateCoeffs()
342 //- Return internal field next to patch as patch field
343 virtual tmp<Field<Type> > patchInternalField() const;
345 //- Return patchField on the opposite patch of a coupled patch
346 virtual tmp<Field<Type> > patchNeighbourField() const
348 notImplemented(type() + "patchNeighbourField()");
352 //- Initialise the evaluation of the patch field
353 virtual void initEvaluate
355 const Pstream::commsTypes commsType=Pstream::blocking
359 //- Evaluate the patch field, sets Updated to false
360 virtual void evaluate
362 const Pstream::commsTypes commsType=Pstream::blocking
366 //- Return the matrix diagonal coefficients corresponding to the
367 // evaluation of the value of this patchField with given weights
368 virtual tmp<Field<Type> > valueInternalCoeffs
370 const tmp<Field<scalar> >&
376 + "::valueInternalCoeffs(const tmp<Field<scalar> >&)"
381 //- Return the matrix source coefficients corresponding to the
382 // evaluation of the value of this patchField with given weights
383 virtual tmp<Field<Type> > valueBoundaryCoeffs
385 const tmp<Field<scalar> >&
391 + "::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
396 //- Return the matrix diagonal coefficients corresponding to the
397 // evaluation of the gradient of this patchField
398 virtual tmp<Field<Type> > gradientInternalCoeffs() const
400 notImplemented(type() + "::gradientInternalCoeffs()");
404 //- Return the matrix source coefficients corresponding to the
405 // evaluation of the gradient of this patchField
406 virtual tmp<Field<Type> > gradientBoundaryCoeffs() const
408 notImplemented(type() + "::gradientBoundaryCoeffs()");
413 //- Manipulate matrix
414 virtual void manipulateMatrix(fvMatrix<Type>& matrix);
420 virtual void write(Ostream&) const;
422 //- Helper function to write the keyword and entry only if the
423 // values are not equal. The value is then output as value2
424 template<class EntryType>
425 void writeEntryIfDifferent
428 const word& entryName,
429 const EntryType& value1,
430 const EntryType& value2
436 //- Check fvPatchField<Type> against given fvPatchField<Type>
437 void check(const fvPatchField<Type>&) const;
442 virtual void operator=(const UList<Type>&);
444 virtual void operator=(const fvPatchField<Type>&);
445 virtual void operator+=(const fvPatchField<Type>&);
446 virtual void operator-=(const fvPatchField<Type>&);
447 virtual void operator*=(const fvPatchField<scalar>&);
448 virtual void operator/=(const fvPatchField<scalar>&);
450 virtual void operator+=(const Field<Type>&);
451 virtual void operator-=(const Field<Type>&);
453 virtual void operator*=(const Field<scalar>&);
454 virtual void operator/=(const Field<scalar>&);
456 virtual void operator=(const Type&);
457 virtual void operator+=(const Type&);
458 virtual void operator-=(const Type&);
459 virtual void operator*=(const scalar);
460 virtual void operator/=(const scalar);
463 // Force an assignment irrespective of form of patch
465 virtual void operator==(const fvPatchField<Type>&);
466 virtual void operator==(const Field<Type>&);
467 virtual void operator==(const Type&);
472 friend Ostream& operator<< <Type>(Ostream&, const fvPatchField<Type>&);
476 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
478 } // End namespace Foam
480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
483 # include "fvPatchField.C"
484 # include "calculatedFvPatchField.H"
488 #define makePatchTypeFieldTypeName(type) \
490 defineNamedTemplateTypeNameAndDebug(type, 0);
492 #define makePatchFieldsTypeName(type) \
494 makePatchTypeFieldTypeName(type##FvPatchScalarField); \
495 makePatchTypeFieldTypeName(type##FvPatchVectorField); \
496 makePatchTypeFieldTypeName(type##FvPatchSphericalTensorField); \
497 makePatchTypeFieldTypeName(type##FvPatchSymmTensorField); \
498 makePatchTypeFieldTypeName(type##FvPatchTensorField);
500 #define makePatchTypeField(PatchTypeField, typePatchTypeField) \
502 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
504 addToRunTimeSelectionTable \
506 PatchTypeField, typePatchTypeField, patch \
509 addToRunTimeSelectionTable \
512 typePatchTypeField, \
516 addToRunTimeSelectionTable \
518 PatchTypeField, typePatchTypeField, dictionary \
522 #define makePatchFields(type) \
524 makePatchTypeField(fvPatchScalarField, type##FvPatchScalarField); \
525 makePatchTypeField(fvPatchVectorField, type##FvPatchVectorField); \
528 fvPatchSphericalTensorField, \
529 type##FvPatchSphericalTensorField \
531 makePatchTypeField(fvPatchSymmTensorField, type##FvPatchSymmTensorField); \
532 makePatchTypeField(fvPatchTensorField, type##FvPatchTensorField);
535 #define makePatchTypeFieldTypedefs(type) \
537 typedef type##FvPatchField<scalar> type##FvPatchScalarField; \
538 typedef type##FvPatchField<vector> type##FvPatchVectorField; \
539 typedef type##FvPatchField<sphericalTensor> \
540 type##FvPatchSphericalTensorField; \
541 typedef type##FvPatchField<symmTensor> type##FvPatchSymmTensorField; \
542 typedef type##FvPatchField<tensor> type##FvPatchTensorField;
545 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
549 // ************************************************************************* //