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