FreeFOAM The Cross-Platform CFD Toolkit
particleForces.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "particleForces.H"
27 #include <finiteVolume/fvMesh.H>
28 #include <finiteVolume/volFields.H>
29 #include <finiteVolume/fvcGrad.H>
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 (
35  const fvMesh& mesh,
36  const dictionary& dict,
37  const vector& g
38 )
39 :
40  mesh_(mesh),
41  dict_(dict.subDict("particleForces")),
42  g_(g),
43  gradUPtr_(NULL),
44  gravity_(dict_.lookup("gravity")),
45  virtualMass_(dict_.lookup("virtualMass")),
46  Cvm_(0.0),
47  pressureGradient_(dict_.lookup("pressureGradient")),
48  UName_(dict_.lookupOrDefault<word>("U", "U"))
49 {
50  if (virtualMass_)
51  {
52  dict_.lookup("Cvm") >> Cvm_;
53  }
54 }
55 
56 
58 :
59  mesh_(f.mesh_),
60  dict_(f.dict_),
61  g_(f.g_),
62  gradUPtr_(f.gradUPtr_),
63  gravity_(f.gravity_),
64  virtualMass_(f.virtualMass_),
65  Cvm_(f.Cvm_),
66  pressureGradient_(f.pressureGradient_),
67  UName_(f.UName_)
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 
74 {
75  cacheFields(false);
76 }
77 
78 
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 
82 {
83  return dict_;
84 }
85 
86 
88 {
89  return g_;
90 }
91 
92 
94 {
95  return gravity_;
96 }
97 
98 
100 {
101  return virtualMass_;
102 }
103 
104 
106 {
107  return pressureGradient_;
108 }
109 
110 
112 {
113  return UName_;
114 }
115 
116 
117 void Foam::particleForces::cacheFields(const bool store)
118 {
119  if (store && pressureGradient_)
120  {
121  const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
122  gradUPtr_ = fvc::grad(U).ptr();
123  }
124  else
125  {
126  if (gradUPtr_)
127  {
128  delete gradUPtr_;
129  gradUPtr_ = NULL;
130  }
131  }
132 }
133 
134 
136 (
137  const label cellI,
138  const scalar dt,
139  const scalar rhoc,
140  const scalar rho,
141  const vector& Uc,
142  const vector& U
143 ) const
144 {
145  vector Ftot = vector::zero;
146 
147  // Virtual mass force
148  if (virtualMass_)
149  {
151  (
152  "Foam::particleForces::calcCoupled(...) - virtual mass force"
153  );
154 // Ftot += Cvm_*rhoc/rho*d(Uc - U)/dt;
155  }
156 
157  // Pressure gradient force
158  if (pressureGradient_)
159  {
160  const volTensorField& gradU = *gradUPtr_;
161  Ftot += rhoc/rho*(U & gradU[cellI]);
162  }
163 
164  return Ftot;
165 }
166 
167 
169 (
170  const label cellI,
171  const scalar dt,
172  const scalar rhoc,
173  const scalar rho,
174  const vector& Uc,
175  const vector& U
176 ) const
177 {
178  vector Ftot = vector::zero;
179 
180  // Gravity force
181  if (gravity_)
182  {
183  Ftot += g_*(1.0 - rhoc/rho);
184  }
185 
186  return Ftot;
187 }
188 
189 
190 // ************************ vim: set sw=4 sts=4 et: ************************ //
191