initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / cfdTools / general / porousMedia / porousZone.H
blob5b4d16af5f6ebe4e498db526856656cc0c8ab2ae
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::porousZone
28 Description
29     Porous zone definition based on cell zones.
31     Porous zone definition based on cell zones and parameters obtained from a
32     control dictionary constructed from the given stream. The orientation of
33     the porous region is defined with the same notation as a coordinateSystem,
34     but only a Cartesian coordinate system is valid.
36     Implemented porosity models:
38     powerLaw (@e C0 and @e C1 parameters)
39     @f[
40         S = - \rho C_0 |U|^{(C_1 - 1)/2} U
41     @f]
43     Darcy-Forchheimer (@e d and @e f parameters)
44     @f[
45         S = - (\mu \, d \, U + \frac{\rho |U|}{2} \, f) U
46     @f]
49     Since negative Darcy/Forchheimer parameters are invalid, they can be used
50     to specify a multiplier (of the max component).
52     The porousZones method porousZones::ddt() mirrors the normal fvm::ddt()
53     method, but accounts for the effective volume of the cells.
55 See Also
56     porousZones and coordinateSystems
58 SourceFiles
59     porousZone.C
60     porousZoneTemplates.C
62 \*---------------------------------------------------------------------------*/
64 #ifndef porousZone_H
65 #define porousZone_H
67 #include "dictionary.H"
68 #include "coordinateSystem.H"
69 #include "coordinateSystems.H"
70 #include "wordList.H"
71 #include "labelList.H"
72 #include "dimensionedScalar.H"
73 #include "dimensionedTensor.H"
74 #include "primitiveFieldsFwd.H"
75 #include "volFieldsFwd.H"
76 #include "fvMatricesFwd.H"
78 #include "fvMesh.H"
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 namespace Foam
85 class fvMesh;
87 /*---------------------------------------------------------------------------*\
88                         Class porousZone Declaration
89 \*---------------------------------------------------------------------------*/
91 class porousZone
93     // Private data
95         //- Name of this zone
96         word name_;
98         //- Reference to the finite volume mesh this zone is part of
99         const fvMesh& mesh_;
101         //- Dictionary containing the parameters
102         dictionary dict_;
104         //- Cell zone ID
105         label cellZoneID_;
107         //- Coordinate system used for the zone (Cartesian)
108         coordinateSystem coordSys_;
110         //- porosity of the zone (0 < porosity <= 1)
111         //  Placeholder for treatment of temporal terms.
112         //  Currently unused.
113         scalar porosity_;
115         //- powerLaw coefficient C0
116         scalar C0_;
118         //- powerLaw coefficient C1
119         scalar C1_;
121         //- Darcy coefficient
122         dimensionedTensor D_;
124         //- Forchheimer coefficient
125         dimensionedTensor F_;
128     // Private Member Functions
130         //- adjust negative resistance values to be multiplier of max value
131         static void adjustNegativeResistance(dimensionedVector& resist);
133         //- Power-law resistance
134         template<class RhoFieldType>
135         void addPowerLawResistance
136         (
137             scalarField& Udiag,
138             const labelList& cells,
139             const scalarField& V,
140             const RhoFieldType& rho,
141             const vectorField& U
142         ) const;
144         //- Viscous and inertial resistance
145         template<class RhoFieldType>
146         void addViscousInertialResistance
147         (
148             scalarField& Udiag,
149             vectorField& Usource,
150             const labelList& cells,
151             const scalarField& V,
152             const RhoFieldType& rho,
153             const scalarField& mu,
154             const vectorField& U
155         ) const;
158         //- Power-law resistance
159         template<class RhoFieldType>
160         void addPowerLawResistance
161         (
162             tensorField& AU,
163             const labelList& cells,
164             const RhoFieldType& rho,
165             const vectorField& U
166         ) const;
168         //- Viscous and inertial resistance
169         template<class RhoFieldType>
170         void addViscousInertialResistance
171         (
172             tensorField& AU,
173             const labelList& cells,
174             const RhoFieldType& rho,
175             const scalarField& mu,
176             const vectorField& U
177         ) const;
180         //- Disallow default bitwise copy construct
181         porousZone(const porousZone&);
183         //- Disallow default bitwise assignment
184         void operator=(const porousZone&);
187 public:
189     // Constructors
191         //- Construct from components
192         porousZone(const word& name, const fvMesh&, const dictionary&);
194         //- Return clone
195         autoPtr<porousZone> clone() const
196         {
197             notImplemented("autoPtr<porousZone> clone() const");
198             return autoPtr<porousZone>(NULL);
199         }
202         //- Return pointer to new porousZone created on freestore from Istream
203         class iNew
204         {
205             //- Reference to the finite volume mesh this zone is part of
206             const fvMesh& mesh_;
208         public:
210             iNew(const fvMesh& mesh)
211             :
212                 mesh_(mesh)
213             {}
215             autoPtr<porousZone> operator()(Istream& is) const
216             {
217                 word name(is);
218                 dictionary dict(is);
220                 return autoPtr<porousZone>(new porousZone(name, mesh_, dict));
221             }
222         };
225     // Member Functions
227         // Access
229             //- cellZone name
230             const word& zoneName() const
231             {
232                 return name_;
233             }
235             //- cellZone number
236             label zoneId() const
237             {
238                 return cellZoneID_;
239             }
241             //- dictionary values used for the porousZone
242             const dictionary& dict() const
243             {
244                 return dict_;
245             }
247             //- Return coordinate system
248             const coordinateSystem& coordSys() const
249             {
250                 return coordSys_;
251             }
253             //- Return origin
254             const point& origin() const
255             {
256                 return coordSys_.origin();
257             }
259             //- Return axis
260             const vector& axis() const
261             {
262                 return coordSys_.axis();
263             }
265             //- Return porosity
266             const scalar& porosity() const
267             {
268                 return porosity_;
269             }
271             //- Edit access to porosity
272             scalar& porosity()
273             {
274                 return porosity_;
275             }
278         //- modify time derivative elements according to porosity
279         template<class Type>
280         void modifyDdt(fvMatrix<Type>&) const;
282         //- Add the viscous and inertial resistance force contribution
283         //  to the momentum equation
284         void addResistance(fvVectorMatrix& UEqn) const;
286         //- Add the viscous and inertial resistance force contribution
287         //  to the tensorial diagonal.
288         //  Optionally correct the processor BCs of AU.
289         void addResistance
290         (
291             const fvVectorMatrix& UEqn,
292             volTensorField& AU,
293             bool correctAUprocBC = true
294         ) const;
296         //- Write the porousZone dictionary
297         void writeDict(Ostream&, bool subDict = true) const;
300     // Ostream Operator
302         friend Ostream& operator<<(Ostream&, const porousZone&);
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 } // End namespace Foam
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 #ifdef NoRepository
313 #   include "porousZoneTemplates.C"
314 #endif
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 #endif
320 // ************************************************************************* //