1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Namespace for models related to porous media
34 Porous zone definition based on cell zones.
36 Porous zone definition based on cell zones and parameters obtained from a
37 control dictionary constructed from the given stream. The orientation of
38 the porous region is defined with the same notation as a coordinateSystem,
39 but only a Cartesian coordinate system is valid.
41 Implemented porosity models:
43 powerLaw (\e C0 and \e C1 parameters)
45 S = - \rho C_0 |U|^{(C_1 - 1)/2} U
48 Darcy-Forchheimer (@e d and \e f parameters)
50 S = - (\mu \, d + \frac{\rho |U|}{2} \, f) U
54 Since negative Darcy/Forchheimer parameters are invalid, they can be used
55 to specify a multiplier (of the max component).
57 The porousZones method porousZones::ddt() mirrors the normal fvm::ddt()
58 method, but accounts for the effective volume of the cells.
60 An example dictionary entry:
65 coordinateSystem system_10;
67 intensity 0.001; // optional
68 mixingLength 0.0001; // optional
69 printCoeffs yes; // optional: feedback for the user
73 d d [0 -2 0 0 0] (-1000 -1000 5.3756e+07);
74 f f [0 -1 0 0 0] (-1000 -1000 15.83);
80 porousZones and coordinateSystems
86 \*---------------------------------------------------------------------------*/
91 #include "dictionary.H"
92 #include "coordinateSystem.H"
93 #include "coordinateSystems.H"
95 #include "labelList.H"
96 #include "dimensionedScalar.H"
97 #include "dimensionedTensor.H"
98 #include "primitiveFieldsFwd.H"
99 #include "volFieldsFwd.H"
100 #include "fvMatricesFwd.H"
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 /*---------------------------------------------------------------------------*\
112 Class porousZone Declaration
113 \*---------------------------------------------------------------------------*/
119 //- Name of this zone, or a regular expression
122 //- Reference to the finite volume mesh this zone is part of
125 //- Dictionary containing the parameters
129 labelList cellZoneIds_;
131 //- Coordinate system used for the zone (Cartesian)
132 coordinateSystem coordSys_;
134 //- porosity of the zone (0 < porosity <= 1)
135 // Placeholder for treatment of temporal terms.
139 //- Turbulent intensity as fraction of the velocity
142 //- Turbulent length scale
143 scalar mixingLength_;
145 //- powerLaw coefficient C0
148 //- powerLaw coefficient C1
151 //- Darcy coefficient
152 dimensionedTensor D_;
154 //- Forchheimer coefficient
155 dimensionedTensor F_;
158 // Private Member Functions
160 //- adjust negative resistance values to be multiplier of max value
161 static void adjustNegativeResistance(dimensionedVector& resist);
163 //- Power-law resistance
164 template<class RhoFieldType>
165 void addPowerLawResistance
168 const scalarField& V,
169 const RhoFieldType& rho,
173 //- Viscous and inertial resistance
174 template<class RhoFieldType>
175 void addViscousInertialResistance
178 vectorField& Usource,
179 const scalarField& V,
180 const RhoFieldType& rho,
181 const scalarField& mu,
186 //- Power-law resistance
187 template<class RhoFieldType>
188 void addPowerLawResistance
191 const RhoFieldType& rho,
195 //- Viscous and inertial resistance
196 template<class RhoFieldType>
197 void addViscousInertialResistance
200 const RhoFieldType& rho,
201 const scalarField& mu,
206 //- Disallow default bitwise copy construct
207 porousZone(const porousZone&);
209 //- Disallow default bitwise assignment
210 void operator=(const porousZone&);
217 //- Construct from components
218 porousZone(const keyType& key, const fvMesh&, const dictionary&);
221 autoPtr<porousZone> clone() const
223 notImplemented("autoPtr<porousZone> clone() const");
224 return autoPtr<porousZone>(NULL);
227 //- Return pointer to new porousZone created on freestore from Istream
230 //- Reference to the finite volume mesh this zone is part of
235 iNew(const fvMesh& mesh)
240 autoPtr<porousZone> operator()(Istream& is) const
245 return autoPtr<porousZone>(new porousZone(key, mesh_, dict));
251 virtual ~porousZone()
260 const keyType& zoneName() const
266 const fvMesh& mesh() const
272 const labelList& zoneIds() const
277 //- dictionary values used for the porousZone
278 const dictionary& dict() const
283 //- Return coordinate system
284 const coordinateSystem& coordSys() const
290 const point& origin() const
292 return coordSys_.origin();
298 return coordSys_.axis();
302 scalar porosity() const
307 //- Edit access to porosity
313 //- Return turbulent intensity
314 scalar intensity() const
319 //- Edit access to turbulent intensity
325 //- Return turbulent length scale
326 scalar mixingLength() const
328 return mixingLength_;
331 //- Edit access to turbulent length scale
332 scalar& mixingLength()
334 return mixingLength_;
338 //- Modify time derivative elements according to porosity
340 void modifyDdt(fvMatrix<Type>&) const;
342 //- Add the viscous and inertial resistance force contribution
343 // to the momentum equation
344 void addResistance(fvVectorMatrix& UEqn) const;
346 //- Add the viscous and inertial resistance force contribution
347 // to the tensorial diagonal.
348 // Optionally correct the processor BCs of AU.
351 const fvVectorMatrix& UEqn,
353 bool correctAUprocBC = true
356 //- Write the porousZone dictionary
357 virtual void writeDict(Ostream&, bool subDict = true) const;
362 friend Ostream& operator<<(Ostream&, const porousZone&);
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 } // End namespace Foam
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 # include "porousZoneTemplates.C"
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 // ************************************************************************* //