FreeFOAM The Cross-Platform CFD Toolkit
porousZone.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::porousZone
26 
27 Description
28  Porous zone definition based on cell zones.
29 
30  Porous zone definition based on cell zones and parameters obtained from a
31  control dictionary constructed from the given stream. The orientation of
32  the porous region is defined with the same notation as a coordinateSystem,
33  but only a Cartesian coordinate system is valid.
34 
35  Implemented porosity models:
36 
37  powerLaw (@e C0 and @e C1 parameters)
38  @f[
39  S = - \rho C_0 |U|^{(C_1 - 1)/2} U
40  @f]
41 
42  Darcy-Forchheimer (@e d and @e f parameters)
43  @f[
44  S = - (\mu \, d + \frac{\rho |U|}{2} \, f) U
45  @f]
46 
47 
48  Since negative Darcy/Forchheimer parameters are invalid, they can be used
49  to specify a multiplier (of the max component).
50 
51  The porousZones method porousZones::ddt() mirrors the normal fvm::ddt()
52  method, but accounts for the effective volume of the cells.
53 
54 See Also
55  porousZones and coordinateSystems
56 
57 SourceFiles
58  porousZone.C
59  porousZoneTemplates.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef porousZone_H
64 #define porousZone_H
65 
66 #include <OpenFOAM/dictionary.H>
69 #include <OpenFOAM/wordList.H>
70 #include <OpenFOAM/labelList.H>
76 
77 #include <finiteVolume/fvMesh.H>
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 
84 class fvMesh;
85 
86 /*---------------------------------------------------------------------------*\
87  Class porousZone Declaration
88 \*---------------------------------------------------------------------------*/
89 
91 {
92  // Private data
93 
94  //- Name of this zone
95  word name_;
96 
97  //- Reference to the finite volume mesh this zone is part of
98  const fvMesh& mesh_;
99 
100  //- Dictionary containing the parameters
101  dictionary dict_;
102 
103  //- Cell zone ID
104  label cellZoneID_;
105 
106  //- Coordinate system used for the zone (Cartesian)
107  coordinateSystem coordSys_;
108 
109  //- porosity of the zone (0 < porosity <= 1)
110  // Placeholder for treatment of temporal terms.
111  // Currently unused.
112  scalar porosity_;
113 
114  //- powerLaw coefficient C0
115  scalar C0_;
116 
117  //- powerLaw coefficient C1
118  scalar C1_;
119 
120  //- Darcy coefficient
122 
123  //- Forchheimer coefficient
125 
126 
127  // Private Member Functions
128 
129  //- adjust negative resistance values to be multiplier of max value
130  static void adjustNegativeResistance(dimensionedVector& resist);
131 
132  //- Power-law resistance
133  template<class RhoFieldType>
134  void addPowerLawResistance
135  (
136  scalarField& Udiag,
137  const labelList& cells,
138  const scalarField& V,
139  const RhoFieldType& rho,
140  const vectorField& U
141  ) const;
142 
143  //- Viscous and inertial resistance
144  template<class RhoFieldType>
145  void addViscousInertialResistance
146  (
147  scalarField& Udiag,
148  vectorField& Usource,
149  const labelList& cells,
150  const scalarField& V,
151  const RhoFieldType& rho,
152  const scalarField& mu,
153  const vectorField& U
154  ) const;
155 
156 
157  //- Power-law resistance
158  template<class RhoFieldType>
159  void addPowerLawResistance
160  (
161  tensorField& AU,
162  const labelList& cells,
163  const RhoFieldType& rho,
164  const vectorField& U
165  ) const;
166 
167  //- Viscous and inertial resistance
168  template<class RhoFieldType>
169  void addViscousInertialResistance
170  (
171  tensorField& AU,
172  const labelList& cells,
173  const RhoFieldType& rho,
174  const scalarField& mu,
175  const vectorField& U
176  ) const;
177 
178 
179  //- Disallow default bitwise copy construct
180  porousZone(const porousZone&);
181 
182  //- Disallow default bitwise assignment
183  void operator=(const porousZone&);
184 
185 
186 public:
187 
188  // Constructors
189 
190  //- Construct from components
191  porousZone(const word& name, const fvMesh&, const dictionary&);
192 
193  //- Return clone
195  {
196  notImplemented("autoPtr<porousZone> clone() const");
197  return autoPtr<porousZone>(NULL);
198  }
199 
200  //- Return pointer to new porousZone created on freestore from Istream
201  class iNew
202  {
203  //- Reference to the finite volume mesh this zone is part of
204  const fvMesh& mesh_;
205 
206  public:
207 
208  iNew(const fvMesh& mesh)
209  :
210  mesh_(mesh)
211  {}
212 
214  {
215  word name(is);
216  dictionary dict(is);
217 
218  return autoPtr<porousZone>(new porousZone(name, mesh_, dict));
219  }
220  };
221 
222 
223  //- Destructor
224  virtual ~porousZone()
225  {}
226 
227 
228  // Member Functions
229 
230  // Access
231 
232  //- cellZone name
233  const word& zoneName() const
234  {
235  return name_;
236  }
237 
238  //- Return mesh
239  const fvMesh& mesh() const
240  {
241  return mesh_;
242  }
243 
244  //- cellZone number
245  label zoneId() const
246  {
247  return cellZoneID_;
248  }
249 
250  //- dictionary values used for the porousZone
251  const dictionary& dict() const
252  {
253  return dict_;
254  }
255 
256  //- Return coordinate system
257  const coordinateSystem& coordSys() const
258  {
259  return coordSys_;
260  }
261 
262  //- Return origin
263  const point& origin() const
264  {
265  return coordSys_.origin();
266  }
267 
268  //- Return axis
269  vector axis() const
270  {
271  return coordSys_.axis();
272  }
273 
274  //- Return porosity
275  scalar porosity() const
276  {
277  return porosity_;
278  }
279 
280  //- Edit access to porosity
281  scalar& porosity()
282  {
283  return porosity_;
284  }
285 
286 
287  //- Modify time derivative elements according to porosity
288  template<class Type>
289  void modifyDdt(fvMatrix<Type>&) const;
290 
291  //- Add the viscous and inertial resistance force contribution
292  // to the momentum equation
293  void addResistance(fvVectorMatrix& UEqn) const;
294 
295  //- Add the viscous and inertial resistance force contribution
296  // to the tensorial diagonal.
297  // Optionally correct the processor BCs of AU.
298  void addResistance
299  (
300  const fvVectorMatrix& UEqn,
301  volTensorField& AU,
302  bool correctAUprocBC = true
303  ) const;
304 
305  //- Write the porousZone dictionary
306  virtual void writeDict(Ostream&, bool subDict = true) const;
307 
308 
309  // Ostream Operator
310 
311  friend Ostream& operator<<(Ostream&, const porousZone&);
312 };
313 
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 } // End namespace Foam
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 #ifdef NoRepository
323 #endif
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 #endif
328 
329 // ************************ vim: set sw=4 sts=4 et: ************************ //