ParticleForceList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
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 "ParticleForceList.H"
27 #include "entry.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class CloudType>
33 (
34  CloudType& owner,
35  const fvMesh& mesh
36 )
37 :
39  owner_(owner),
40  mesh_(mesh),
41  dict_(dictionary::null),
42  calcCoupled_(true),
43  calcNonCoupled_(true)
44 {}
45 
46 
47 template<class CloudType>
49 (
50  CloudType& owner,
51  const fvMesh& mesh,
52  const dictionary& dict,
53  const bool readFields
54 )
55 :
57  owner_(owner),
58  mesh_(mesh),
59  dict_(dict),
60  calcCoupled_(true),
61  calcNonCoupled_(true)
62 {
63  if (readFields)
64  {
65  wordList modelNames(dict.toc());
66 
67  Info<< "Constructing particle forces" << endl;
68 
69  if (modelNames.size() > 0)
70  {
71  this->setSize(modelNames.size());
72 
73  label i = 0;
74  forAllConstIter(IDLList<entry>, dict, iter)
75  {
76  const word& model = iter().keyword();
77  if (iter().isDict())
78  {
79  this->set
80  (
81  i++,
83  (
84  owner,
85  mesh,
86  iter().dict(),
87  model
88  )
89  );
90  }
91  else
92  {
93  this->set
94  (
95  i++,
97  (
98  owner,
99  mesh,
100  dictionary::null,
101  model
102  )
103  );
104  }
105  }
106  }
107  else
108  {
109  Info<< " none" << endl;
110  }
111  }
112 }
113 
114 
115 template<class CloudType>
117 (
118  const ParticleForceList& pf
119 )
120 :
122  owner_(pf.owner_),
123  mesh_(pf.mesh_),
124  dict_(pf.dict_)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
129 
130 template<class CloudType>
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 
137 template<class CloudType>
139 {
140  forAll(*this, i)
141  {
142  this->operator[](i).cacheFields(store);
143  }
144 }
145 
146 
147 template<class CloudType>
149 (
150  const typename CloudType::parcelType& p,
151  const typename CloudType::parcelType::trackingData& td,
152  const scalar dt,
153  const scalar mass,
154  const scalar Re,
155  const scalar muc
156 ) const
157 {
158  forceSuSp value(Zero, 0.0);
159 
160  if (calcCoupled_)
161  {
162  forAll(*this, i)
163  {
164  value += this->operator[](i).calcCoupled(p, td, dt, mass, Re, muc);
165  }
166  }
167 
168  return value;
169 }
170 
171 
172 template<class CloudType>
174 (
175  const typename CloudType::parcelType& p,
176  const typename CloudType::parcelType::trackingData& td,
177  const scalar dt,
178  const scalar mass,
179  const scalar Re,
180  const scalar muc
181 ) const
182 {
183  forceSuSp value(Zero, 0.0);
184 
185  if (calcNonCoupled_)
186  {
187  forAll(*this, i)
188  {
189  value +=
190  this->operator[](i).calcNonCoupled(p, td, dt, mass, Re, muc);
191  }
192  }
193 
194  return value;
195 }
196 
197 
198 template<class CloudType>
200 (
201  const typename CloudType::parcelType& p,
202  const typename CloudType::parcelType::trackingData& td,
203  const scalar mass
204 ) const
205 {
206  scalar massEff = mass;
207  forAll(*this, i)
208  {
209  massEff += this->operator[](i).massAdd(p, td, mass);
210  }
211 
212  return massEff;
213 }
214 
215 
216 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:50
dictionary dict
virtual void cacheFields(const bool store)
Cache fields.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
ParticleForceList(CloudType &owner, const fvMesh &mesh)
Null constructor.
wordList toc() const
Return the table of contents.
Definition: dictionary.C:1115
Helper container for force Su and Sp terms.
Definition: forceSuSp.H:61
virtual scalar massEff(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar mass) const
Return the effective mass.
points setSize(newPointi)
virtual forceSuSp calcCoupled(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the coupled force.
A class for handling words, derived from string.
Definition: word.H:59
virtual forceSuSp calcNonCoupled(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the non-coupled force.
static const zero Zero
Definition: zero.H:97
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
messageStream Info
virtual ~ParticleForceList()
Destructor.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
List of particle forces.