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

fvPatchField.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     fvPatchField
00027 
00028 Description
00029     fvPatchField<Type> abstract base class.  This class gives a fat-interface
00030     to all derived classes covering all possible ways in which they might be
00031     used.  The first level of derivation is to basic patchFields which cover
00032     zero-gradient, fixed-gradient, fixed-value and mixed conditions.  The next
00033     level of derivation covers all the specialised typed with specific
00034     evaluation proceedures, particularly with respect to specific fields.
00035 
00036 SourceFiles
00037     fvPatchField.C
00038     newFvPatchField.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef fvPatchField_H
00043 #define fvPatchField_H
00044 
00045 #include "fvPatch.H"
00046 #include "DimensionedField.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 // Class forward declarations
00054 
00055 class objectRegistry;
00056 class dictionary;
00057 class fvPatchFieldMapper;
00058 class volMesh;
00059 
00060 
00061 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00062 
00063 template<class Type>
00064 class fvPatchField;
00065 
00066 template<class Type>
00067 Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
00068 
00069 
00070 /*---------------------------------------------------------------------------*\
00071                            Class patch Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 template<class Type>
00075 class fvPatchField
00076 :
00077     public Field<Type>
00078 {
00079     // Private data
00080 
00081         //- Reference to patch
00082         const fvPatch& patch_;
00083 
00084         //- Reference to internal field
00085         const DimensionedField<Type, volMesh>& internalField_;
00086 
00087         //- Update index used so that updateCoeffs is called only once during
00088         //  the construction of the matrix
00089         bool updated_;
00090 
00091 
00092 public:
00093 
00094     typedef fvPatch Patch;
00095 
00096 
00097     //- Runtime type information
00098     TypeName("fvPatchField");
00099 
00100     //- Debug switch to disallow the use of 
00101     static int disallowDefaultFvPatchField;
00102 
00103 
00104     // Declare run-time constructor selection tables
00105 
00106         declareRunTimeSelectionTable
00107         (
00108             tmp,
00109             fvPatchField,
00110             patch,
00111             (
00112                 const fvPatch& p,
00113                 const DimensionedField<Type, volMesh>& iF
00114             ),
00115             (p, iF)
00116         );
00117 
00118         declareRunTimeSelectionTable
00119         (
00120             tmp,
00121             fvPatchField,
00122             patchMapper,
00123             (
00124                 const fvPatchField<Type>& ptf,
00125                 const fvPatch& p,
00126                 const DimensionedField<Type, volMesh>& iF,
00127                 const fvPatchFieldMapper& m
00128             ),
00129             (dynamic_cast<const fvPatchFieldType&>(ptf), p, iF, m)
00130         );
00131 
00132         declareRunTimeSelectionTable
00133         (
00134             tmp,
00135             fvPatchField,
00136             dictionary,
00137             (
00138                 const fvPatch& p,
00139                 const DimensionedField<Type, volMesh>& iF,
00140                 const dictionary& dict
00141             ),
00142             (p, iF, dict)
00143         );
00144 
00145 
00146     // Constructors
00147 
00148         //- Construct from patch and internal field
00149         fvPatchField
00150         (
00151             const fvPatch&,
00152             const DimensionedField<Type, volMesh>&
00153         );
00154 
00155         //- Construct from patch and internal field and patch field
00156         fvPatchField
00157         (
00158             const fvPatch&,
00159             const DimensionedField<Type, volMesh>&,
00160             const Field<Type>&
00161         );
00162 
00163         //- Construct from patch, internal field and dictionary
00164         fvPatchField
00165         (
00166             const fvPatch&,
00167             const DimensionedField<Type, volMesh>&,
00168             const dictionary&
00169         );
00170 
00171         //- Construct by mapping the given fvPatchField onto a new patch
00172         fvPatchField
00173         (
00174             const fvPatchField<Type>&,
00175             const fvPatch&,
00176             const DimensionedField<Type, volMesh>&,
00177             const fvPatchFieldMapper&
00178         );
00179 
00180         //- Construct as copy
00181         fvPatchField(const fvPatchField<Type>&);
00182 
00183         //- Construct and return a clone
00184         virtual tmp<fvPatchField<Type> > clone() const
00185         {
00186             return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this));
00187         }
00188 
00189         //- Construct as copy setting internal field reference
00190         fvPatchField
00191         (
00192             const fvPatchField<Type>&,
00193             const DimensionedField<Type, volMesh>&
00194         );
00195 
00196         //- Construct and return a clone setting internal field reference
00197         virtual tmp<fvPatchField<Type> > clone
00198         (
00199             const DimensionedField<Type, volMesh>& iF
00200         ) const
00201         {
00202             return tmp<fvPatchField<Type> >(new fvPatchField<Type>(*this, iF));
00203         }
00204 
00205 
00206     // Selectors
00207 
00208         //- Return a pointer to a new patchField created on freestore given
00209         //  patch and internal field
00210         //  (does not set the patch field values)
00211         static tmp<fvPatchField<Type> > New
00212         (
00213             const word&,
00214             const fvPatch&,
00215             const DimensionedField<Type, volMesh>&
00216         );
00217 
00218         //- Return a pointer to a new patchField created on freestore from
00219         //  a given fvPatchField mapped onto a new patch
00220         static tmp<fvPatchField<Type> > New
00221         (
00222             const fvPatchField<Type>&,
00223             const fvPatch&,
00224             const DimensionedField<Type, volMesh>&,
00225             const fvPatchFieldMapper&
00226         );
00227 
00228         //- Return a pointer to a new patchField created on freestore
00229         //  from dictionary
00230         static tmp<fvPatchField<Type> > New
00231         (
00232             const fvPatch&,
00233             const DimensionedField<Type, volMesh>&,
00234             const dictionary&
00235         );
00236 
00237         //- Return a pointer to a new calculatedFvPatchField created on
00238         //  freestore without setting patchField values
00239         template<class Type2>
00240         static tmp<fvPatchField<Type> > NewCalculatedType
00241         (
00242             const fvPatchField<Type2>&
00243         );
00244 
00245 
00246     // Destructor
00247 
00248         virtual ~fvPatchField<Type>()
00249         {}
00250 
00251 
00252     // Member functions
00253 
00254         // Access
00255 
00256             //- Return local objectRegistry
00257             const objectRegistry& db() const;
00258 
00259             //- Return patch
00260             const fvPatch& patch() const
00261             {
00262                 return patch_;
00263             }
00264 
00265             //- Return dimensioned internal field reference
00266             const DimensionedField<Type, volMesh>&
00267             dimensionedInternalField() const
00268             {
00269                 return internalField_;
00270             }
00271 
00272             //- Return internal field reference
00273             const Field<Type>& internalField() const
00274             {
00275                 return internalField_;
00276             }
00277 
00278             //- Return the type of the calculated for of fvPatchField
00279             static const word& calculatedType();
00280 
00281             //- Return true if this patch field fixes a value.
00282             //  Needed to check if a level has to be specified while solving
00283             //  Poissons equations.
00284             virtual bool fixesValue() const
00285             {
00286                 return false;
00287             }
00288 
00289             //- Return true if this patch field is coupled
00290             virtual bool coupled() const
00291             {
00292                 return false;
00293             }
00294 
00295             //- Return true if the boundary condition has already been updated
00296             bool updated() const
00297             {
00298                 return updated_;
00299             }
00300 
00301 
00302         // Mapping functions
00303 
00304             //- Map (and resize as needed) from self given a mapping object
00305             virtual void autoMap
00306             (
00307                 const fvPatchFieldMapper&
00308             );
00309 
00310             //- Reverse map the given fvPatchField onto this fvPatchField
00311             virtual void rmap
00312             (
00313                 const fvPatchField<Type>&,
00314                 const labelList&
00315             );
00316 
00317 
00318         // Evaluation functions
00319 
00320             //- Return patch-normal gradient
00321             virtual tmp<Field<Type> > snGrad() const;
00322 
00323             //- Update the coefficients associated with the patch field
00324             //  Sets Updated to true
00325             virtual void updateCoeffs()
00326             {
00327                 updated_ = true;
00328             }
00329 
00330             //- Return internal field next to patch as patch field
00331             virtual tmp<Field<Type> > patchInternalField() const;
00332 
00333             //- Return patchField on the opposite patch of a coupled patch
00334             virtual tmp<Field<Type> > patchNeighbourField() const
00335             {
00336                 notImplemented(type() + "patchNeighbourField()");
00337                 return *this;
00338             }
00339 
00340             //- Initialise the evaluation of the patch field
00341             virtual void initEvaluate(const bool=false)
00342             {}
00343 
00344             //- Evaluate the patch field, sets Updated to false
00345             virtual void evaluate();
00346 
00347 
00348             //- Return the matrix diagonal coefficients corresponding to the
00349             //  evaluation of the value of this patchField with given weights
00350             virtual tmp<Field<Type> > valueInternalCoeffs
00351             (
00352                 const tmp<Field<scalar> >&
00353             ) const
00354             {
00355                 notImplemented
00356                 (
00357                     type()
00358                   + "::valueInternalCoeffs(const tmp<Field<scalar> >&)"
00359                 );
00360                 return *this;
00361             }
00362 
00363             //- Return the matrix source coefficients corresponding to the
00364             //  evaluation of the value of this patchField with given weights
00365             virtual tmp<Field<Type> > valueBoundaryCoeffs
00366             (
00367                 const tmp<Field<scalar> >&
00368             ) const
00369             {
00370                 notImplemented
00371                 (
00372                     type()
00373                   + "::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
00374                 );
00375                 return *this;
00376             }
00377 
00378             //- Return the matrix diagonal coefficients corresponding to the
00379             //  evaluation of the gradient of this patchField
00380             virtual tmp<Field<Type> > gradientInternalCoeffs() const
00381             {
00382                 notImplemented(type() + "::gradientInternalCoeffs()");
00383                 return *this;
00384             }
00385 
00386             //- Return the matrix source coefficients corresponding to the
00387             //  evaluation of the gradient of this patchField
00388             virtual tmp<Field<Type> > gradientBoundaryCoeffs() const
00389             {
00390                 notImplemented(type() + "::gradientBoundaryCoeffs()");
00391                 return *this;
00392             }
00393 
00394 
00395         //- Write
00396         virtual void write(Ostream&) const;
00397 
00398 
00399         // Check
00400 
00401             //- Check fvPatchField<Type> against given fvPatchField<Type>
00402             void check(const fvPatchField<Type>&) const;
00403 
00404 
00405     // Member operators
00406 
00407         virtual void operator=(const UList<Type>&);
00408 
00409         virtual void operator=(const fvPatchField<Type>&);
00410         virtual void operator+=(const fvPatchField<Type>&);
00411         virtual void operator-=(const fvPatchField<Type>&);
00412         virtual void operator*=(const fvPatchField<scalar>&);
00413         virtual void operator/=(const fvPatchField<scalar>&);
00414 
00415         virtual void operator+=(const Field<Type>&);
00416         virtual void operator-=(const Field<Type>&);
00417 
00418         virtual void operator*=(const Field<scalar>&);
00419         virtual void operator/=(const Field<scalar>&);
00420 
00421         virtual void operator=(const Type&);
00422         virtual void operator+=(const Type&);
00423         virtual void operator-=(const Type&);
00424         virtual void operator*=(const scalar);
00425         virtual void operator/=(const scalar);
00426 
00427 
00428         // Force an assignment irrespective of form of patch
00429 
00430         virtual void operator==(const fvPatchField<Type>&);
00431         virtual void operator==(const Field<Type>&);
00432         virtual void operator==(const Type&);
00433 
00434 
00435     // Ostream operator
00436 
00437         friend Ostream& operator<< <Type>(Ostream&, const fvPatchField<Type>&);
00438 };
00439 
00440 
00441 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00442 
00443 } // End namespace Foam
00444 
00445 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00446 
00447 #ifdef NoRepository
00448 #   include "fvPatchField.C"
00449 #   include "calculatedFvPatchField.H"
00450 #endif
00451 
00452 
00453 #define makePatchTypeFieldTypeName(type)                                   \
00454                                                                            \
00455 defineNamedTemplateTypeNameAndDebug(type, 0);
00456 
00457 #define makePatchFieldsTypeName(type)                                      \
00458                                                                            \
00459 makePatchTypeFieldTypeName(type##FvPatchScalarField);                      \
00460 makePatchTypeFieldTypeName(type##FvPatchVectorField);                      \
00461 makePatchTypeFieldTypeName(type##FvPatchSphericalTensorField);             \
00462 makePatchTypeFieldTypeName(type##FvPatchSymmTensorField);                  \
00463 makePatchTypeFieldTypeName(type##FvPatchTensorField);
00464 
00465 #define makePatchTypeField(PatchTypeField, typePatchTypeField)             \
00466                                                                            \
00467 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
00468                                                                            \
00469 addToRunTimeSelectionTable                                                 \
00470 (                                                                          \
00471     PatchTypeField, typePatchTypeField, patch                              \
00472 );                                                                         \
00473                                                                            \
00474 addToRunTimeSelectionTable                                                 \
00475 (                                                                          \
00476     PatchTypeField,                                                        \
00477     typePatchTypeField,                                                    \
00478     patchMapper                                                            \
00479 );                                                                         \
00480                                                                            \
00481 addToRunTimeSelectionTable                                                 \
00482 (                                                                          \
00483     PatchTypeField, typePatchTypeField, dictionary                         \
00484 );
00485 
00486 
00487 #define makePatchFields(type)                                              \
00488                                                                            \
00489 makePatchTypeField(fvPatchScalarField, type##FvPatchScalarField);          \
00490 makePatchTypeField(fvPatchVectorField, type##FvPatchVectorField);          \
00491 makePatchTypeField                                                         \
00492 (                                                                          \
00493     fvPatchSphericalTensorField,                                           \
00494     type##FvPatchSphericalTensorField                                      \
00495 );                                                                         \
00496 makePatchTypeField(fvPatchSymmTensorField, type##FvPatchSymmTensorField);  \
00497 makePatchTypeField(fvPatchTensorField, type##FvPatchTensorField);
00498 
00499 
00500 #define makePatchTypeFieldTypedefs(type)                                   \
00501                                                                            \
00502 typedef type##FvPatchField<scalar> type##FvPatchScalarField;               \
00503 typedef type##FvPatchField<vector> type##FvPatchVectorField;               \
00504 typedef type##FvPatchField<sphericalTensor>                                \
00505     type##FvPatchSphericalTensorField;                                     \
00506 typedef type##FvPatchField<symmTensor> type##FvPatchSymmTensorField;       \
00507 typedef type##FvPatchField<tensor> type##FvPatchTensorField;
00508 
00509 
00510 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00511 
00512 #endif
00513 
00514 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd