OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*----------------------------------------------------------------------------*/
00026 
00027 #include "porousZone.H"
00028 #include "fvMesh.H"
00029 
00030 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00031 
00032 template<class Type>
00033 void Foam::porousZone::modifyDdt(fvMatrix<Type>& m) const
00034 {
00035     if (porosity_ < 1)
00036     {
00037         const labelList& cells = mesh_.cellZones()[cellZoneID_];
00038 
00039         forAll(cells, i)
00040         {
00041             m.diag()[cells[i]]   *= porosity_;
00042             m.source()[cells[i]] *= porosity_;
00043         }
00044     }
00045 }
00046 
00047 
00048 template<class RhoFieldType>
00049 void Foam::porousZone::addPowerLawResistance
00050 (
00051     scalarField& Udiag,
00052     const labelList& cells,
00053     const scalarField& V,
00054     const RhoFieldType& rho,
00055     const vectorField& U
00056 ) const
00057 {
00058     const scalar C0 = C0_;
00059     const scalar C1m1b2 = (C1_ - 1.0)/2.0;
00060 
00061     forAll (cells, i)
00062     {
00063         Udiag[cells[i]] +=
00064             V[cells[i]]*rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2);
00065     }
00066 }
00067 
00068 
00069 template<class RhoFieldType>
00070 void Foam::porousZone::addViscousInertialResistance
00071 (
00072     scalarField& Udiag,
00073     vectorField& Usource,
00074     const labelList& cells,
00075     const scalarField& V,
00076     const RhoFieldType& rho,
00077     const scalarField& mu,
00078     const vectorField& U
00079 ) const
00080 {
00081     const tensor& D = D_.value();
00082     const tensor& F = F_.value();
00083 
00084     forAll (cells, i)
00085     {
00086         tensor dragCoeff = mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
00087         scalar isoDragCoeff = tr(dragCoeff);
00088 
00089         Udiag[cells[i]] += V[cells[i]]*isoDragCoeff;
00090         Usource[cells[i]] -=
00091             V[cells[i]]*((dragCoeff - I*isoDragCoeff) & U[cells[i]]);
00092     }
00093 }
00094 
00095 
00096 template<class RhoFieldType>
00097 void Foam::porousZone::addPowerLawResistance
00098 (
00099     tensorField& AU,
00100     const labelList& cells,
00101     const RhoFieldType& rho,
00102     const vectorField& U
00103 ) const
00104 {
00105     const scalar C0 = C0_;
00106     const scalar C1m1b2 = (C1_ - 1.0)/2.0;
00107 
00108     forAll (cells, i)
00109     {
00110         AU[cells[i]] = AU[cells[i]]
00111           + I*(rho[cells[i]]*C0*pow(magSqr(U[cells[i]]), C1m1b2));
00112     }
00113 }
00114 
00115 
00116 template<class RhoFieldType>
00117 void Foam::porousZone::addViscousInertialResistance
00118 (
00119     tensorField& AU,
00120     const labelList& cells,
00121     const RhoFieldType& rho,
00122     const scalarField& mu,
00123     const vectorField& U
00124 ) const
00125 {
00126     const tensor& D = D_.value();
00127     const tensor& F = F_.value();
00128 
00129     forAll (cells, i)
00130     {
00131         AU[cells[i]] += mu[cells[i]]*D + (rho[cells[i]]*mag(U[cells[i]]))*F;
00132     }
00133 }
00134 
00135 
00136 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd