MPPICCloud.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) 2013-2015 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 "MPPICCloud.H"
27 #include "PackingModel.H"
28 #include "ParticleStressModel.H"
29 #include "DampingModel.H"
30 #include "IsotropyModel.H"
31 #include "TimeScaleModel.H"
32 
33 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
34 
35 template<class CloudType>
37 {
38  packingModel_.reset
39  (
41  (
42  this->subModelProperties(),
43  *this
44  ).ptr()
45  );
46  dampingModel_.reset
47  (
49  (
50  this->subModelProperties(),
51  *this
52  ).ptr()
53  );
54  isotropyModel_.reset
55  (
57  (
58  this->subModelProperties(),
59  *this
60  ).ptr()
61  );
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
67 template<class CloudType>
69 (
70  const word& cloudName,
71  const volScalarField& rho,
72  const volVectorField& U,
73  const volScalarField& mu,
74  const dimensionedVector& g,
75  bool readFields
76 )
77 :
78  CloudType(cloudName, rho, U, mu, g, false),
79  packingModel_(NULL),
80  dampingModel_(NULL),
81  isotropyModel_(NULL)
82 {
83  if (this->solution().active())
84  {
85  if (this->solution().steadyState())
86  {
88  << "MPPIC modelling not available for steady state calculations"
89  << exit(FatalError);
90  }
91 
92  setModels();
93 
94  if (readFields)
95  {
97  }
98  }
99 }
100 
101 
102 template<class CloudType>
104 (
106  const word& name
107 )
108 :
109  CloudType(c, name),
110  packingModel_(c.packingModel_->clone()),
111  dampingModel_(c.dampingModel_->clone()),
112  isotropyModel_(c.isotropyModel_->clone())
113 {}
114 
115 
116 template<class CloudType>
118 (
119  const fvMesh& mesh,
120  const word& name,
121  const MPPICCloud<CloudType>& c
122 )
123 :
124  CloudType(mesh, name, c),
125  packingModel_(NULL),
126  dampingModel_(NULL),
127  isotropyModel_(NULL)
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
133 template<class CloudType>
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
140 template<class CloudType>
142 {
143  cloudCopyPtr_.reset
144  (
145  static_cast<MPPICCloud<CloudType>*>
146  (
147  clone(this->name() + "Copy").ptr()
148  )
149  );
150 }
151 
152 
153 template<class CloudType>
155 {
156  this->cloudReset(cloudCopyPtr_());
157  cloudCopyPtr_.clear();
158 }
159 
160 
161 template<class CloudType>
163 {
164  if (this->solution().canEvolve())
165  {
166  typename parcelType::template
167  TrackingData<MPPICCloud<CloudType> > td(*this);
168 
169  this->solve(td);
170  }
171 }
172 
173 
174 template<class CloudType>
175 template<class TrackData>
177 {
178  // Kinematic
179  // ~~~~~~~~~
180 
181  // force calculation and tracking
182  td.part() = TrackData::tpLinearTrack;
183  CloudType::move(td, this->db().time().deltaTValue());
184 
185 
186  // Preliminary
187  // ~~~~~~~~~~~
188 
189  // switch forces off so they are not applied in corrector steps
190  this->forces().setCalcNonCoupled(false);
191  this->forces().setCalcCoupled(false);
192 
193 
194  // Damping
195  // ~~~~~~~
196 
197  if (dampingModel_->active())
198  {
199  // update averages
200  td.updateAverages(*this);
201 
202  // memory allocation and eulerian calculations
203  dampingModel_->cacheFields(true);
204 
205  // calculate the damping velocity corrections without moving the parcels
206  td.part() = TrackData::tpDampingNoTrack;
207  CloudType::move(td, this->db().time().deltaTValue());
208 
209  // correct the parcel positions and velocities
210  td.part() = TrackData::tpCorrectTrack;
211  CloudType::move(td, this->db().time().deltaTValue());
212 
213  // finalise and free memory
214  dampingModel_->cacheFields(false);
215  }
216 
217 
218  // Packing
219  // ~~~~~~~
220 
221  if (packingModel_->active())
222  {
223  // same procedure as for damping
224  td.updateAverages(*this);
225  packingModel_->cacheFields(true);
226  td.part() = TrackData::tpPackingNoTrack;
227  CloudType::move(td, this->db().time().deltaTValue());
228  td.part() = TrackData::tpCorrectTrack;
229  CloudType::move(td, this->db().time().deltaTValue());
230  packingModel_->cacheFields(false);
231  }
232 
233 
234  // Isotropy
235  // ~~~~~~~~
236 
237  if (isotropyModel_->active())
238  {
239  // update averages
240  td.updateAverages(*this);
241 
242  // apply isotropy model
243  isotropyModel_->calculate();
244  }
245 
246 
247  // Final
248  // ~~~~~
249 
250  // update cell occupancy
251  this->updateCellOccupancy();
252 
253  // switch forces back on
254  this->forces().setCalcNonCoupled(true);
255  this->forces().setCalcCoupled(this->solution().coupled());
256 }
257 
258 
259 template<class CloudType>
261 {
262  CloudType::info();
263 
264  tmp<volScalarField> alpha = this->theta();
265 
266  const scalar alphaMin = gMin(alpha().internalField());
267  const scalar alphaMax = gMax(alpha().internalField());
268 
269  Info<< " Min cell volume fraction = " << alphaMin << endl;
270  Info<< " Max cell volume fraction = " << alphaMax << endl;
271 
272  if (alphaMax < SMALL)
273  {
274  return;
275  }
276 
277  scalar nMin = GREAT;
278 
279  forAll(this->mesh().cells(), cellI)
280  {
281  const label n = this->cellOccupancy()[cellI].size();
282 
283  if (n > 0)
284  {
285  const scalar nPack = n*alphaMax/alpha()[cellI];
286 
287  if (nPack < nMin)
288  {
289  nMin = nPack;
290  }
291  }
292  }
293 
294  reduce(nMin, minOp<scalar>());
295 
296  Info<< " Min dense number of parcels = " << nMin << endl;
297 }
298 
299 
300 // ************************************************************************* //
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
Foam::MPPICCloud::setModels
void setModels()
Set cloud sub-models.
Definition: MPPICCloud.C:36
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::constant::physicoChemical::mu
const dimensionedScalar mu
Atomic mass unit.
Definition: createFields.H:13
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::MPPICCloud::storeState
void storeState()
Store the current cloud state.
Definition: MPPICCloud.C:141
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::minOp
Definition: ops.H:173
IsotropyModel.H
TimeScaleModel.H
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::DampingModel
Base class for collisional damping models.
Definition: MPPICCloud.H:56
Foam::readFields
This function object reads fields from the time directories and adds them to the mesh database for fu...
Definition: readFields.H:104
Foam::MPPICCloud::evolve
void evolve()
Evolve the cloud.
Definition: MPPICCloud.C:162
U
U
Definition: pEqn.H:46
n
label n
Definition: TABSMDCalcMethod2.H:31
solve
rhoEqn solve()
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
Foam::MPPICCloud::motion
void motion(TrackData &td)
Particle motion.
Definition: MPPICCloud.C:176
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
cellOccupancy
const List< DynamicList< molecule * > > & cellOccupancy
Definition: calculateMDFields.H:1
Foam::Info
messageStream Info
MPPICCloud.H
Foam::MPPICCloud::MPPICCloud
MPPICCloud(const MPPICCloud &)
Disallow default bitwise copy construct.
Foam::CloudType
DSMCCloud< dsmcParcel > CloudType
Definition: makeDSMCParcelBinaryCollisionModels.C:36
Foam::PackingModel
Base class for packing models.
Definition: MPPICCloud.H:53
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
alphaMax
dimensionedScalar alphaMax(laminarTransport.lookup("alphaMax"))
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
rho
rho
Definition: pEqn.H:3
Foam::forces
This function object calculates the forces and moments by integrating the pressure and skin-friction ...
Definition: forces.H:234
internalField
conserve internalField()+
Foam::MPPICCloud::info
void info()
I-O.
Definition: MPPICCloud.C:260
Foam::MPPICCloud::restoreState
void restoreState()
Reset the current cloud to the previously stored state.
Definition: MPPICCloud.C:154
PackingModel.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
DampingModel.H
readFields
void readFields(const boolList &haveMesh, const fvMesh &mesh, const autoPtr< fvMeshSubset > &subsetterPtr, IOobjectList &allObjects, PtrList< GeoField > &fields)
Definition: redistributePar.C:589
cloudName
const word cloudName(propsDict.lookup("cloudName"))
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
ParticleStressModel.H
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::IsotropyModel
Base class for collisional return-to-isotropy models.
Definition: MPPICCloud.H:59
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:563
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::MPPICCloud
Adds MPPIC modelling to kinematic clouds.
Definition: MPPICCloud.H:66
Foam::MPPICCloud::~MPPICCloud
virtual ~MPPICCloud()
Destructor.
Definition: MPPICCloud.C:134
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:562
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47