1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 An abstract base class with a fat-interface to all derived classes
29 covering all possible ways in which they might be used.
31 The first level of derivation is to basic patchFields which cover
32 zero-gradient, fixed-gradient, fixed-value and mixed conditions.
34 The next level of derivation covers all the specialised typed with
35 specific evaluation proceedures, particularly with respect to specific
42 \*---------------------------------------------------------------------------*/
44 #ifndef fvsPatchField_H
45 #define fvsPatchField_H
48 #include "DimensionedField.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Forward declaration of classes
59 class fvPatchFieldMapper;
65 // Forward declaration of friend functions and operators
71 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
74 /*---------------------------------------------------------------------------*\
75 Class patch Declaration
76 \*---------------------------------------------------------------------------*/
85 //- Reference to patch
86 const fvPatch& patch_;
88 //- Reference to internal field
89 const DimensionedField<Type, surfaceMesh>& internalField_;
94 typedef fvPatch Patch;
97 //- Runtime type information
98 TypeName("fvsPatchField");
100 //- Debug switch to disallow the use of
101 static debug::debugSwitch disallowDefaultFvsPatchField;
104 // Declare run-time constructor selection tables
107 declareRunTimeSelectionTable
114 const DimensionedField<Type, surfaceMesh>& iF
119 declareRunTimeSelectionTable
125 const fvsPatchField<Type>& ptf,
127 const DimensionedField<Type, surfaceMesh>& iF,
128 const fvPatchFieldMapper& m
130 (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
133 declareRunTimeSelectionTable
140 const DimensionedField<Type, surfaceMesh>& iF,
141 const dictionary& dict
149 //- Construct from patch and internal field
153 const DimensionedField<Type, surfaceMesh>&
156 //- Construct from patch and internal field and patch field
160 const DimensionedField<Type, surfaceMesh>&,
164 //- Construct from patch, internal field and dictionary
168 const DimensionedField<Type, surfaceMesh>&,
170 const bool valueRequired = false
173 //- Construct by mapping the given fvsPatchField onto a new patch
176 const fvsPatchField<Type>&,
178 const DimensionedField<Type, surfaceMesh>&,
179 const fvPatchFieldMapper&
182 //- Construct as copy
183 fvsPatchField(const fvsPatchField<Type>&);
185 //- Construct and return a clone
186 virtual tmp<fvsPatchField<Type> > clone() const
188 return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
191 //- Construct as copy setting internal field reference
194 const fvsPatchField<Type>&,
195 const DimensionedField<Type, surfaceMesh>&
198 //- Construct and return a clone setting internal field reference
199 virtual tmp<fvsPatchField<Type> > clone
201 const DimensionedField<Type, surfaceMesh>& iF
204 return tmp<fvsPatchField<Type> >
206 new fvsPatchField<Type>(*this, iF)
213 //- Return a pointer to a new patchField created on freestore given
214 // patch and internal field
215 // (does not set the patch field values)
216 static tmp<fvsPatchField<Type> > New
220 const DimensionedField<Type, surfaceMesh>&
223 //- Return a pointer to a new patchField created on freestore from
224 // a given fvsPatchField mapped onto a new patch
225 static tmp<fvsPatchField<Type> > New
227 const fvsPatchField<Type>&,
229 const DimensionedField<Type, surfaceMesh>&,
230 const fvPatchFieldMapper&
233 //- Return a pointer to a new patchField created on freestore
235 static tmp<fvsPatchField<Type> > New
238 const DimensionedField<Type, surfaceMesh>&,
242 //- Return a pointer to a new calculatedFvsPatchField created on
243 // freestore without setting patchField values
244 template<class Type2>
245 static tmp<fvsPatchField<Type> > NewCalculatedType
247 const fvsPatchField<Type2>&
253 virtual ~fvsPatchField<Type>()
261 //- Return local objectRegistry
262 const objectRegistry& db() const;
264 //- Lookup and return the patchField of the named field from the
265 // field's objectRegistry.
266 // N.B. The dummy pointer arguments are used if this function is
267 // instantiated within a templated function to avoid a bug in gcc.
268 // See inletOutletFvPatchField.C and outletInletFvPatchField.C
269 template<class GeometricField, class Type2>
270 const typename GeometricField::PatchFieldType& lookupPatchField
273 const GeometricField* = NULL,
278 const fvPatch& patch() const
283 //- Return dimensioned internal field reference
284 const DimensionedField<Type, surfaceMesh>&
285 dimensionedInternalField() const
287 return internalField_;
290 //- Return internal field reference
291 const Field<Type>& internalField() const
293 return internalField_;
296 //- Return the type of the calculated for of fvsPatchField
297 static const word& calculatedType();
299 //- Return true if this patch field fixes a value.
300 // Needed to check if a level has to be specified while solving
301 // Poissons equations.
302 virtual bool fixesValue() const
307 //- Return true if this patch field is coupled
308 virtual bool coupled() const
316 //- Map (and resize as needed) from self given a mapping object
319 const fvPatchFieldMapper&
322 //- Reverse map the given fvsPatchField onto this fvsPatchField
325 const fvsPatchField<Type>&,
330 // Evaluation functions
332 //- Initialise the evaluation of the patch field
333 virtual void initEvaluate
335 const Pstream::commsTypes commsType = Pstream::blocking
339 //- Evaluate the patch field, sets Updated to false
340 virtual void evaluate
342 const Pstream::commsTypes commsType = Pstream::blocking
348 virtual void write(Ostream&) const;
353 //- Check fvsPatchField<Type> against given fvsPatchField<Type>
354 void check(const fvsPatchField<Type>&) const;
356 //- Check fvsPatchField<Type> against given fvPatchField<Type>
357 void check(const fvPatchField<Type>&) const;
362 virtual void operator=(const UList<Type>&);
364 virtual void operator=(const fvsPatchField<Type>&);
365 virtual void operator+=(const fvsPatchField<Type>&);
366 virtual void operator-=(const fvsPatchField<Type>&);
367 virtual void operator*=(const fvsPatchField<scalar>&);
368 virtual void operator/=(const fvsPatchField<scalar>&);
370 virtual void operator=(const fvPatchField<Type>&);
372 virtual void operator+=(const Field<Type>&);
373 virtual void operator-=(const Field<Type>&);
375 virtual void operator*=(const Field<scalar>&);
376 virtual void operator/=(const Field<scalar>&);
378 virtual void operator=(const Type&);
379 virtual void operator+=(const Type&);
380 virtual void operator-=(const Type&);
381 virtual void operator*=(const scalar);
382 virtual void operator/=(const scalar);
385 // Force an assignment irrespective of form of patch
387 virtual void operator==(const fvsPatchField<Type>&);
388 virtual void operator==(const Field<Type>&);
389 virtual void operator==(const Type&);
395 friend Ostream& operator<< <Type>
398 const fvsPatchField<Type>&
404 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
406 } // End namespace Foam
408 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
411 # include "fvsPatchField.C"
412 # include "calculatedFvsPatchField.H"
416 #define makeFvsPatchTypeFieldTypeName(type) \
418 defineNamedTemplateTypeNameAndDebug(type, 0);
420 #define makeFvsPatchFieldsTypeName(type) \
422 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
423 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
424 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
425 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
426 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensor4thOrderField); \
427 makeFvsPatchTypeFieldTypeName(type##FvsPatchDiagTensorField); \
428 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
430 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
432 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
434 addToRunTimeSelectionTable \
436 PatchTypeField, typePatchTypeField, patch \
439 addToRunTimeSelectionTable \
442 typePatchTypeField, \
446 addToRunTimeSelectionTable \
448 PatchTypeField, typePatchTypeField, dictionary \
452 #define makeFvsPatchFields(type) \
454 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
455 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
456 makeFvsPatchTypeField \
458 fvsPatchSphericalTensorField, \
459 type##FvsPatchSphericalTensorField \
461 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
462 makeFvsPatchTypeField \
464 fvsPatchSymmTensor4thOrderField, \
465 type##FvsPatchSymmTensor4thOrderField \
467 makeFvsPatchTypeField \
469 fvsPatchDiagTensorField, \
470 type##FvsPatchDiagTensorField \
472 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
475 #define makeFvsPatchTypeFieldTypedefs(type) \
477 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
478 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
479 typedef type##FvsPatchField<sphericalTensor> \
480 type##FvsPatchSphericalTensorField; \
481 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
482 typedef type##FvsPatchField<symmTensor4thOrder> \
483 type##FvsPatchSymmTensor4thOrderField; \
484 typedef type##FvsPatchField<diagTensor> \
485 type##FvsPatchDiagTensorField; \
486 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
489 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
493 // ************************************************************************* //