1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, 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;
63 // Forward declaration of friend functions and operators
69 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
72 /*---------------------------------------------------------------------------*\
73 Class patch Declaration
74 \*---------------------------------------------------------------------------*/
83 //- Reference to patch
84 const fvPatch& patch_;
86 //- Reference to internal field
87 const DimensionedField<Type, surfaceMesh>& internalField_;
92 typedef fvPatch Patch;
95 //- Runtime type information
96 TypeName("fvsPatchField");
98 //- Debug switch to disallow the use of genericFvsPatchField
99 static int disallowGenericFvsPatchField;
102 // Declare run-time constructor selection tables
104 declareRunTimeSelectionTable
111 const DimensionedField<Type, surfaceMesh>& iF
116 declareRunTimeSelectionTable
122 const fvsPatchField<Type>& ptf,
124 const DimensionedField<Type, surfaceMesh>& iF,
125 const fvPatchFieldMapper& m
127 (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
130 declareRunTimeSelectionTable
137 const DimensionedField<Type, surfaceMesh>& iF,
138 const dictionary& dict
146 //- Construct from patch and internal field
150 const DimensionedField<Type, surfaceMesh>&
153 //- Construct from patch and internal field and patch field
157 const DimensionedField<Type, surfaceMesh>&,
161 //- Construct from patch, internal field and dictionary
165 const DimensionedField<Type, surfaceMesh>&,
169 //- Construct by mapping the given fvsPatchField onto a new patch
172 const fvsPatchField<Type>&,
174 const DimensionedField<Type, surfaceMesh>&,
175 const fvPatchFieldMapper&
178 //- Construct as copy
179 fvsPatchField(const fvsPatchField<Type>&);
181 //- Construct and return a clone
182 virtual tmp<fvsPatchField<Type> > clone() const
184 return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
187 //- Construct as copy setting internal field reference
190 const fvsPatchField<Type>&,
191 const DimensionedField<Type, surfaceMesh>&
194 //- Construct and return a clone setting internal field reference
195 virtual tmp<fvsPatchField<Type> > clone
197 const DimensionedField<Type, surfaceMesh>& iF
200 return tmp<fvsPatchField<Type> >
202 new fvsPatchField<Type>(*this, iF)
209 //- Return a pointer to a new patchField created on freestore given
210 // patch and internal field
211 // (does not set the patch field values)
212 static tmp<fvsPatchField<Type> > New
216 const DimensionedField<Type, surfaceMesh>&
219 //- Return a pointer to a new patchField created on freestore given
220 // patch and internal field
221 // (does not set the patch field values)
222 // Allows override of constraint type
223 static tmp<fvsPatchField<Type> > New
226 const word& actualPatchType,
228 const DimensionedField<Type, surfaceMesh>&
231 //- Return a pointer to a new patchField created on freestore from
232 // a given fvsPatchField mapped onto a new patch
233 static tmp<fvsPatchField<Type> > New
235 const fvsPatchField<Type>&,
237 const DimensionedField<Type, surfaceMesh>&,
238 const fvPatchFieldMapper&
241 //- Return a pointer to a new patchField created on freestore
243 static tmp<fvsPatchField<Type> > New
246 const DimensionedField<Type, surfaceMesh>&,
250 //- Return a pointer to a new calculatedFvsPatchField created on
251 // freestore without setting patchField values
252 template<class Type2>
253 static tmp<fvsPatchField<Type> > NewCalculatedType
255 const fvsPatchField<Type2>&
260 virtual ~fvsPatchField<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, surfaceMesh>&
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 fvsPatchField
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
310 //- Map (and resize as needed) from self given a mapping object
313 const fvPatchFieldMapper&
316 //- Reverse map the given fvsPatchField onto this fvsPatchField
319 const fvsPatchField<Type>&,
325 virtual void write(Ostream&) const;
330 //- Check fvsPatchField<Type> against given fvsPatchField<Type>
331 void check(const fvsPatchField<Type>&) const;
336 virtual void operator=(const UList<Type>&);
338 virtual void operator=(const fvsPatchField<Type>&);
339 virtual void operator+=(const fvsPatchField<Type>&);
340 virtual void operator-=(const fvsPatchField<Type>&);
341 virtual void operator*=(const fvsPatchField<scalar>&);
342 virtual void operator/=(const fvsPatchField<scalar>&);
344 virtual void operator+=(const Field<Type>&);
345 virtual void operator-=(const Field<Type>&);
347 virtual void operator*=(const Field<scalar>&);
348 virtual void operator/=(const Field<scalar>&);
350 virtual void operator=(const Type&);
351 virtual void operator+=(const Type&);
352 virtual void operator-=(const Type&);
353 virtual void operator*=(const scalar);
354 virtual void operator/=(const scalar);
357 // Force an assignment irrespective of form of patch
359 virtual void operator==(const fvsPatchField<Type>&);
360 virtual void operator==(const Field<Type>&);
361 virtual void operator==(const Type&);
366 friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
372 } // End namespace Foam
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 # include "fvsPatchField.C"
378 # include "calculatedFvsPatchField.H"
382 #define makeFvsPatchTypeFieldTypeName(type) \
384 defineNamedTemplateTypeNameAndDebug(type, 0);
386 #define makeFvsPatchFieldsTypeName(type) \
388 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
389 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
390 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
391 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
392 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
394 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
396 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
398 addToRunTimeSelectionTable \
400 PatchTypeField, typePatchTypeField, patch \
403 addToRunTimeSelectionTable \
406 typePatchTypeField, \
410 addToRunTimeSelectionTable \
412 PatchTypeField, typePatchTypeField, dictionary \
416 #define makeFvsPatchFields(type) \
418 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
419 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
420 makeFvsPatchTypeField \
422 fvsPatchSphericalTensorField, \
423 type##FvsPatchSphericalTensorField \
425 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
426 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
429 #define makeFvsPatchTypeFieldTypedefs(type) \
431 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
432 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
433 typedef type##FvsPatchField<sphericalTensor> \
434 type##FvsPatchSphericalTensorField; \
435 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
436 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
439 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
443 // ************************************************************************* //