OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

pointPatchField.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     pointPatchField
00027 
00028 Description
00029     Abstract base class for point-mesh patch fields.
00030 
00031     The base-field does not store values as they are part of the 
00032     "internal field".  There are derived classes to store constraint values
00033     e.g. fixedValuePointPatchField derived from the generic
00034     valuePointPatchField which ensures the values in the "internal field"
00035     are reset to the fixed-values by applying the stored values.
00036 
00037 SourceFiles
00038     pointPatchField.C
00039     newpointPatchField.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef pointPatchField_H
00044 #define pointPatchField_H
00045 
00046 #include "pointPatch.H"
00047 #include "DimensionedField.H"
00048 #include "autoPtr.H"
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 namespace Foam
00053 {
00054 
00055 // Class forward declarations
00056 
00057 class objectRegistry;
00058 class dictionary;
00059 class pointPatchFieldMapper;
00060 class pointMesh;
00061 
00062 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00063 
00064 template<class Type>
00065 class pointPatchField;
00066 
00067 template<class Type>
00068 Ostream& operator<<
00069 (
00070     Ostream&,
00071     const pointPatchField<Type>&
00072 );
00073 
00074 
00075 /*---------------------------------------------------------------------------*\
00076                        Class pointPatchField Declaration
00077 \*---------------------------------------------------------------------------*/
00078 
00079 template<class Type>
00080 class pointPatchField
00081 {
00082     // Private data
00083 
00084         //- Reference to patch
00085         const pointPatch& patch_;
00086 
00087         //- Reference to internal field
00088         const DimensionedField<Type, pointMesh>& internalField_;
00089 
00090         //- Update index used so that updateCoeffs is called only once during
00091         //  the construction of the matrix
00092         bool updated_;
00093 
00094 
00095 public:
00096 
00097     typedef pointPatch Patch;
00098 
00099 
00100     //- Runtime type information
00101     TypeName("pointPatchField");
00102 
00103 
00104     // Declare run-time constructor selection tables
00105 
00106         declareRunTimeSelectionTable
00107         (
00108             autoPtr,
00109             pointPatchField,
00110             pointPatch,
00111             (
00112                 const pointPatch& p,
00113                 const DimensionedField<Type, pointMesh>& iF
00114             ),
00115             (p, iF)
00116         );
00117 
00118         declareRunTimeSelectionTable
00119         (
00120             autoPtr,
00121             pointPatchField,
00122             patchMapper,
00123             (
00124                 const pointPatchField<Type>& ptf,
00125                 const pointPatch& p,
00126                 const DimensionedField<Type, pointMesh>& iF,
00127                 const pointPatchFieldMapper& m
00128             ),
00129             (dynamic_cast<const pointPatchFieldType&>(ptf), p, iF, m)
00130         );
00131 
00132         declareRunTimeSelectionTable
00133         (
00134             autoPtr,
00135             pointPatchField,
00136             dictionary,
00137             (
00138                 const pointPatch& p,
00139                 const DimensionedField<Type, pointMesh>& iF,
00140                 const dictionary& dict
00141             ),
00142             (p, iF, dict)
00143         );
00144 
00145 
00146     // Constructors
00147 
00148         //- Construct from patch and internal field
00149         pointPatchField
00150         (
00151             const pointPatch&,
00152             const DimensionedField<Type, pointMesh>&
00153         );
00154 
00155         //- Construct as copy
00156         pointPatchField(const pointPatchField<Type>&);
00157 
00158         //- Construct and return a clone
00159         virtual autoPtr<pointPatchField<Type> > clone() const = 0;
00160 
00161         //- Construct as copy setting internal field reference
00162         pointPatchField
00163         (
00164             const pointPatchField<Type>&,
00165             const DimensionedField<Type, pointMesh>&
00166         );
00167 
00168         //- Construct and return a clone setting internal field reference
00169         virtual autoPtr<pointPatchField<Type> > clone
00170         (
00171             const DimensionedField<Type, pointMesh>& iF
00172         ) const = 0;
00173 
00174 
00175     // Selectors
00176 
00177         //- Return a pointer to a new patchField created on freestore given
00178         //  patch and internal field
00179         //  (does not set the patch field values)
00180         static autoPtr<pointPatchField<Type> > New
00181         (
00182             const word&,
00183             const pointPatch&,
00184             const DimensionedField<Type, pointMesh>&
00185         );
00186 
00187         //- Return a pointer to a new patchField created on freestore from
00188         //  a given pointPatchField mapped onto a new patch
00189         static autoPtr<pointPatchField<Type> > New
00190         (
00191             const pointPatchField<Type>&,
00192             const pointPatch&,
00193             const DimensionedField<Type, pointMesh>&,
00194             const pointPatchFieldMapper&
00195         );
00196 
00197         //- Return a pointer to a new patchField created on freestore
00198         //  from dictionary
00199         static autoPtr<pointPatchField<Type> > New
00200         (
00201             const pointPatch&,
00202             const DimensionedField<Type, pointMesh>&,
00203             const dictionary&
00204         );
00205 
00206 
00207         //- Return a pointer to a new CalculatedpointPatchField created on
00208         //  freestore without setting patchField values
00209         template<class Type2>
00210         static autoPtr<pointPatchField<Type> >
00211         NewCalculatedType
00212         (
00213             const pointPatchField<Type2>&
00214         );
00215 
00216 
00217     // Destructor
00218 
00219         virtual ~pointPatchField<Type>()
00220         {}
00221 
00222 
00223     // Member functions
00224 
00225         // Access
00226 
00227             //- Return local objectRegistry
00228             const objectRegistry& db() const;
00229 
00230             //- Return size
00231             label size() const
00232             {
00233                 return patch().size();
00234             }
00235 
00236             //- Return patch
00237             const pointPatch& patch() const
00238             {
00239                 return patch_;
00240             }
00241 
00242             //- Return dimensioned internal field reference
00243             const DimensionedField<Type, pointMesh>&
00244             dimensionedInternalField() const
00245             {
00246                 return internalField_;
00247             }
00248 
00249             //- Return internal field reference
00250             const Field<Type>& internalField() const
00251             {
00252                 return internalField_;
00253             }
00254 
00255             //- Return true if this patch field is coupled
00256             virtual bool coupled() const
00257             {
00258                 return false;
00259             }
00260 
00261             //- Return true if the boundary condition has already been updated
00262             bool updated() const
00263             {
00264                 return updated_;
00265             }
00266 
00267             //- Return field created from appropriate internal field values
00268             tmp<Field<Type> > patchInternalField() const;
00269 
00270             //- Return field created from appropriate internal field values
00271             //  given internal field reference
00272             template<class Type1>
00273             tmp<Field<Type1> > patchInternalField
00274             (
00275                 const Field<Type1>& iF
00276             ) const;
00277 
00278             //- Given the internal field and a patch field,
00279             //  add the patch field to the internal field
00280             template<class Type1>
00281             void addToInternalField
00282             (
00283                 Field<Type1>& iF,
00284                 const Field<Type1>& pF
00285             ) const;
00286 
00287             //- Given the internal field and a patch field,
00288             //  set the patch field in the internal field
00289             template<class Type1>
00290             void setInInternalField
00291             (
00292                 Field<Type1>& iF,
00293                 const Field<Type1>& pF
00294             ) const;
00295 
00296             //- Return the type of the calculated for of pointPatchField
00297             static const word& calculatedType();
00298 
00299 
00300         // Mapping functions
00301 
00302             //- Map (and resize as needed) from self given a mapping object
00303             virtual void autoMap
00304             (
00305                 const pointPatchFieldMapper&
00306             )
00307             {}
00308 
00309             //- Reverse map the given pointPatchField onto this pointPatchField
00310             virtual void rmap
00311             (
00312                 const pointPatchField<Type>&,
00313                 const labelList&
00314             )
00315             {}
00316 
00317 
00318         // Evaluation functions
00319 
00320             //- Update the coefficients associated with the patch field
00321             //  Sets Updated to true
00322             virtual void updateCoeffs()
00323             {
00324                 updated_ = true;
00325             }
00326 
00327             //- Initialise evaluation of the patch field (do nothing)
00328             virtual void initEvaluate(const bool=false)
00329             {}
00330 
00331             //- Evaluate the patch field
00332             virtual void evaluate();
00333 
00334 
00335         //- Write
00336         virtual void write(Ostream&) const;
00337 
00338 
00339     // Member operators
00340 
00341         virtual void operator=
00342         (
00343             const pointPatchField<Type>&
00344         )
00345         {}
00346 
00347         virtual void operator+=
00348         (
00349             const pointPatchField<Type>&
00350         )
00351         {}
00352 
00353         virtual void operator-=
00354         (
00355             const pointPatchField<Type>&
00356         )
00357         {}
00358 
00359         virtual void operator*=
00360         (
00361             const pointPatchField<scalar>&
00362         )
00363         {}
00364 
00365         virtual void operator/=
00366         (
00367             const pointPatchField<scalar>&
00368         )
00369         {}
00370 
00371         virtual void operator=(const Field<Type>&){}
00372         virtual void operator+=(const Field<Type>&){}
00373         virtual void operator-=(const Field<Type>&){}
00374 
00375         virtual void operator*=(const Field<scalar>&){}
00376         virtual void operator/=(const Field<scalar>&){}
00377 
00378         virtual void operator=(const Type&){}
00379         virtual void operator+=(const Type&){}
00380         virtual void operator-=(const Type&){}
00381         virtual void operator*=(const scalar){}
00382         virtual void operator/=(const scalar){}
00383 
00384 
00385         // Force an assignment irrespective of form of patch
00386         // By default these do nothing unless the patch actually has boundary
00387         // values
00388 
00389             virtual void operator==
00390             (
00391                 const pointPatchField<Type>&
00392             )
00393             {}
00394 
00395             virtual void operator==(const Field<Type>&){}
00396             virtual void operator==(const Type&){}
00397 
00398 
00399     // Ostream operator
00400 
00401         friend Ostream& operator<< <Type>
00402         (
00403             Ostream&,
00404             const pointPatchField<Type>&
00405         );
00406 };
00407 
00408 
00409 // This function is added as a hack to enable simple backward compatability
00410 // with verions using referenceLevel in GeometicField
00411 template<class Type>
00412 const pointPatchField<Type>& operator+
00413 (
00414     const pointPatchField<Type>& ppf,
00415     const Type&
00416 )
00417 {
00418     return ppf;
00419 }
00420 
00421 
00422 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00423 
00424 } // End namespace Foam
00425 
00426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00427 
00428 #include "pointPatchFieldFunctions.H"
00429 
00430 #ifdef NoRepository
00431 #   include "pointPatchField.C"
00432 #   include "calculatedPointPatchField.H"
00433 #endif
00434 
00435 
00436 #define makePointPatchTypeFieldTypeName(type)                                 \
00437                                                                               \
00438 defineNamedTemplateTypeNameAndDebug(type, 0);
00439 
00440 #define makePointPatchFieldsTypeName(type)                                    \
00441                                                                               \
00442 makePointPatchTypeFieldTypeName(type##PointPatchScalarField);                 \
00443 makePointPatchTypeFieldTypeName(type##PointPatchVectorField);                 \
00444 makePointPatchTypeFieldTypeName(type##PointPatchSphericalTensorField);        \
00445 makePointPatchTypeFieldTypeName(type##PointPatchSymmTensorField);             \
00446 makePointPatchTypeFieldTypeName(type##PointPatchTensorField);
00447 
00448 #define makePointPatchTypeField(PatchTypeField, typePatchTypeField)           \
00449                                                                               \
00450 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                   \
00451                                                                               \
00452 addToRunTimeSelectionTable                                                    \
00453 (                                                                             \
00454     PatchTypeField, typePatchTypeField, pointPatch                            \
00455 );                                                                            \
00456                                                                               \
00457 addToRunTimeSelectionTable                                                    \
00458 (                                                                             \
00459     PatchTypeField,                                                           \
00460     typePatchTypeField,                                                       \
00461     patchMapper                                                               \
00462 );                                                                            \
00463                                                                               \
00464 addToRunTimeSelectionTable                                                    \
00465 (                                                                             \
00466     PatchTypeField, typePatchTypeField, dictionary                            \
00467 );
00468 
00469 
00470 #define makePointPatchFields(type)                                            \
00471                                                                               \
00472 makePointPatchTypeField                                                       \
00473 (                                                                             \
00474     pointPatchScalarField,                                                    \
00475     type##PointPatchScalarField                                               \
00476 );                                                                            \
00477                                                                               \
00478 makePointPatchTypeField                                                       \
00479 (                                                                             \
00480     pointPatchVectorField,                                                    \
00481     type##PointPatchVectorField                                               \
00482 );                                                                            \
00483                                                                               \
00484 makePointPatchTypeField                                                       \
00485 (                                                                             \
00486     pointPatchSphericalTensorField,                                           \
00487     type##PointPatchSphericalTensorField                                      \
00488 );                                                                            \
00489                                                                               \
00490 makePointPatchTypeField                                                       \
00491 (                                                                             \
00492     pointPatchSymmTensorField,                                                \
00493     type##PointPatchSymmTensorField                                           \
00494 );                                                                            \
00495                                                                               \
00496 makePointPatchTypeField                                                       \
00497 (                                                                             \
00498     pointPatchTensorField,                                                    \
00499     type##PointPatchTensorField                                               \
00500 );
00501              
00502 
00503 #define makePointPatchFieldTypedefs(type)                                     \
00504                                                                               \
00505 typedef type##PointPatchField<scalar> type##PointPatchScalarField;            \
00506 typedef type##PointPatchField<vector> type##PointPatchVectorField;            \
00507 typedef type##PointPatchField<sphericalTensor>                                \
00508     type##PointPatchSphericalTensorField;                                     \
00509 typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField;    \
00510 typedef type##PointPatchField<tensor> type##PointPatchTensorField;
00511 
00512 
00513 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00514 
00515 #endif
00516 
00517 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd