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

porousZone.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::porousZone
00026 
00027 Description
00028     Porous zone definition based on cell zones.
00029 
00030     Porous zone definition based on cell zones and parameters obtained from a
00031     control dictionary constructed from the given stream. The orientation of
00032     the porous region is defined with the same notation as a coordinateSystem,
00033     but only a Cartesian coordinate system is valid.
00034 
00035     Implemented porosity models:
00036 
00037     powerLaw (@e C0 and @e C1 parameters)
00038     @f[
00039         S = - \rho C_0 |U|^{(C_1 - 1)/2} U
00040     @f]
00041 
00042     Darcy-Forchheimer (@e d and @e f parameters)
00043     @f[
00044         S = - (\mu \, d + \frac{\rho |U|}{2} \, f) U
00045     @f]
00046 
00047 
00048     Since negative Darcy/Forchheimer parameters are invalid, they can be used
00049     to specify a multiplier (of the max component).
00050 
00051     The porousZones method porousZones::ddt() mirrors the normal fvm::ddt()
00052     method, but accounts for the effective volume of the cells.
00053 
00054 See Also
00055     porousZones and coordinateSystems
00056 
00057 SourceFiles
00058     porousZone.C
00059     porousZoneTemplates.C
00060 
00061 \*---------------------------------------------------------------------------*/
00062 
00063 #ifndef porousZone_H
00064 #define porousZone_H
00065 
00066 #include <OpenFOAM/dictionary.H>
00067 #include <meshTools/coordinateSystem.H>
00068 #include <meshTools/coordinateSystems.H>
00069 #include <OpenFOAM/wordList.H>
00070 #include <OpenFOAM/labelList.H>
00071 #include <OpenFOAM/dimensionedScalar.H>
00072 #include <OpenFOAM/dimensionedTensor.H>
00073 #include <OpenFOAM/primitiveFieldsFwd.H>
00074 #include <finiteVolume/volFieldsFwd.H>
00075 #include <finiteVolume/fvMatricesFwd.H>
00076 
00077 #include <finiteVolume/fvMesh.H>
00078 
00079 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00080 
00081 namespace Foam
00082 {
00083 
00084 class fvMesh;
00085 
00086 /*---------------------------------------------------------------------------*\
00087                         Class porousZone Declaration
00088 \*---------------------------------------------------------------------------*/
00089 
00090 class porousZone
00091 {
00092     // Private data
00093 
00094         //- Name of this zone
00095         word name_;
00096 
00097         //- Reference to the finite volume mesh this zone is part of
00098         const fvMesh& mesh_;
00099 
00100         //- Dictionary containing the parameters
00101         dictionary dict_;
00102 
00103         //- Cell zone ID
00104         label cellZoneID_;
00105 
00106         //- Coordinate system used for the zone (Cartesian)
00107         coordinateSystem coordSys_;
00108 
00109         //- porosity of the zone (0 < porosity <= 1)
00110         //  Placeholder for treatment of temporal terms.
00111         //  Currently unused.
00112         scalar porosity_;
00113 
00114         //- powerLaw coefficient C0
00115         scalar C0_;
00116 
00117         //- powerLaw coefficient C1
00118         scalar C1_;
00119 
00120         //- Darcy coefficient
00121         dimensionedTensor D_;
00122 
00123         //- Forchheimer coefficient
00124         dimensionedTensor F_;
00125 
00126 
00127     // Private Member Functions
00128 
00129         //- adjust negative resistance values to be multiplier of max value
00130         static void adjustNegativeResistance(dimensionedVector& resist);
00131 
00132         //- Power-law resistance
00133         template<class RhoFieldType>
00134         void addPowerLawResistance
00135         (
00136             scalarField& Udiag,
00137             const labelList& cells,
00138             const scalarField& V,
00139             const RhoFieldType& rho,
00140             const vectorField& U
00141         ) const;
00142 
00143         //- Viscous and inertial resistance
00144         template<class RhoFieldType>
00145         void addViscousInertialResistance
00146         (
00147             scalarField& Udiag,
00148             vectorField& Usource,
00149             const labelList& cells,
00150             const scalarField& V,
00151             const RhoFieldType& rho,
00152             const scalarField& mu,
00153             const vectorField& U
00154         ) const;
00155 
00156 
00157         //- Power-law resistance
00158         template<class RhoFieldType>
00159         void addPowerLawResistance
00160         (
00161             tensorField& AU,
00162             const labelList& cells,
00163             const RhoFieldType& rho,
00164             const vectorField& U
00165         ) const;
00166 
00167         //- Viscous and inertial resistance
00168         template<class RhoFieldType>
00169         void addViscousInertialResistance
00170         (
00171             tensorField& AU,
00172             const labelList& cells,
00173             const RhoFieldType& rho,
00174             const scalarField& mu,
00175             const vectorField& U
00176         ) const;
00177 
00178 
00179         //- Disallow default bitwise copy construct
00180         porousZone(const porousZone&);
00181 
00182         //- Disallow default bitwise assignment
00183         void operator=(const porousZone&);
00184 
00185 
00186 public:
00187 
00188     // Constructors
00189 
00190         //- Construct from components
00191         porousZone(const word& name, const fvMesh&, const dictionary&);
00192 
00193         //- Return clone
00194         autoPtr<porousZone> clone() const
00195         {
00196             notImplemented("autoPtr<porousZone> clone() const");
00197             return autoPtr<porousZone>(NULL);
00198         }
00199 
00200         //- Return pointer to new porousZone created on freestore from Istream
00201         class iNew
00202         {
00203             //- Reference to the finite volume mesh this zone is part of
00204             const fvMesh& mesh_;
00205 
00206         public:
00207 
00208             iNew(const fvMesh& mesh)
00209             :
00210                 mesh_(mesh)
00211             {}
00212 
00213             autoPtr<porousZone> operator()(Istream& is) const
00214             {
00215                 word name(is);
00216                 dictionary dict(is);
00217 
00218                 return autoPtr<porousZone>(new porousZone(name, mesh_, dict));
00219             }
00220         };
00221 
00222 
00223     //- Destructor
00224     virtual ~porousZone()
00225     {}
00226 
00227 
00228     // Member Functions
00229 
00230         // Access
00231 
00232             //- cellZone name
00233             const word& zoneName() const
00234             {
00235                 return name_;
00236             }
00237 
00238             //- Return mesh
00239             const fvMesh& mesh() const
00240             {
00241                 return mesh_;
00242             }
00243 
00244             //- cellZone number
00245             label zoneId() const
00246             {
00247                 return cellZoneID_;
00248             }
00249 
00250             //- dictionary values used for the porousZone
00251             const dictionary& dict() const
00252             {
00253                 return dict_;
00254             }
00255 
00256             //- Return coordinate system
00257             const coordinateSystem& coordSys() const
00258             {
00259                 return coordSys_;
00260             }
00261 
00262             //- Return origin
00263             const point& origin() const
00264             {
00265                 return coordSys_.origin();
00266             }
00267 
00268             //- Return axis
00269             vector axis() const
00270             {
00271                 return coordSys_.axis();
00272             }
00273 
00274             //- Return porosity
00275             scalar porosity() const
00276             {
00277                 return porosity_;
00278             }
00279 
00280             //- Edit access to porosity
00281             scalar& porosity()
00282             {
00283                 return porosity_;
00284             }
00285 
00286 
00287         //- Modify time derivative elements according to porosity
00288         template<class Type>
00289         void modifyDdt(fvMatrix<Type>&) const;
00290 
00291         //- Add the viscous and inertial resistance force contribution
00292         //  to the momentum equation
00293         void addResistance(fvVectorMatrix& UEqn) const;
00294 
00295         //- Add the viscous and inertial resistance force contribution
00296         //  to the tensorial diagonal.
00297         //  Optionally correct the processor BCs of AU.
00298         void addResistance
00299         (
00300             const fvVectorMatrix& UEqn,
00301             volTensorField& AU,
00302             bool correctAUprocBC = true
00303         ) const;
00304 
00305         //- Write the porousZone dictionary
00306         virtual void writeDict(Ostream&, bool subDict = true) const;
00307 
00308 
00309     // Ostream Operator
00310 
00311         friend Ostream& operator<<(Ostream&, const porousZone&);
00312 };
00313 
00314 
00315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00316 
00317 } // End namespace Foam
00318 
00319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00320 
00321 #ifdef NoRepository
00322 #   include <finiteVolume/porousZoneTemplates.C>
00323 #endif
00324 
00325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00326 
00327 #endif
00328 
00329 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines