OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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