OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-2009 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     Foam::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 // Forward declaration of classes
00056 
00057 class objectRegistry;
00058 class dictionary;
00059 class pointPatchFieldMapper;
00060 class pointMesh;
00061 
00062 // Forward declaration of friend functions and operators
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         //- Optional patch type, used to allow specified boundary conditions
00095         //  to be applied to constraint patches by providing the constraint
00096         //  patch type as 'patchType'
00097         word patchType_;
00098 
00099 
00100 public:
00101 
00102     typedef pointPatch Patch;
00103 
00104 
00105     //- Runtime type information
00106     TypeName("pointPatchField");
00107 
00108     //- Debug switch to disallow the use of genericPointPatchField
00109     static int disallowGenericPointPatchField;
00110 
00111 
00112     // Declare run-time constructor selection tables
00113 
00114         declareRunTimeSelectionTable
00115         (
00116             autoPtr,
00117             pointPatchField,
00118             pointPatch,
00119             (
00120                 const pointPatch& p,
00121                 const DimensionedField<Type, pointMesh>& iF
00122             ),
00123             (p, iF)
00124         );
00125 
00126         declareRunTimeSelectionTable
00127         (
00128             autoPtr,
00129             pointPatchField,
00130             patchMapper,
00131             (
00132                 const pointPatchField<Type>& ptf,
00133                 const pointPatch& p,
00134                 const DimensionedField<Type, pointMesh>& iF,
00135                 const pointPatchFieldMapper& m
00136             ),
00137             (dynamic_cast<const pointPatchFieldType&>(ptf), p, iF, m)
00138         );
00139 
00140         declareRunTimeSelectionTable
00141         (
00142             autoPtr,
00143             pointPatchField,
00144             dictionary,
00145             (
00146                 const pointPatch& p,
00147                 const DimensionedField<Type, pointMesh>& iF,
00148                 const dictionary& dict
00149             ),
00150             (p, iF, dict)
00151         );
00152 
00153 
00154     // Constructors
00155 
00156         //- Construct from patch and internal field
00157         pointPatchField
00158         (
00159             const pointPatch&,
00160             const DimensionedField<Type, pointMesh>&
00161         );
00162 
00163         //- Construct from patch, internal field and dictionary
00164         pointPatchField
00165         (
00166             const pointPatch&,
00167             const DimensionedField<Type, pointMesh>&,
00168             const dictionary&
00169         );
00170 
00171         //- Construct as copy
00172         pointPatchField(const pointPatchField<Type>&);
00173 
00174         //- Construct and return a clone
00175         virtual autoPtr<pointPatchField<Type> > clone() const = 0;
00176 
00177         //- Construct as copy setting internal field reference
00178         pointPatchField
00179         (
00180             const pointPatchField<Type>&,
00181             const DimensionedField<Type, pointMesh>&
00182         );
00183 
00184         //- Construct and return a clone setting internal field reference
00185         virtual autoPtr<pointPatchField<Type> > clone
00186         (
00187             const DimensionedField<Type, pointMesh>& iF
00188         ) const = 0;
00189 
00190 
00191     // Selectors
00192 
00193         //- Return a pointer to a new patchField created on freestore given
00194         //  patch and internal field
00195         //  (does not set the patch field values)
00196         static autoPtr<pointPatchField<Type> > New
00197         (
00198             const word&,
00199             const pointPatch&,
00200             const DimensionedField<Type, pointMesh>&
00201         );
00202 
00203         //- Return a pointer to a new patchField created on freestore from
00204         //  a given pointPatchField mapped onto a new patch
00205         static autoPtr<pointPatchField<Type> > New
00206         (
00207             const pointPatchField<Type>&,
00208             const pointPatch&,
00209             const DimensionedField<Type, pointMesh>&,
00210             const pointPatchFieldMapper&
00211         );
00212 
00213         //- Return a pointer to a new patchField created on freestore
00214         //  from dictionary
00215         static autoPtr<pointPatchField<Type> > New
00216         (
00217             const pointPatch&,
00218             const DimensionedField<Type, pointMesh>&,
00219             const dictionary&
00220         );
00221 
00222 
00223         //- Return a pointer to a new CalculatedpointPatchField created on
00224         //  freestore without setting patchField values
00225         template<class Type2>
00226         static autoPtr<pointPatchField<Type> >
00227         NewCalculatedType
00228         (
00229             const pointPatchField<Type2>&
00230         );
00231 
00232 
00233     // Destructor
00234 
00235         virtual ~pointPatchField<Type>()
00236         {}
00237 
00238 
00239     // Member functions
00240 
00241         // Access
00242 
00243             //- Return local objectRegistry
00244             const objectRegistry& db() const;
00245 
00246             //- Return size
00247             label size() const
00248             {
00249                 return patch().size();
00250             }
00251 
00252             //- Return patch
00253             const pointPatch& patch() const
00254             {
00255                 return patch_;
00256             }
00257 
00258             //- Return dimensioned internal field reference
00259             const DimensionedField<Type, pointMesh>&
00260             dimensionedInternalField() const
00261             {
00262                 return internalField_;
00263             }
00264 
00265             //- Return internal field reference
00266             const Field<Type>& internalField() const
00267             {
00268                 return internalField_;
00269             }
00270 
00271             //- Return true if this patch field is coupled
00272             virtual bool coupled() const
00273             {
00274                 return false;
00275             }
00276 
00277             //- Return true if the boundary condition has already been updated
00278             bool updated() const
00279             {
00280                 return updated_;
00281             }
00282 
00283             //- Return field created from appropriate internal field values
00284             tmp<Field<Type> > patchInternalField() const;
00285 
00286             //- Return field created from appropriate internal field values
00287             //  given internal field reference
00288             template<class Type1>
00289             tmp<Field<Type1> > patchInternalField
00290             (
00291                 const Field<Type1>& iF
00292             ) const;
00293 
00294             //- Given the internal field and a patch field,
00295             //  add the patch field to the internal field
00296             template<class Type1>
00297             void addToInternalField
00298             (
00299                 Field<Type1>& iF,
00300                 const Field<Type1>& pF
00301             ) const;
00302 
00303             //- Given the internal field and a patch field,
00304             //  set the patch field in the internal field
00305             template<class Type1>
00306             void setInInternalField
00307             (
00308                 Field<Type1>& iF,
00309                 const Field<Type1>& pF,
00310                 const labelList& meshPoints
00311             ) const;
00312 
00313             //- Given the internal field and a patch field,
00314             //  set the patch field in the internal field
00315             template<class Type1>
00316             void setInInternalField
00317             (
00318                 Field<Type1>& iF,
00319                 const Field<Type1>& pF
00320             ) const;
00321 
00322             //- Return the type of the calculated for of pointPatchField
00323             static const word& calculatedType();
00324 
00325 
00326         // Mapping functions
00327 
00328             //- Map (and resize as needed) from self given a mapping object
00329             virtual void autoMap
00330             (
00331                 const pointPatchFieldMapper&
00332             )
00333             {}
00334 
00335             //- Reverse map the given pointPatchField onto this pointPatchField
00336             virtual void rmap
00337             (
00338                 const pointPatchField<Type>&,
00339                 const labelList&
00340             )
00341             {}
00342 
00343 
00344         // Evaluation functions
00345 
00346             //- Update the coefficients associated with the patch field
00347             //  Sets Updated to true
00348             virtual void updateCoeffs()
00349             {
00350                 updated_ = true;
00351             }
00352 
00353             //- Initialise evaluation of the patch field (do nothing)
00354             virtual void initEvaluate
00355             (
00356                 const Pstream::commsTypes commsType=Pstream::blocking
00357             )
00358             {}
00359 
00360             //- Evaluate the patch field
00361             virtual void evaluate
00362             (
00363                 const Pstream::commsTypes commsType=Pstream::blocking
00364             );
00365 
00366 
00367         //- Write
00368         virtual void write(Ostream&) const;
00369 
00370 
00371     // Member operators
00372 
00373         virtual void operator=
00374         (
00375             const pointPatchField<Type>&
00376         )
00377         {}
00378 
00379         virtual void operator+=
00380         (
00381             const pointPatchField<Type>&
00382         )
00383         {}
00384 
00385         virtual void operator-=
00386         (
00387             const pointPatchField<Type>&
00388         )
00389         {}
00390 
00391         virtual void operator*=
00392         (
00393             const pointPatchField<scalar>&
00394         )
00395         {}
00396 
00397         virtual void operator/=
00398         (
00399             const pointPatchField<scalar>&
00400         )
00401         {}
00402 
00403         virtual void operator=(const Field<Type>&){}
00404         virtual void operator+=(const Field<Type>&){}
00405         virtual void operator-=(const Field<Type>&){}
00406 
00407         virtual void operator*=(const Field<scalar>&){}
00408         virtual void operator/=(const Field<scalar>&){}
00409 
00410         virtual void operator=(const Type&){}
00411         virtual void operator+=(const Type&){}
00412         virtual void operator-=(const Type&){}
00413         virtual void operator*=(const scalar){}
00414         virtual void operator/=(const scalar){}
00415 
00416 
00417         // Force an assignment irrespective of form of patch
00418         // By generic these do nothing unless the patch actually has boundary
00419         // values
00420 
00421             virtual void operator==
00422             (
00423                 const pointPatchField<Type>&
00424             )
00425             {}
00426 
00427             virtual void operator==(const Field<Type>&){}
00428             virtual void operator==(const Type&){}
00429 
00430 
00431     // Ostream operator
00432 
00433         friend Ostream& operator<< <Type>
00434         (
00435             Ostream&,
00436             const pointPatchField<Type>&
00437         );
00438 };
00439 
00440 
00441 // This function is added as a hack to enable simple backward compatability
00442 // with verions using referenceLevel in GeometicField
00443 template<class Type>
00444 const pointPatchField<Type>& operator+
00445 (
00446     const pointPatchField<Type>& ppf,
00447     const Type&
00448 )
00449 {
00450     return ppf;
00451 }
00452 
00453 
00454 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00455 
00456 } // End namespace Foam
00457 
00458 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00459 
00460 #include "pointPatchFieldFunctions.H"
00461 
00462 #ifdef NoRepository
00463 #   include "pointPatchField.C"
00464 #   include "calculatedPointPatchField.H"
00465 #endif
00466 
00467 
00468 #define makePointPatchTypeFieldTypeName(type)                                 \
00469                                                                               \
00470 defineNamedTemplateTypeNameAndDebug(type, 0);
00471 
00472 #define makePointPatchFieldsTypeName(type)                                    \
00473                                                                               \
00474 makePointPatchTypeFieldTypeName(type##PointPatchScalarField);                 \
00475 makePointPatchTypeFieldTypeName(type##PointPatchVectorField);                 \
00476 makePointPatchTypeFieldTypeName(type##PointPatchSphericalTensorField);        \
00477 makePointPatchTypeFieldTypeName(type##PointPatchSymmTensorField);             \
00478 makePointPatchTypeFieldTypeName(type##PointPatchTensorField);
00479 
00480 #define makePointPatchTypeField(PatchTypeField, typePatchTypeField)           \
00481                                                                               \
00482 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                   \
00483                                                                               \
00484 addToRunTimeSelectionTable                                                    \
00485 (                                                                             \
00486     PatchTypeField, typePatchTypeField, pointPatch                            \
00487 );                                                                            \
00488                                                                               \
00489 addToRunTimeSelectionTable                                                    \
00490 (                                                                             \
00491     PatchTypeField,                                                           \
00492     typePatchTypeField,                                                       \
00493     patchMapper                                                               \
00494 );                                                                            \
00495                                                                               \
00496 addToRunTimeSelectionTable                                                    \
00497 (                                                                             \
00498     PatchTypeField, typePatchTypeField, dictionary                            \
00499 );
00500 
00501 
00502 #define makePointPatchFields(type)                                            \
00503                                                                               \
00504 makePointPatchTypeField                                                       \
00505 (                                                                             \
00506     pointPatchScalarField,                                                    \
00507     type##PointPatchScalarField                                               \
00508 );                                                                            \
00509                                                                               \
00510 makePointPatchTypeField                                                       \
00511 (                                                                             \
00512     pointPatchVectorField,                                                    \
00513     type##PointPatchVectorField                                               \
00514 );                                                                            \
00515                                                                               \
00516 makePointPatchTypeField                                                       \
00517 (                                                                             \
00518     pointPatchSphericalTensorField,                                           \
00519     type##PointPatchSphericalTensorField                                      \
00520 );                                                                            \
00521                                                                               \
00522 makePointPatchTypeField                                                       \
00523 (                                                                             \
00524     pointPatchSymmTensorField,                                                \
00525     type##PointPatchSymmTensorField                                           \
00526 );                                                                            \
00527                                                                               \
00528 makePointPatchTypeField                                                       \
00529 (                                                                             \
00530     pointPatchTensorField,                                                    \
00531     type##PointPatchTensorField                                               \
00532 );
00533 
00534 
00535 #define makePointPatchFieldTypedefs(type)                                     \
00536                                                                               \
00537 typedef type##PointPatchField<scalar> type##PointPatchScalarField;            \
00538 typedef type##PointPatchField<vector> type##PointPatchVectorField;            \
00539 typedef type##PointPatchField<sphericalTensor>                                \
00540     type##PointPatchSphericalTensorField;                                     \
00541 typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField;    \
00542 typedef type##PointPatchField<tensor> type##PointPatchTensorField;
00543 
00544 
00545 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00546 
00547 #endif
00548 
00549 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd