1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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 Abstract base class for point-mesh patch fields.
30 The base-field does not store values as they are part of the
31 "internal field". There are derived classes to store constraint values
32 e.g. fixedValuePointPatchField derived from the generic
33 valuePointPatchField which ensures the values in the "internal field"
34 are reset to the fixed-values by applying the stored values.
40 \*---------------------------------------------------------------------------*/
42 #ifndef pointPatchField_H
43 #define pointPatchField_H
45 #include "pointPatch.H"
46 #include "DimensionedField.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 // Forward declaration of classes
58 class pointPatchFieldMapper;
61 // Forward declaration of friend functions and operators
64 class pointPatchField;
70 const pointPatchField<Type>&
74 /*---------------------------------------------------------------------------*\
75 Class pointPatchField Declaration
76 \*---------------------------------------------------------------------------*/
83 //- Reference to patch
84 const pointPatch& patch_;
86 //- Reference to internal field
87 const DimensionedField<Type, pointMesh>& internalField_;
89 //- Update index used so that updateCoeffs is called only once during
90 // the construction of the matrix
93 //- Optional patch type, used to allow specified boundary conditions
94 // to be applied to constraint patches by providing the constraint
95 // patch type as 'patchType'
101 typedef pointPatch Patch;
104 //- Runtime type information
105 TypeName("pointPatchField");
107 //- Debug switch to disallow the use of genericPointPatchField
108 static int disallowGenericPointPatchField;
111 // Declare run-time constructor selection tables
113 declareRunTimeSelectionTable
120 const DimensionedField<Type, pointMesh>& iF
125 declareRunTimeSelectionTable
131 const pointPatchField<Type>& ptf,
133 const DimensionedField<Type, pointMesh>& iF,
134 const pointPatchFieldMapper& m
136 (dynamic_cast<const pointPatchFieldType&>(ptf), p, iF, m)
139 declareRunTimeSelectionTable
146 const DimensionedField<Type, pointMesh>& iF,
147 const dictionary& dict
155 //- Construct from patch and internal field
159 const DimensionedField<Type, pointMesh>&
162 //- Construct from patch, internal field and dictionary
166 const DimensionedField<Type, pointMesh>&,
170 //- Construct as copy
171 pointPatchField(const pointPatchField<Type>&);
173 //- Construct and return a clone
174 virtual autoPtr<pointPatchField<Type> > clone() const = 0;
176 //- Construct as copy setting internal field reference
179 const pointPatchField<Type>&,
180 const DimensionedField<Type, pointMesh>&
183 //- Construct and return a clone setting internal field reference
184 virtual autoPtr<pointPatchField<Type> > clone
186 const DimensionedField<Type, pointMesh>& iF
192 //- Return a pointer to a new patchField created on freestore given
193 // patch and internal field
194 // (does not set the patch field values)
195 static autoPtr<pointPatchField<Type> > New
199 const DimensionedField<Type, pointMesh>&
202 //- Return a pointer to a new patchField created on freestore given
203 // patch and internal field
204 // (does not set the patch field values).
205 // Allows override of constraint type
206 static autoPtr<pointPatchField<Type> > New
209 const word& actualPatchType,
211 const DimensionedField<Type, pointMesh>&
214 //- Return a pointer to a new patchField created on freestore from
215 // a given pointPatchField mapped onto a new patch
216 static autoPtr<pointPatchField<Type> > New
218 const pointPatchField<Type>&,
220 const DimensionedField<Type, pointMesh>&,
221 const pointPatchFieldMapper&
224 //- Return a pointer to a new patchField created on freestore
226 static autoPtr<pointPatchField<Type> > New
229 const DimensionedField<Type, pointMesh>&,
234 //- Return a pointer to a new CalculatedpointPatchField created on
235 // freestore without setting patchField values
236 template<class Type2>
237 static autoPtr<pointPatchField<Type> >
240 const pointPatchField<Type2>&
245 virtual ~pointPatchField<Type>()
253 //- Return local objectRegistry
254 const objectRegistry& db() const;
259 return patch().size();
263 const pointPatch& patch() const
268 //- Return dimensioned internal field reference
269 const DimensionedField<Type, pointMesh>&
270 dimensionedInternalField() const
272 return internalField_;
275 //- Return internal field reference
276 const Field<Type>& internalField() const
278 return internalField_;
281 //- Return true if this patch field is coupled
282 virtual bool coupled() const
287 //- Return true if the boundary condition has already been updated
293 //- Return field created from appropriate internal field values
294 tmp<Field<Type> > patchInternalField() const;
296 //- Return field created from appropriate internal field values
297 // given internal field reference
298 template<class Type1>
299 tmp<Field<Type1> > patchInternalField
301 const Field<Type1>& iF
304 //- Return field created from selected internal field values
305 // given internal field reference
306 template<class Type1>
307 tmp<Field<Type1> > patchInternalField
309 const Field<Type1>& iF,
310 const labelList& meshPoints
313 //- Given the internal field and a patch field,
314 // add the patch field to the internal field
315 template<class Type1>
316 void addToInternalField
319 const Field<Type1>& pF
322 //- Given the internal field and a patch field,
323 // add selected elements of the patch field to the internal field
324 template<class Type1>
325 void addToInternalField
328 const Field<Type1>& pF,
329 const labelList& points
332 //- Given the internal field and a patch field,
333 // set the patch field in the internal field
334 template<class Type1>
335 void setInInternalField
338 const Field<Type1>& pF,
339 const labelList& meshPoints
342 //- Given the internal field and a patch field,
343 // set the patch field in the internal field
344 template<class Type1>
345 void setInInternalField
348 const Field<Type1>& pF
351 //- Return the type of the calculated form of pointPatchField
352 static const word& calculatedType();
354 //- Return the constraint type this pointPatchField implements.
355 virtual const word& constraintType() const
363 //- Map (and resize as needed) from self given a mapping object
366 const pointPatchFieldMapper&
370 //- Reverse map the given pointPatchField onto this pointPatchField
373 const pointPatchField<Type>&,
379 // Evaluation functions
381 //- Update the coefficients associated with the patch field
382 // Sets Updated to true
383 virtual void updateCoeffs()
388 //- Initialise evaluation of the patch field (do nothing)
389 virtual void initEvaluate
391 const Pstream::commsTypes commsType=Pstream::blocking
395 //- Evaluate the patch field
396 virtual void evaluate
398 const Pstream::commsTypes commsType=Pstream::blocking
403 virtual void write(Ostream&) const;
408 virtual void operator=
410 const pointPatchField<Type>&
414 virtual void operator+=
416 const pointPatchField<Type>&
420 virtual void operator-=
422 const pointPatchField<Type>&
426 virtual void operator*=
428 const pointPatchField<scalar>&
432 virtual void operator/=
434 const pointPatchField<scalar>&
438 virtual void operator=(const Field<Type>&){}
439 virtual void operator+=(const Field<Type>&){}
440 virtual void operator-=(const Field<Type>&){}
442 virtual void operator*=(const Field<scalar>&){}
443 virtual void operator/=(const Field<scalar>&){}
445 virtual void operator=(const Type&){}
446 virtual void operator+=(const Type&){}
447 virtual void operator-=(const Type&){}
448 virtual void operator*=(const scalar){}
449 virtual void operator/=(const scalar){}
452 // Force an assignment irrespective of form of patch
453 // By generic these do nothing unless the patch actually has boundary
456 virtual void operator==
458 const pointPatchField<Type>&
462 virtual void operator==(const Field<Type>&){}
463 virtual void operator==(const Type&){}
468 friend Ostream& operator<< <Type>
471 const pointPatchField<Type>&
476 // This function is added as a hack to enable simple backward compatability
477 // with verions using referenceLevel in GeometicField
479 const pointPatchField<Type>& operator+
481 const pointPatchField<Type>& ppf,
489 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
491 } // End namespace Foam
493 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
495 #include "pointPatchFieldFunctions.H"
498 # include "pointPatchField.C"
499 # include "calculatedPointPatchField.H"
503 #define addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
504 addToRunTimeSelectionTable \
507 typePatchTypeField, \
510 addToRunTimeSelectionTable \
513 typePatchTypeField, \
516 addToRunTimeSelectionTable \
519 typePatchTypeField, \
524 // for non-templated patch fields
525 #define makePointPatchTypeField(PatchTypeField,typePatchTypeField) \
526 defineTypeNameAndDebug(typePatchTypeField, 0); \
527 addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
530 // for templated patch fields
531 #define makeTemplatePointPatchTypeField(PatchTypeField, typePatchTypeField) \
532 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
533 addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
536 #define makePointPatchFields(type) \
537 makeTemplatePointPatchTypeField \
539 pointPatchScalarField, \
540 type##PointPatchScalarField \
542 makeTemplatePointPatchTypeField \
544 pointPatchVectorField, \
545 type##PointPatchVectorField \
547 makeTemplatePointPatchTypeField \
549 pointPatchSphericalTensorField, \
550 type##PointPatchSphericalTensorField \
552 makeTemplatePointPatchTypeField \
554 pointPatchSymmTensorField, \
555 type##PointPatchSymmTensorField \
557 makeTemplatePointPatchTypeField \
559 pointPatchTensorField, \
560 type##PointPatchTensorField \
564 #define makePointPatchFieldsTypeName(type) \
565 defineNamedTemplateTypeNameAndDebug(type##PointPatchScalarField, 0); \
566 defineNamedTemplateTypeNameAndDebug(type##PointPatchVectorField, 0); \
567 defineNamedTemplateTypeNameAndDebug \
569 type##PointPatchSphericalTensorField, 0 \
571 defineNamedTemplateTypeNameAndDebug(type##PointPatchSymmTensorField, 0); \
572 defineNamedTemplateTypeNameAndDebug(type##PointPatchTensorField, 0)
575 #define makePointPatchFieldTypedefs(type) \
576 typedef type##PointPatchField<scalar> type##PointPatchScalarField; \
577 typedef type##PointPatchField<vector> type##PointPatchVectorField; \
578 typedef type##PointPatchField<sphericalTensor> \
579 type##PointPatchSphericalTensorField; \
580 typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField;\
581 typedef type##PointPatchField<tensor> type##PointPatchTensorField;
584 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
588 // ************************************************************************* //