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