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

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