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

fvsPatchField.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     fvsPatchField
00027 
00028 Description
00029     fvsPatchField<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     fvsPatchField.C
00038     newFvsPatchField.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef fvsPatchField_H
00043 #define fvsPatchField_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 surfaceMesh;
00059 
00060 
00061 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00062 
00063 template<class Type>
00064 class fvsPatchField;
00065 
00066 template<class Type>
00067 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
00068 
00069 
00070 /*---------------------------------------------------------------------------*\
00071                            Class patch Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 template<class Type>
00075 class fvsPatchField
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, surfaceMesh>& internalField_;
00086 
00087 
00088 public:
00089 
00090     typedef fvPatch Patch;
00091 
00092 
00093     //- Runtime type information
00094     TypeName("fvsPatchField");
00095 
00096     //- Debug switch to disallow the use of 
00097     static int disallowDefaultFvsPatchField;
00098 
00099 
00100     // Declare run-time constructor selection tables
00101 
00102         declareRunTimeSelectionTable
00103         (
00104             tmp,
00105             fvsPatchField,
00106             patch,
00107             (
00108                 const fvPatch& p,
00109                 const DimensionedField<Type, surfaceMesh>& iF
00110             ),
00111             (p, iF)
00112         );
00113 
00114         declareRunTimeSelectionTable
00115         (
00116             tmp,
00117             fvsPatchField,
00118             patchMapper,
00119             (
00120                 const fvsPatchField<Type>& ptf,
00121                 const fvPatch& p,
00122                 const DimensionedField<Type, surfaceMesh>& iF,
00123                 const fvPatchFieldMapper& m
00124             ),
00125             (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
00126         );
00127 
00128         declareRunTimeSelectionTable
00129         (
00130             tmp,
00131             fvsPatchField,
00132             dictionary,
00133             (
00134                 const fvPatch& p,
00135                 const DimensionedField<Type, surfaceMesh>& iF,
00136                 const dictionary& dict
00137             ),
00138             (p, iF, dict)
00139         );
00140 
00141 
00142     // Constructors
00143 
00144         //- Construct from patch and internal field
00145         fvsPatchField
00146         (
00147             const fvPatch&,
00148             const DimensionedField<Type, surfaceMesh>&
00149         );
00150 
00151         //- Construct from patch and internal field and patch field
00152         fvsPatchField
00153         (
00154             const fvPatch&,
00155             const DimensionedField<Type, surfaceMesh>&,
00156             const Field<Type>&
00157         );
00158 
00159         //- Construct from patch, internal field and dictionary
00160         fvsPatchField
00161         (
00162             const fvPatch&,
00163             const DimensionedField<Type, surfaceMesh>&,
00164             const dictionary&
00165         );
00166 
00167         //- Construct by mapping the given fvsPatchField onto a new patch
00168         fvsPatchField
00169         (
00170             const fvsPatchField<Type>&,
00171             const fvPatch&,
00172             const DimensionedField<Type, surfaceMesh>&,
00173             const fvPatchFieldMapper&
00174         );
00175 
00176         //- Construct as copy
00177         fvsPatchField(const fvsPatchField<Type>&);
00178 
00179         //- Construct and return a clone
00180         virtual tmp<fvsPatchField<Type> > clone() const
00181         {
00182             return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
00183         }
00184 
00185         //- Construct as copy setting internal field reference
00186         fvsPatchField
00187         (
00188             const fvsPatchField<Type>&,
00189             const DimensionedField<Type, surfaceMesh>&
00190         );
00191 
00192         //- Construct and return a clone setting internal field reference
00193         virtual tmp<fvsPatchField<Type> > clone
00194         (
00195             const DimensionedField<Type, surfaceMesh>& iF
00196         ) const
00197         {
00198             return tmp<fvsPatchField<Type> >
00199             (
00200                 new fvsPatchField<Type>(*this, iF)
00201             );
00202         }
00203 
00204 
00205     // Selectors
00206 
00207         //- Return a pointer to a new patchField created on freestore given
00208         //  patch and internal field
00209         //  (does not set the patch field values)
00210         static tmp<fvsPatchField<Type> > New
00211         (
00212             const word&,
00213             const fvPatch&,
00214             const DimensionedField<Type, surfaceMesh>&
00215         );
00216 
00217         //- Return a pointer to a new patchField created on freestore from
00218         //  a given fvsPatchField mapped onto a new patch
00219         static tmp<fvsPatchField<Type> > New
00220         (
00221             const fvsPatchField<Type>&,
00222             const fvPatch&,
00223             const DimensionedField<Type, surfaceMesh>&,
00224             const fvPatchFieldMapper&
00225         );
00226 
00227         //- Return a pointer to a new patchField created on freestore
00228         //  from dictionary
00229         static tmp<fvsPatchField<Type> > New
00230         (
00231             const fvPatch&,
00232             const DimensionedField<Type, surfaceMesh>&,
00233             const dictionary&
00234         );
00235 
00236         //- Return a pointer to a new calculatedFvsPatchField created on
00237         //  freestore without setting patchField values
00238         template<class Type2>
00239         static tmp<fvsPatchField<Type> > NewCalculatedType
00240         (
00241             const fvsPatchField<Type2>&
00242         );
00243 
00244 
00245     // Destructor
00246 
00247         virtual ~fvsPatchField<Type>()
00248         {}
00249 
00250 
00251     // Member functions
00252 
00253         // Access
00254 
00255             //- Return local objectRegistry
00256             const objectRegistry& db() const;
00257 
00258             //- Return patch
00259             const fvPatch& patch() const
00260             {
00261                 return patch_;
00262             }
00263 
00264             //- Return dimensioned internal field reference
00265             const DimensionedField<Type, surfaceMesh>&
00266             dimensionedInternalField() const
00267             {
00268                 return internalField_;
00269             }
00270 
00271             //- Return internal field reference
00272             const Field<Type>& internalField() const
00273             {
00274                 return internalField_;
00275             }
00276 
00277             //- Return the type of the calculated for of fvsPatchField
00278             static const word& calculatedType();
00279 
00280             //- Return true if this patch field fixes a value.
00281             //  Needed to check if a level has to be specified while solving
00282             //  Poissons equations.
00283             virtual bool fixesValue() const
00284             {
00285                 return false;
00286             }
00287 
00288             //- Return true if this patch field is coupled
00289             virtual bool coupled() const
00290             {
00291                 return false;
00292             }
00293 
00294 
00295         // Mapping functions
00296 
00297             //- Map (and resize as needed) from self given a mapping object
00298             virtual void autoMap
00299             (
00300                 const fvPatchFieldMapper&
00301             );
00302 
00303             //- Reverse map the given fvsPatchField onto this fvsPatchField
00304             virtual void rmap
00305             (
00306                 const fvsPatchField<Type>&,
00307                 const labelList&
00308             );
00309 
00310 
00311         //- Write
00312         virtual void write(Ostream&) const;
00313 
00314 
00315         // Check
00316 
00317             //- Check fvsPatchField<Type> against given fvsPatchField<Type>
00318             void check(const fvsPatchField<Type>&) const;
00319 
00320 
00321     // Member operators
00322 
00323         virtual void operator=(const UList<Type>&);
00324 
00325         virtual void operator=(const fvsPatchField<Type>&);
00326         virtual void operator+=(const fvsPatchField<Type>&);
00327         virtual void operator-=(const fvsPatchField<Type>&);
00328         virtual void operator*=(const fvsPatchField<scalar>&);
00329         virtual void operator/=(const fvsPatchField<scalar>&);
00330 
00331         virtual void operator+=(const Field<Type>&);
00332         virtual void operator-=(const Field<Type>&);
00333 
00334         virtual void operator*=(const Field<scalar>&);
00335         virtual void operator/=(const Field<scalar>&);
00336 
00337         virtual void operator=(const Type&);
00338         virtual void operator+=(const Type&);
00339         virtual void operator-=(const Type&);
00340         virtual void operator*=(const scalar);
00341         virtual void operator/=(const scalar);
00342 
00343 
00344         // Force an assignment irrespective of form of patch
00345 
00346         virtual void operator==(const fvsPatchField<Type>&);
00347         virtual void operator==(const Field<Type>&);
00348         virtual void operator==(const Type&);
00349 
00350 
00351     // Ostream operator
00352 
00353         friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
00354 };
00355 
00356 
00357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00358 
00359 } // End namespace Foam
00360 
00361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00362 
00363 #ifdef NoRepository
00364 #   include "fvsPatchField.C"
00365 #   include "calculatedFvsPatchField.H"
00366 #endif
00367 
00368 
00369 #define makeFvsPatchTypeFieldTypeName(type)                                \
00370                                                                            \
00371 defineNamedTemplateTypeNameAndDebug(type, 0);
00372 
00373 #define makeFvsPatchFieldsTypeName(type)                                   \
00374                                                                            \
00375 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField);                  \
00376 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField);                  \
00377 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField);         \
00378 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField);              \
00379 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
00380 
00381 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField)          \
00382                                                                            \
00383 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
00384                                                                            \
00385 addToRunTimeSelectionTable                                                 \
00386 (                                                                          \
00387     PatchTypeField, typePatchTypeField, patch                              \
00388 );                                                                         \
00389                                                                            \
00390 addToRunTimeSelectionTable                                                 \
00391 (                                                                          \
00392     PatchTypeField,                                                        \
00393     typePatchTypeField,                                                    \
00394     patchMapper                                                            \
00395 );                                                                         \
00396                                                                            \
00397 addToRunTimeSelectionTable                                                 \
00398 (                                                                          \
00399     PatchTypeField, typePatchTypeField, dictionary                         \
00400 );
00401 
00402 
00403 #define makeFvsPatchFields(type)                                           \
00404                                                                            \
00405 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField);     \
00406 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField);     \
00407 makeFvsPatchTypeField                                                      \
00408 (                                                                          \
00409     fvsPatchSphericalTensorField,                                          \
00410     type##FvsPatchSphericalTensorField                                     \
00411 );                                                                         \
00412 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
00413 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
00414 
00415 
00416 #define makeFvsPatchTypeFieldTypedefs(type)                                \
00417                                                                            \
00418 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField;             \
00419 typedef type##FvsPatchField<vector> type##FvsPatchVectorField;             \
00420 typedef type##FvsPatchField<sphericalTensor>                               \
00421     type##FvsPatchSphericalTensorField;                                    \
00422 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField;     \
00423 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
00424 
00425 
00426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00427 
00428 #endif
00429 
00430 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd