FreeFOAM The Cross-Platform CFD Toolkit
porousZoneTemplates.C
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 \*----------------------------------------------------------------------------*/
25 
26 #include "porousZone.H"
27 #include <finiteVolume/fvMesh.H>
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 {
34  if (porosity_ < 1)
35  {
36  const labelList& cells = mesh_.cellZones()[cellZoneID_];
37 
38  forAll(cells, i)
39  {
40  m.diag()[cells[i]] *= porosity_;
41  m.source()[cells[i]] *= porosity_;
42  }
43  }
44 }
45 
46 
47 template<class RhoFieldType>
48 void Foam::porousZone::addPowerLawResistance
49 (
50  scalarField& Udiag,
51  const labelList& cells,
52  const scalarField& V,
53  const RhoFieldType& rho,
54  const vectorField& U
55 ) const
56 {
57  const scalar C0 = C0_;
58  const scalar C1m1b2 = (C1_ - 1.0)/2.0;
59 
60  forAll (cells, i)
61  {
62  Udiag[cells[i]] +=
63  V[cells[i]]*rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2);
64  }
65 }
66 
67 
68 template<class RhoFieldType>
69 void Foam::porousZone::addViscousInertialResistance
70 (
71  scalarField& Udiag,
72  vectorField& Usource,
73  const labelList& cells,
74  const scalarField& V,
75  const RhoFieldType& rho,
76  const scalarField& mu,
77  const vectorField& U
78 ) const
79 {
80  const tensor& D = D_.value();
81  const tensor& F = F_.value();
82 
83  forAll (cells, i)
84  {
85  tensor dragCoeff = mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
86  scalar isoDragCoeff = tr(dragCoeff);
87 
88  Udiag[cells[i]] += V[cells[i]]*isoDragCoeff;
89  Usource[cells[i]] -=
90  V[cells[i]]*((dragCoeff - I*isoDragCoeff) & U[cells[i]]);
91  }
92 }
93 
94 
95 template<class RhoFieldType>
96 void Foam::porousZone::addPowerLawResistance
97 (
98  tensorField& AU,
99  const labelList& cells,
100  const RhoFieldType& rho,
101  const vectorField& U
102 ) const
103 {
104  const scalar C0 = C0_;
105  const scalar C1m1b2 = (C1_ - 1.0)/2.0;
106 
107  forAll (cells, i)
108  {
109  AU[cells[i]] = AU[cells[i]]
110  + I*(rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2));
111  }
112 }
113 
114 
115 template<class RhoFieldType>
116 void Foam::porousZone::addViscousInertialResistance
117 (
118  tensorField& AU,
119  const labelList& cells,
120  const RhoFieldType& rho,
121  const scalarField& mu,
122  const vectorField& U
123 ) const
124 {
125  const tensor& D = D_.value();
126  const tensor& F = F_.value();
127 
128  forAll (cells, i)
129  {
130  AU[cells[i]] += mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
131  }
132 }
133 
134 
135 // ************************ vim: set sw=4 sts=4 et: ************************ //