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

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