FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

porousZoneTemplates.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*----------------------------------------------------------------------------*/
00025 
00026 #include "porousZone.H"
00027 #include <finiteVolume/fvMesh.H>
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 template<class Type>
00032 void Foam::porousZone::modifyDdt(fvMatrix<Type>& m) const
00033 {
00034     if (porosity_ < 1)
00035     {
00036         const labelList& cells = mesh_.cellZones()[cellZoneID_];
00037 
00038         forAll(cells, i)
00039         {
00040             m.diag()[cells[i]]   *= porosity_;
00041             m.source()[cells[i]] *= porosity_;
00042         }
00043     }
00044 }
00045 
00046 
00047 template<class RhoFieldType>
00048 void Foam::porousZone::addPowerLawResistance
00049 (
00050     scalarField& Udiag,
00051     const labelList& cells,
00052     const scalarField& V,
00053     const RhoFieldType& rho,
00054     const vectorField& U
00055 ) const
00056 {
00057     const scalar C0 = C0_;
00058     const scalar C1m1b2 = (C1_ - 1.0)/2.0;
00059 
00060     forAll (cells, i)
00061     {
00062         Udiag[cells[i]] +=
00063             V[cells[i]]*rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2);
00064     }
00065 }
00066 
00067 
00068 template<class RhoFieldType>
00069 void Foam::porousZone::addViscousInertialResistance
00070 (
00071     scalarField& Udiag,
00072     vectorField& Usource,
00073     const labelList& cells,
00074     const scalarField& V,
00075     const RhoFieldType& rho,
00076     const scalarField& mu,
00077     const vectorField& U
00078 ) const
00079 {
00080     const tensor& D = D_.value();
00081     const tensor& F = F_.value();
00082 
00083     forAll (cells, i)
00084     {
00085         tensor dragCoeff = mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
00086         scalar isoDragCoeff = tr(dragCoeff);
00087 
00088         Udiag[cells[i]] += V[cells[i]]*isoDragCoeff;
00089         Usource[cells[i]] -=
00090             V[cells[i]]*((dragCoeff - I*isoDragCoeff) & U[cells[i]]);
00091     }
00092 }
00093 
00094 
00095 template<class RhoFieldType>
00096 void Foam::porousZone::addPowerLawResistance
00097 (
00098     tensorField& AU,
00099     const labelList& cells,
00100     const RhoFieldType& rho,
00101     const vectorField& U
00102 ) const
00103 {
00104     const scalar C0 = C0_;
00105     const scalar C1m1b2 = (C1_ - 1.0)/2.0;
00106 
00107     forAll (cells, i)
00108     {
00109         AU[cells[i]] = AU[cells[i]]
00110           + I*(rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2));
00111     }
00112 }
00113 
00114 
00115 template<class RhoFieldType>
00116 void Foam::porousZone::addViscousInertialResistance
00117 (
00118     tensorField& AU,
00119     const labelList& cells,
00120     const RhoFieldType& rho,
00121     const scalarField& mu,
00122     const vectorField& U
00123 ) const
00124 {
00125     const tensor& D = D_.value();
00126     const tensor& F = F_.value();
00127 
00128     forAll (cells, i)
00129     {
00130         AU[cells[i]] += mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
00131     }
00132 }
00133 
00134 
00135 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines