1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 "particleForces.H"
29 #include "volFields.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::particleForces::particleForces
37 const dictionary& dict,
42 dict_(dict.subDict("particleForces")),
45 gravity_(dict_.lookup("gravity")),
46 virtualMass_(dict_.lookup("virtualMass")),
48 pressureGradient_(dict_.lookup("pressureGradient")),
49 UName_(dict_.lookupOrDefault<word>("U", "U"))
53 dict_.lookup("Cvm") >> Cvm_;
58 Foam::particleForces::particleForces(const particleForces& f)
63 gradUPtr_(f.gradUPtr_),
65 virtualMass_(f.virtualMass_),
67 pressureGradient_(f.pressureGradient_),
72 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74 Foam::particleForces::~particleForces()
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 const Foam::dictionary& Foam::particleForces::dict() const
88 const Foam::vector& Foam::particleForces::g() const
94 Foam::Switch Foam::particleForces::gravity() const
100 Foam::Switch Foam::particleForces::virtualMass() const
106 Foam::Switch Foam::particleForces::pressureGradient() const
108 return pressureGradient_;
112 const Foam::word& Foam::particleForces::UName() const
118 void Foam::particleForces::cacheFields(const bool store)
120 if (store && pressureGradient_)
122 const volVectorField U = mesh_.lookupObject<volVectorField>(UName_);
123 gradUPtr_ = fvc::grad(U).ptr();
135 Foam::vector Foam::particleForces::calcCoupled
145 vector Ftot = vector::zero;
147 // Virtual mass force
152 "Foam::particleForces::calcCoupled(...) - virtual mass force"
154 // Ftot += Cvm_*rhoc/rho*d(Uc - U)/dt;
157 // Pressure gradient force
158 if (pressureGradient_)
160 const volTensorField& gradU = *gradUPtr_;
161 Ftot += rhoc/rho*(U & gradU[cellI]);
168 Foam::vector Foam::particleForces::calcNonCoupled
178 vector Ftot = vector::zero;
183 Ftot += g_*(1.0 - rhoc/rho);
190 // ************************************************************************* //