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

particleForces.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) 2008-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 "particleForces.H"
00028 #include "fvMesh.H"
00029 #include "volFields.H"
00030 #include "fvcGrad.H"
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 Foam::particleForces::particleForces
00035 (
00036     const fvMesh& mesh,
00037     const dictionary& dict,
00038     const vector& g
00039 )
00040 :
00041     mesh_(mesh),
00042     dict_(dict.subDict("particleForces")),
00043     g_(g),
00044     gradUPtr_(NULL),
00045     gravity_(dict_.lookup("gravity")),
00046     virtualMass_(dict_.lookup("virtualMass")),
00047     Cvm_(0.0),
00048     pressureGradient_(dict_.lookup("pressureGradient")),
00049     UName_(dict_.lookupOrDefault<word>("U", "U"))
00050 {
00051     if (virtualMass_)
00052     {
00053         dict_.lookup("Cvm") >> Cvm_;
00054     }
00055 }
00056 
00057 
00058 Foam::particleForces::particleForces(const particleForces& f)
00059 :
00060     mesh_(f.mesh_),
00061     dict_(f.dict_),
00062     g_(f.g_),
00063     gradUPtr_(f.gradUPtr_),
00064     gravity_(f.gravity_),
00065     virtualMass_(f.virtualMass_),
00066     Cvm_(f.Cvm_),
00067     pressureGradient_(f.pressureGradient_),
00068     UName_(f.UName_)
00069 {}
00070 
00071 
00072 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00073 
00074 Foam::particleForces::~particleForces()
00075 {
00076     cacheFields(false);
00077 }
00078 
00079 
00080 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00081 
00082 const Foam::dictionary& Foam::particleForces::dict() const
00083 {
00084     return dict_;
00085 }
00086 
00087 
00088 const Foam::vector& Foam::particleForces::g() const
00089 {
00090     return g_;
00091 }
00092 
00093 
00094 Foam::Switch Foam::particleForces::gravity() const
00095 {
00096     return gravity_;
00097 }
00098 
00099 
00100 Foam::Switch Foam::particleForces::virtualMass() const
00101 {
00102     return virtualMass_;
00103 }
00104 
00105 
00106 Foam::Switch Foam::particleForces::pressureGradient() const
00107 {
00108     return pressureGradient_;
00109 }
00110 
00111 
00112 const Foam::word& Foam::particleForces::UName() const
00113 {
00114     return UName_;
00115 }
00116 
00117 
00118 void Foam::particleForces::cacheFields(const bool store)
00119 {
00120     if (store && pressureGradient_)
00121     {
00122         const volVectorField U = mesh_.lookupObject<volVectorField>(UName_);
00123         gradUPtr_ = fvc::grad(U).ptr();
00124     }
00125     else
00126     {
00127         if (gradUPtr_)
00128         {
00129             delete gradUPtr_;
00130         }
00131     }
00132 }
00133 
00134 
00135 Foam::vector Foam::particleForces::calcCoupled
00136 (
00137     const label cellI,
00138     const scalar dt,
00139     const scalar rhoc,
00140     const scalar rho,
00141     const vector& Uc,
00142     const vector& U
00143 ) const
00144 {
00145     vector Ftot = vector::zero;
00146 
00147     // Virtual mass force
00148     if (virtualMass_)
00149     {
00150         notImplemented
00151         (
00152             "Foam::particleForces::calcCoupled(...) - virtual mass force"
00153         );
00154 //        Ftot += Cvm_*rhoc/rho*d(Uc - U)/dt;
00155     }
00156 
00157     // Pressure gradient force
00158     if (pressureGradient_)
00159     {
00160         const volTensorField& gradU = *gradUPtr_;
00161         Ftot += rhoc/rho*(U & gradU[cellI]);
00162     }
00163 
00164     return Ftot;
00165 }
00166 
00167 
00168 Foam::vector Foam::particleForces::calcNonCoupled
00169 (
00170     const label cellI,
00171     const scalar dt,
00172     const scalar rhoc,
00173     const scalar rho,
00174     const vector& Uc,
00175     const vector& U
00176 ) const
00177 {
00178     vector Ftot = vector::zero;
00179 
00180     // Gravity force
00181     if (gravity_)
00182     {
00183         Ftot += g_*(1.0 - rhoc/rho);
00184     }
00185 
00186     return Ftot;
00187 }
00188 
00189 
00190 // ************************************************************************* //
00191 
Copyright © 2000-2009 OpenCFD Ltd