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

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-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 "particleForces.H"
00027 #include <finiteVolume/fvMesh.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <finiteVolume/fvcGrad.H>
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 Foam::particleForces::particleForces
00034 (
00035     const fvMesh& mesh,
00036     const dictionary& dict,
00037     const vector& g
00038 )
00039 :
00040     mesh_(mesh),
00041     dict_(dict.subDict("particleForces")),
00042     g_(g),
00043     gradUPtr_(NULL),
00044     gravity_(dict_.lookup("gravity")),
00045     virtualMass_(dict_.lookup("virtualMass")),
00046     Cvm_(0.0),
00047     pressureGradient_(dict_.lookup("pressureGradient")),
00048     UName_(dict_.lookupOrDefault<word>("U", "U"))
00049 {
00050     if (virtualMass_)
00051     {
00052         dict_.lookup("Cvm") >> Cvm_;
00053     }
00054 }
00055 
00056 
00057 Foam::particleForces::particleForces(const particleForces& f)
00058 :
00059     mesh_(f.mesh_),
00060     dict_(f.dict_),
00061     g_(f.g_),
00062     gradUPtr_(f.gradUPtr_),
00063     gravity_(f.gravity_),
00064     virtualMass_(f.virtualMass_),
00065     Cvm_(f.Cvm_),
00066     pressureGradient_(f.pressureGradient_),
00067     UName_(f.UName_)
00068 {}
00069 
00070 
00071 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00072 
00073 Foam::particleForces::~particleForces()
00074 {
00075     cacheFields(false);
00076 }
00077 
00078 
00079 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00080 
00081 const Foam::dictionary& Foam::particleForces::dict() const
00082 {
00083     return dict_;
00084 }
00085 
00086 
00087 const Foam::vector& Foam::particleForces::g() const
00088 {
00089     return g_;
00090 }
00091 
00092 
00093 Foam::Switch Foam::particleForces::gravity() const
00094 {
00095     return gravity_;
00096 }
00097 
00098 
00099 Foam::Switch Foam::particleForces::virtualMass() const
00100 {
00101     return virtualMass_;
00102 }
00103 
00104 
00105 Foam::Switch Foam::particleForces::pressureGradient() const
00106 {
00107     return pressureGradient_;
00108 }
00109 
00110 
00111 const Foam::word& Foam::particleForces::UName() const
00112 {
00113     return UName_;
00114 }
00115 
00116 
00117 void Foam::particleForces::cacheFields(const bool store)
00118 {
00119     if (store && pressureGradient_)
00120     {
00121         const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
00122         gradUPtr_ = fvc::grad(U).ptr();
00123     }
00124     else
00125     {
00126         if (gradUPtr_)
00127         {
00128             delete gradUPtr_;
00129             gradUPtr_ = NULL;
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 // ************************ vim: set sw=4 sts=4 et: ************************ //
00191 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines