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
118 declareRunTimeSelectionTable
125 const DimensionedField<Type, volMesh>& iF
130 declareRunTimeSelectionTable
136 const fvPatchField<Type>& ptf,
138 const DimensionedField<Type, volMesh>& iF,
139 const fvPatchFieldMapper& m
141 (dynamic_cast<const fvPatchFieldType&>(ptf), p, iF, m)
144 declareRunTimeSelectionTable
151 const DimensionedField<Type, volMesh>& iF,
152 const dictionary& dict
160 //- Construct from patch and internal field
164 const DimensionedField<Type, volMesh>&
167 //- Construct from patch and internal field and patch field
171 const DimensionedField<Type, volMesh>&,
175 //- Construct from patch, internal field and dictionary
179 const DimensionedField<Type, volMesh>&,
181 const bool valueRequired = false
184 //- Construct by mapping the given fvPatchField onto a new patch
187 const fvPatchField<Type>&,
189 const DimensionedField<Type, volMesh>&,
190 const fvPatchFieldMapper&
193 //- Construct as copy
194 fvPatchField(const fvPatchField<Type>&);
196 //- Construct and return a clone
197 virtual tmp<fvPatchField<Type> > clone() const
199 return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this));
202 //- Construct as copy setting internal field reference
205 const fvPatchField<Type>&,
206 const DimensionedField<Type, volMesh>&
209 //- Construct and return a clone setting internal field reference
210 virtual tmp<fvPatchField<Type> > clone
212 const DimensionedField<Type, volMesh>& iF
215 return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this, iF));
221 //- Return a pointer to a new patchField created on freestore given
222 // patch and internal field
223 // (does not set the patch field values)
224 static tmp<fvPatchField<Type> > New
228 const DimensionedField<Type, volMesh>&
231 //- Return a pointer to a new patchField created on freestore from
232 // a given fvPatchField mapped onto a new patch
233 static tmp<fvPatchField<Type> > New
235 const fvPatchField<Type>&,
237 const DimensionedField<Type, volMesh>&,
238 const fvPatchFieldMapper&
241 //- Return a pointer to a new patchField created on freestore
243 static tmp<fvPatchField<Type> > New
246 const DimensionedField<Type, volMesh>&,
250 //- Return a pointer to a new calculatedFvPatchField created on
251 // freestore without setting patchField values
252 template<class Type2>
253 static tmp<fvPatchField<Type> > NewCalculatedType
255 const fvPatchField<Type2>&
261 virtual ~fvPatchField<Type>()
269 //- Return local objectRegistry
270 const objectRegistry& db() const;
273 const fvPatch& patch() const
278 //- Return dimensioned internal field reference
279 const DimensionedField<Type, volMesh>&
280 dimensionedInternalField() const
282 return internalField_;
285 //- Return internal field reference
286 const Field<Type>& internalField() const
288 return internalField_;
291 //- Return the type of the calculated for of fvPatchField
292 static const word& calculatedType();
294 //- Return true if this patch field fixes a value.
295 // Needed to check if a level has to be specified while solving
296 // Poissons equations.
297 virtual bool fixesValue() const
302 //- Return true if this patch field is coupled
303 virtual bool coupled() const
308 //- Return true if the boundary condition has already been updated
317 //- Map (and resize as needed) from self given a mapping object
320 const fvPatchFieldMapper&
323 //- Reverse map the given fvPatchField onto this fvPatchField
326 const fvPatchField<Type>&,
331 // Evaluation functions
333 //- Return patch-normal gradient
334 virtual tmp<Field<Type> > snGrad() const;
336 //- Update the coefficients associated with the patch field
337 // Sets Updated to true
338 virtual void updateCoeffs()
343 //- Return internal field next to patch as patch field
344 virtual tmp<Field<Type> > patchInternalField() const;
346 //- Return patchField on the opposite patch of a coupled patch
347 virtual tmp<Field<Type> > patchNeighbourField() const
349 notImplemented(type() + "patchNeighbourField()");
353 //- Initialise the evaluation of the patch field
354 virtual void initEvaluate
356 const Pstream::commsTypes commsType=Pstream::blocking
360 //- Evaluate the patch field, sets Updated to false
361 virtual void evaluate
363 const Pstream::commsTypes commsType=Pstream::blocking
367 //- Return the matrix diagonal coefficients corresponding to the
368 // evaluation of the value of this patchField with given weights
369 virtual tmp<Field<Type> > valueInternalCoeffs
371 const tmp<Field<scalar> >&
377 + "::valueInternalCoeffs(const tmp<Field<scalar> >&)"
382 //- Return the matrix source coefficients corresponding to the
383 // evaluation of the value of this patchField with given weights
384 virtual tmp<Field<Type> > valueBoundaryCoeffs
386 const tmp<Field<scalar> >&
392 + "::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
397 //- Return the matrix diagonal coefficients corresponding to the
398 // evaluation of the gradient of this patchField
399 virtual tmp<Field<Type> > gradientInternalCoeffs() const
401 notImplemented(type() + "::gradientInternalCoeffs()");
405 //- Return the matrix source coefficients corresponding to the
406 // evaluation of the gradient of this patchField
407 virtual tmp<Field<Type> > gradientBoundaryCoeffs() const
409 notImplemented(type() + "::gradientBoundaryCoeffs()");
414 //- Manipulate matrix
415 virtual void manipulateMatrix(fvMatrix<Type>& matrix);
421 virtual void write(Ostream&) const;
423 //- Helper function to write the keyword and entry only if the
424 // values are not equal. The value is then output as value2
425 template<class EntryType>
426 void writeEntryIfDifferent
429 const word& entryName,
430 const EntryType& value1,
431 const EntryType& value2
437 //- Check fvPatchField<Type> against given fvPatchField<Type>
438 void check(const fvPatchField<Type>&) const;
443 virtual void operator=(const UList<Type>&);
445 virtual void operator=(const fvPatchField<Type>&);
446 virtual void operator+=(const fvPatchField<Type>&);
447 virtual void operator-=(const fvPatchField<Type>&);
448 virtual void operator*=(const fvPatchField<scalar>&);
449 virtual void operator/=(const fvPatchField<scalar>&);
451 virtual void operator+=(const Field<Type>&);
452 virtual void operator-=(const Field<Type>&);
454 virtual void operator*=(const Field<scalar>&);
455 virtual void operator/=(const Field<scalar>&);
457 virtual void operator=(const Type&);
458 virtual void operator+=(const Type&);
459 virtual void operator-=(const Type&);
460 virtual void operator*=(const scalar);
461 virtual void operator/=(const scalar);
464 // Force an assignment irrespective of form of patch
466 virtual void operator==(const fvPatchField<Type>&);
467 virtual void operator==(const Field<Type>&);
468 virtual void operator==(const Type&);
474 friend Ostream& operator<< <Type>(Ostream&, const fvPatchField<Type>&);
479 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
481 } // End namespace Foam
483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
486 # include "fvPatchField.C"
487 # include "calculatedFvPatchField.H"
491 #define makePatchTypeFieldTypeName(type) \
493 defineNamedTemplateTypeNameAndDebug(type, 0);
495 #define makePatchFieldsTypeName(type) \
497 makePatchTypeFieldTypeName(type##FvPatchScalarField); \
498 makePatchTypeFieldTypeName(type##FvPatchVectorField); \
499 makePatchTypeFieldTypeName(type##FvPatchSphericalTensorField); \
500 makePatchTypeFieldTypeName(type##FvPatchSymmTensorField); \
501 makePatchTypeFieldTypeName(type##FvPatchTensorField);
503 #define makePatchTypeField(PatchTypeField, typePatchTypeField) \
505 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
507 addToRunTimeSelectionTable \
509 PatchTypeField, typePatchTypeField, patch \
512 addToRunTimeSelectionTable \
515 typePatchTypeField, \
519 addToRunTimeSelectionTable \
521 PatchTypeField, typePatchTypeField, dictionary \
525 #define makePatchFields(type) \
527 makePatchTypeField(fvPatchScalarField, type##FvPatchScalarField); \
528 makePatchTypeField(fvPatchVectorField, type##FvPatchVectorField); \
531 fvPatchSphericalTensorField, \
532 type##FvPatchSphericalTensorField \
534 makePatchTypeField(fvPatchSymmTensorField, type##FvPatchSymmTensorField); \
535 makePatchTypeField(fvPatchTensorField, type##FvPatchTensorField);
538 #define makePatchTypeFieldTypedefs(type) \
540 typedef type##FvPatchField<scalar> type##FvPatchScalarField; \
541 typedef type##FvPatchField<vector> type##FvPatchVectorField; \
542 typedef type##FvPatchField<sphericalTensor> \
543 type##FvPatchSphericalTensorField; \
544 typedef type##FvPatchField<symmTensor> type##FvPatchSymmTensorField; \
545 typedef type##FvPatchField<tensor> type##FvPatchTensorField;
548 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
552 // ************************************************************************* //