initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / cfdTools / general / porousMedia / porousZoneTemplates.C
bloba2cada713edc8025509c2bec84c64aecd9a28ddd
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 \*----------------------------------------------------------------------------*/
27 #include "porousZone.H"
28 #include "fvMesh.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 template<class Type>
33 void Foam::porousZone::modifyDdt(fvMatrix<Type>& m) const
35     if (porosity_ < 1)
36     {
37         const labelList& cells = mesh_.cellZones()[cellZoneID_];
39         forAll(cells, i)
40         {
41             m.diag()[cells[i]]   *= porosity_;
42             m.source()[cells[i]] *= porosity_;
43         }
44     }
48 template<class RhoFieldType>
49 void Foam::porousZone::addPowerLawResistance
51     scalarField& Udiag,
52     const labelList& cells,
53     const scalarField& V,
54     const RhoFieldType& rho,
55     const vectorField& U
56 ) const
58     const scalar C0 = C0_;
59     const scalar C1m1b2 = (C1_ - 1.0)/2.0;
61     forAll (cells, i)
62     {
63         Udiag[cells[i]] +=
64             V[cells[i]]*rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2);
65     }
69 template<class RhoFieldType>
70 void Foam::porousZone::addViscousInertialResistance
72     scalarField& Udiag,
73     vectorField& Usource,
74     const labelList& cells,
75     const scalarField& V,
76     const RhoFieldType& rho,
77     const scalarField& mu,
78     const vectorField& U
79 ) const
81     const tensor& D = D_.value();
82     const tensor& F = F_.value();
84     forAll (cells, i)
85     {
86         tensor dragCoeff = mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
87         scalar isoDragCoeff = tr(dragCoeff);
89         Udiag[cells[i]] += V[cells[i]]*isoDragCoeff;
90         Usource[cells[i]] -=
91             V[cells[i]]*((dragCoeff - I*isoDragCoeff) & U[cells[i]]);
92     }
96 template<class RhoFieldType>
97 void Foam::porousZone::addPowerLawResistance
99     tensorField& AU,
100     const labelList& cells,
101     const RhoFieldType& rho,
102     const vectorField& U
103 ) const
105     const scalar C0 = C0_;
106     const scalar C1m1b2 = (C1_ - 1.0)/2.0;
108     forAll (cells, i)
109     {
110         AU[cells[i]] = AU[cells[i]]
111           + I*(rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2));
112     }
116 template<class RhoFieldType>
117 void Foam::porousZone::addViscousInertialResistance
119     tensorField& AU,
120     const labelList& cells,
121     const RhoFieldType& rho,
122     const scalarField& mu,
123     const vectorField& U
124 ) const
126     const tensor& D = D_.value();
127     const tensor& F = F_.value();
129     forAll (cells, i)
130     {
131         AU[cells[i]] += mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
132     }
136 // ************************************************************************* //