FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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