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 faPatchField<Type> abstract base class. This class gives a fat-interface
30 to all derived classes covering all possible ways in which they might be
31 used. The first level of derivation is to basic patchFields which cover
32 zero-gradient, fixed-gradient, fixed-value and mixed conditions. The next
33 level of derivation covers all the specialised typed with specific
34 evaluation proceedures, particularly with respect to specific fields.
40 \*---------------------------------------------------------------------------*/
42 #ifndef faPatchField_H
43 #define faPatchField_H
46 #include "DimensionedField.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 // Class forward declarations
57 class faPatchFieldMapper;
61 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
67 Ostream& operator<<(Ostream&, const faPatchField<Type>&);
69 /*---------------------------------------------------------------------------*\
70 Class faPatchField Declaration
71 \*---------------------------------------------------------------------------*/
80 //- Reference to a patch
81 const faPatch& patch_;
83 //- Reference to internal field
84 const DimensionedField<Type, areaMesh>& internalField_;
86 //- Update index used so that updateCoeffs is called only once during
87 // the construction of the matrix
93 typedef faPatch Patch;
96 //- Runtime type information
97 TypeName("faPatchField");
99 //- Debug switch to disallow the use of
100 static int disallowDefaultFaPatchField;
103 // Declare run-time constructor selection tables
105 declareRunTimeSelectionTable
112 const DimensionedField<Type, areaMesh>& iF
117 declareRunTimeSelectionTable
123 const faPatchField<Type>& ptf,
125 const DimensionedField<Type, areaMesh>& iF,
126 const faPatchFieldMapper& m
128 (dynamic_cast<const faPatchFieldType&>(ptf), p, iF, m)
131 declareRunTimeSelectionTable
138 const DimensionedField<Type, areaMesh>& iF,
139 const dictionary& dict
147 //- Construct from patch and internal field
151 const DimensionedField<Type, areaMesh>&
154 //- Construct from patch and internal field and patch field
158 const DimensionedField<Type, areaMesh>&,
162 //- Construct from patch, internal field and dictionary
166 const DimensionedField<Type, areaMesh>&,
170 //- Construct by mapping the given faPatchField onto a new patch
173 const faPatchField<Type>&,
175 const DimensionedField<Type, areaMesh>&,
176 const faPatchFieldMapper&
179 //- Construct as copy
180 faPatchField(const faPatchField<Type>&);
182 //- Construct and return a clone
183 virtual tmp<faPatchField<Type> > clone() const
185 return tmp<faPatchField<Type> >(new faPatchField<Type>(*this));
188 //- Construct as copy setting internal field reference
191 const faPatchField<Type>&,
192 const DimensionedField<Type, areaMesh>&
195 //- Construct and return a clone setting internal field reference
196 virtual tmp<faPatchField<Type> > clone
198 const DimensionedField<Type, areaMesh>& iF
201 return tmp<faPatchField<Type> >(new faPatchField<Type>(*this, iF));
207 //- Return a pointer to a new patchField created on freestore given
208 // patch and internal field
209 // (does not set the patch field values)
210 static tmp<faPatchField<Type> > New
214 const DimensionedField<Type, areaMesh>&
217 //- Return a pointer to a new patchField created on freestore from
218 // a given faPatchField mapped onto a new patch
219 static tmp<faPatchField<Type> > New
221 const faPatchField<Type>&,
223 const DimensionedField<Type, areaMesh>&,
224 const faPatchFieldMapper&
227 //- Return a pointer to a new patchField created on freestore
229 static tmp<faPatchField<Type> > New
232 const DimensionedField<Type, areaMesh>&,
236 //- Return a pointer to a new calculatedFaPatchField created on
237 // freestore without setting patchField values
238 template<class Type2>
239 static tmp<faPatchField<Type> > NewCalculatedType
241 const faPatchField<Type2>&
247 virtual ~faPatchField<Type>()
255 //- Return local objectRegistry
256 const objectRegistry& db() const;
259 const faPatch& patch() const
264 //- Return dimensioned internal field reference
265 const DimensionedField<Type, areaMesh>&
266 dimensionedInternalField() const
268 return internalField_;
271 //- Return internal field reference
272 const Field<Type>& internalField() const
274 return internalField_;
277 //- Return the type of the calculated for of faPatchField
278 static const word& calculatedType();
280 //- Return true if this patch field fixes a value.
281 // Needed to check if a level has to be specified while solving
282 // Poissons equations.
283 virtual bool fixesValue() const
288 //- Return true if this patch field is coupled
289 virtual bool coupled() const
294 //- Return true if the boundary condition has already been updated
303 //- Map (and resize as needed) from self given a mapping object
306 const faPatchFieldMapper&
309 //- Reverse map the given faPatchField onto this faPatchField
312 const faPatchField<Type>&,
317 // Evaluation functions
319 //- Return patch-normal gradient
320 virtual tmp<Field<Type> > snGrad() const;
322 //- Update the coefficients associated with the patch field
323 // Sets Updated to true
324 virtual void updateCoeffs()
329 //- Return internal field next to patch as patch field
330 virtual tmp<Field<Type> > patchInternalField() const;
332 //- Return patchField on the opposite patch of a coupled patch
333 virtual tmp<Field<Type> > patchNeighbourField() const
335 notImplemented(type() + "patchNeighbourField()");
339 //- Initialise the evaluation of the patch field
340 virtual void initEvaluate
342 const Pstream::commsTypes commsType=Pstream::blocking
346 //- Evaluate the patch field, sets Updated to false
347 virtual void evaluate
349 const Pstream::commsTypes commsType=Pstream::blocking
353 //- Return the matrix diagonal coefficients corresponding to the
354 // evaluation of the value of this patchField with given weights
355 virtual tmp<Field<Type> > valueInternalCoeffs
357 const tmp<Field<scalar> >&
363 + "::valueInternalCoeffs(const tmp<Field<scalar> >&)"
368 //- Return the matrix source coefficients corresponding to the
369 // evaluation of the value of this patchField with given weights
370 virtual tmp<Field<Type> > valueBoundaryCoeffs
372 const tmp<Field<scalar> >&
378 + "::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
383 //- Return the matrix diagonal coefficients corresponding to the
384 // evaluation of the gradient of this patchField
385 virtual tmp<Field<Type> > gradientInternalCoeffs() const
387 notImplemented(type() + "::gradientInternalCoeffs()");
391 //- Return the matrix source coefficients corresponding to the
392 // evaluation of the gradient of this patchField
393 virtual tmp<Field<Type> > gradientBoundaryCoeffs() const
395 notImplemented(type() + "::gradientBoundaryCoeffs()");
401 virtual void write(Ostream&) const;
406 //- Check faPatchField<Type> against given faPatchField<Type>
407 void check(const faPatchField<Type>&) const;
412 virtual void operator=(const UList<Type>&);
414 virtual void operator=(const faPatchField<Type>&);
415 virtual void operator+=(const faPatchField<Type>&);
416 virtual void operator-=(const faPatchField<Type>&);
417 virtual void operator*=(const faPatchField<scalar>&);
418 virtual void operator/=(const faPatchField<scalar>&);
420 virtual void operator+=(const Field<Type>&);
421 virtual void operator-=(const Field<Type>&);
423 virtual void operator*=(const Field<scalar>&);
424 virtual void operator/=(const Field<scalar>&);
426 virtual void operator=(const Type&);
427 virtual void operator+=(const Type&);
428 virtual void operator-=(const Type&);
429 virtual void operator*=(const scalar);
430 virtual void operator/=(const scalar);
433 // Force an assignment irrespective of form of patch
435 virtual void operator==(const faPatchField<Type>&);
436 virtual void operator==(const Field<Type>&);
437 virtual void operator==(const Type&);
442 friend Ostream& operator<< <Type>(Ostream&, const faPatchField<Type>&);
446 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
448 } // End namespace Foam
450 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
453 # include "faPatchField.C"
454 # include "calculatedFaPatchField.H"
458 #define makeFaPatchTypeFieldTypeName(typePatchTypeField) \
460 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
462 #define makeFaPatchFieldsTypeName(typePatchField) \
464 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchScalarField); \
465 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchVectorField); \
466 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSphericalTensorField); \
467 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSymmTensorField); \
468 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchTensorField);
470 #define makeFaPatchTypeField(PatchTypeField, typePatchTypeField) \
472 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
474 addToRunTimeSelectionTable \
476 PatchTypeField, typePatchTypeField, patch \
479 addToRunTimeSelectionTable \
482 typePatchTypeField, \
486 addToRunTimeSelectionTable \
488 PatchTypeField, typePatchTypeField, dictionary \
492 #define makeFaPatchFields(type) \
494 makeFaPatchTypeField(faPatchScalarField, type##FaPatchScalarField); \
495 makeFaPatchTypeField(faPatchVectorField, type##FaPatchVectorField); \
496 makeFaPatchTypeField \
498 faPatchSphericalTensorField, \
499 type##FaPatchSphericalTensorField \
501 makeFaPatchTypeField(faPatchSymmTensorField, type##FaPatchSymmTensorField);\
502 makeFaPatchTypeField(faPatchTensorField, type##FaPatchTensorField);
505 #define makeFaPatchTypeFieldTypedefs(type) \
507 typedef type##FaPatchField<scalar> type##FaPatchScalarField; \
508 typedef type##FaPatchField<vector> type##FaPatchVectorField; \
509 typedef type##FaPatchField<sphericalTensor> \
510 type##FaPatchSphericalTensorField; \
511 typedef type##FaPatchField<symmTensor> type##FaPatchSymmTensorField; \
512 typedef type##FaPatchField<tensor> type##FaPatchTensorField;
515 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
519 // ************************************************************************* //