ReactingParcel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::ReactingParcel
29 
30 Group
31  grpLagrangianIntermediateParcels
32 
33 Description
34  Reacting parcel class with one/two-way coupling with the continuous
35  phase.
36 
37 SourceFiles
38  ReactingParcelI.H
39  ReactingParcel.C
40  ReactingParcelIO.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef ReactingParcel_H
45 #define ReactingParcel_H
46 
47 #include "particle.H"
48 #include "SLGThermo.H"
49 #include "demandDrivenEntry.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 template<class ParcelType>
57 class ReactingParcel;
58 
59 template<class ParcelType>
60 Ostream& operator<<
61 (
62  Ostream&,
64 );
65 
66 
67 /*---------------------------------------------------------------------------*\
68  Class ReactingParcel Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class ParcelType>
72 class ReactingParcel
73 :
74  public ParcelType
75 {
76 public:
77 
78  //- Size in bytes of the fields
79  static const std::size_t sizeofFields;
80 
81 
82  //- Class to hold reacting parcel constant properties
83  class constantProperties
84  :
85  public ParcelType::constantProperties
86  {
87  // Private data
88 
89  //- Minimum pressure [Pa]
91 
92  //- Constant volume flag - e.g. during mass transfer
93  demandDrivenEntry<bool> constantVolume_;
94 
95 
96  public:
97 
98  // Constructors
99 
100  //- Null constructor
102 
103  //- Copy constructor
105 
106  //- Construct from dictionary
107  constantProperties(const dictionary& parentDict);
108 
109 
110  // Access
111 
112  //- Return const access to the minimum pressure
113  inline scalar pMin() const;
114 
115  //- Return const access to the constant volume flag
116  inline bool constantVolume() const;
117  };
118 
119 
120  class trackingData
121  :
122  public ParcelType::trackingData
123  {
124  private:
125 
126  // Private data
127 
128  // Interpolators for continuous phase fields
129 
130  //- Interpolator for continuous phase pressure field
132 
133 
134  // Cached continuous phase properties
135 
136  //- Pressure [Pa]
137  scalar pc_;
138 
139 
140  public:
141 
142  typedef typename ParcelType::trackingData::trackPart trackPart;
143 
144  // Constructors
145 
146  //- Construct from components
147  template<class TrackCloudType>
148  inline trackingData
149  (
150  const TrackCloudType& cloud,
151  trackPart part = ParcelType::trackingData::tpLinearTrack
152  );
153 
154 
155  // Member functions
156 
157  //- Return const access to the interpolator for continuous phase
158  // pressure field
159  inline const interpolation<scalar>& pInterp() const;
160 
161  //- Return the continuous phase pressure
162  inline scalar pc() const;
163 
164  //- Access the continuous phase pressure
165  inline scalar& pc();
166  };
167 
168 
169 protected:
170 
171  // Protected data
172 
173  // Parcel properties
174 
175  //- Initial mass [kg]
176  scalar mass0_;
177 
178  //- Mass fractions of mixture []
179  scalarField Y_;
180 
181 
182  // Protected Member Functions
183 
184  //- Calculate Phase change
185  template<class TrackCloudType>
186  void calcPhaseChange
187  (
188  TrackCloudType& cloud,
189  trackingData& td,
190  const scalar dt, // timestep
191  const scalar Re, // Reynolds number
192  const scalar Pr, // Prandtl number
193  const scalar Ts, // Surface temperature
194  const scalar nus, // Surface kinematic viscosity
195  const scalar d, // diameter
196  const scalar T, // temperature
197  const scalar mass, // mass
198  const label idPhase, // id of phase involved in phase change
199  const scalar YPhase, // total mass fraction
200  const scalarField& YComponents, // component mass fractions
201  scalarField& dMassPC, // mass transfer - local to parcel
202  scalar& Sh, // explicit parcel enthalpy source
203  scalar& N, // flux of species emitted from parcel
204  scalar& NCpW, // sum of N*Cp*W of emission species
205  scalarField& Cs // carrier conc. of emission species
206  );
207 
208  //- Update mass fraction
209  scalar updateMassFraction
210  (
211  const scalar mass0,
212  const scalarField& dMass,
213  scalarField& Y
214  ) const;
215 
216 
217 public:
218 
219  // Static data members
220 
221  //- Runtime type information
222  TypeName("ReactingParcel");
223 
224  //- String representation of properties
226  (
227  ParcelType,
228  " mass0"
229  + " nPhases(Y1..YN)"
230  );
231 
232 
233  // Constructors
234 
235  //- Construct from mesh, coordinates and topology
236  // Other properties initialised as null
237  inline ReactingParcel
238  (
239  const polyMesh& mesh,
240  const barycentric& coordinates,
241  const label celli,
242  const label tetFacei,
243  const label tetPti
244  );
245 
246  //- Construct from a position and a cell, searching for the rest of the
247  // required topology. Other properties are initialised as null.
248  inline ReactingParcel
249  (
250  const polyMesh& mesh,
251  const vector& position,
252  const label celli
253  );
254 
255  //- Construct from components
256  inline ReactingParcel
257  (
258  const polyMesh& mesh,
259  const barycentric& coordinates,
260  const label celli,
261  const label tetFacei,
262  const label tetPti,
263  const label typeId,
264  const scalar nParticle0,
265  const scalar d0,
266  const scalar dTarget0,
267  const vector& U0,
268  const vector& f0,
269  const vector& angularMomentum0,
270  const vector& torque0,
271  const scalarField& Y0,
272  const constantProperties& constProps
273  );
274 
275  //- Construct from Istream
277  (
278  const polyMesh& mesh,
279  Istream& is,
280  bool readFields = true,
281  bool newFormat = true
282  );
283 
284  //- Construct as a copy
286  (
287  const ReactingParcel& p,
288  const polyMesh& mesh
289  );
290 
291  //- Construct as a copy
293 
294  //- Construct and return a (basic particle) clone
295  virtual autoPtr<particle> clone() const
296  {
298  }
299 
300  //- Construct and return a (basic particle) clone
301  virtual autoPtr<particle> clone(const polyMesh& mesh) const
302  {
303  return autoPtr<particle>
304  (
305  new ReactingParcel<ParcelType>(*this, mesh)
306  );
307  }
308 
309  //- Factory class to read-construct particles used for
310  // parallel transfer
311  class iNew
312  {
313  const polyMesh& mesh_;
314 
315  public:
316 
317  iNew(const polyMesh& mesh)
318  :
319  mesh_(mesh)
320  {}
321 
323  {
325  (
326  new ReactingParcel<ParcelType>(mesh_, is, true)
327  );
328  }
329  };
330 
331 
332  // Member Functions
333 
334  // Access
335 
336  //- Return const access to initial mass [kg]
337  inline scalar mass0() const;
338 
339  //- Return const access to mass fractions of mixture []
340  inline const scalarField& Y() const;
341 
342  //- Return const access to mass fractions of gases
343  // Note: for compatibilty only - returns Y()
344  inline const scalarField& YGas() const;
345 
346  //- Return const access to mass fractions of liquids
347  // Note: for compatibilty only - returns Y()
348  inline const scalarField& YLiquid() const;
349 
350  //- Return const access to mass fractions of solids
351  // Note: for compatibilty only - returns Y()
352  inline const scalarField& YSolid() const;
353 
354 
355  // Edit
356 
357  //- Return access to initial mass [kg]
358  inline scalar& mass0();
359 
360  //- Return access to mass fractions of mixture []
361  inline scalarField& Y();
362 
363 
364  // Main calculation loop
365 
366  //- Set cell values
367  template<class TrackCloudType>
368  void setCellValues(TrackCloudType& cloud, trackingData& td);
369 
370  //- Correct cell values using latest transfer information
371  template<class TrackCloudType>
373  (
374  TrackCloudType& cloud,
375  trackingData& td,
376  const scalar dt
377  );
378 
379  //- Correct surface values due to emitted species
380  template<class TrackCloudType>
382  (
383  TrackCloudType& cloud,
384  trackingData& td,
385  const scalar T,
386  const scalarField& Cs,
387  scalar& rhos,
388  scalar& mus,
389  scalar& Prs,
390  scalar& kappas
391  );
392 
393  //- Update parcel properties over the time interval
394  template<class TrackCloudType>
395  void calc
396  (
397  TrackCloudType& cloud,
398  trackingData& td,
399  const scalar dt
400  );
401 
402 
403  // I-O
404 
405  //- Read - composition supplied
406  template<class CloudType, class CompositionType>
407  static void readFields
408  (
409  CloudType& c,
410  const CompositionType& compModel
411  );
412 
413  //- Read - no composition
414  template<class CloudType>
415  static void readFields(CloudType& c);
416 
417  //- Write - composition supplied
418  template<class CloudType, class CompositionType>
419  static void writeFields
420  (
421  const CloudType& c,
422  const CompositionType& compModel
423  );
424 
425  //- Write - no composition
426  template<class CloudType>
427  static void writeFields(const CloudType& c);
428 
429  //- Write individual parcel properties to stream
430  void writeProperties
431  (
432  Ostream& os,
433  const wordRes& filters,
434  const word& delim,
435  const bool namesOnly = false
436  ) const;
437 
438  //- Read particle fields as objects from the obr registry
439  // - no composition
440  template<class CloudType>
441  static void readObjects
442  (
443  CloudType& c,
444  const objectRegistry& obr
445  );
446 
447  //- Read particle fields as objects from the obr registry
448  template<class CloudType, class CompositionType>
449  static void readObjects
450  (
451  CloudType& c,
452  const CompositionType& compModel,
453  const objectRegistry& obr
454  );
455 
456  //- Write particle fields as objects into the obr registry
457  // - no composition
458  template<class CloudType>
459  static void writeObjects
460  (
461  const CloudType& c,
462  objectRegistry& obr
463  );
464 
465  //- Write particle fields as objects into the obr registry
466  template<class CloudType, class CompositionType>
467  static void writeObjects
468  (
469  const CloudType& c,
470  const CompositionType& compModel,
471  objectRegistry& obr
472  );
473 
474 
475  // Ostream Operator
476 
477  friend Ostream& operator<< <ParcelType>
478  (
479  Ostream&,
481  );
482 };
483 
484 
485 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
486 
487 } // End namespace Foam
488 
489 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
490 
491 #include "ReactingParcelI.H"
493 
494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
495 
496 #ifdef NoRepository
497  #include "ReactingParcel.C"
498 #endif
499 
500 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
501 
502 #endif
503 
504 // ************************************************************************* //
Foam::ReactingParcel::mass0
scalar mass0() const
Return const access to initial mass [kg].
Definition: ReactingParcelI.H:161
Foam::ReactingParcel::AddToPropertyList
AddToPropertyList(ParcelType, " mass0"+" nPhases(Y1..YN)")
String representation of properties.
Foam::ReactingParcel::YSolid
const scalarField & YSolid() const
Return const access to mass fractions of solids.
Definition: ReactingParcelI.H:191
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::ReactingParcel::clone
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
Definition: ReactingParcel.H:294
Foam::ReactingParcel::trackingData::pInterp
const interpolation< scalar > & pInterp() const
Return const access to the interpolator for continuous phase.
Definition: ReactingParcelTrackingDataI.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
ReactingParcelTrackingDataI.H
Foam::ReactingParcel::readFields
static void readFields(CloudType &c, const CompositionType &compModel)
Read - composition supplied.
Definition: ReactingParcelIO.C:104
demandDrivenEntry.H
Foam::ReactingParcel::trackingData::trackingData
trackingData(const TrackCloudType &cloud, trackPart part=ParcelType::trackingData::tpLinearTrack)
Construct from components.
Definition: ReactingParcelTrackingDataI.H:31
Foam::ReactingParcel::calc
void calc(TrackCloudType &cloud, trackingData &td, const scalar dt)
Update parcel properties over the time interval.
Definition: ReactingParcel.C:380
Foam::ReactingParcel::TypeName
TypeName("ReactingParcel")
Runtime type information.
SLGThermo.H
Foam::ReactingParcel::Y
const scalarField & Y() const
Return const access to mass fractions of mixture [].
Definition: ReactingParcelI.H:168
Foam::ReactingParcel::trackingData::pc
scalar pc() const
Return the continuous phase pressure.
Definition: ReactingParcelTrackingDataI.H:58
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::ReactingParcel::readObjects
static void readObjects(CloudType &c, const objectRegistry &obr)
Read particle fields as objects from the obr registry.
Definition: ReactingParcelIO.C:259
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::ReactingParcel::trackingData::trackPart
ParcelType::trackingData::trackPart trackPart
Definition: ReactingParcel.H:141
Foam::ReactingParcel::calcPhaseChange
void calcPhaseChange(TrackCloudType &cloud, trackingData &td, const scalar dt, const scalar Re, const scalar Pr, const scalar Ts, const scalar nus, const scalar d, const scalar T, const scalar mass, const label idPhase, const scalar YPhase, const scalarField &YComponents, scalarField &dMassPC, scalar &Sh, scalar &N, scalar &NCpW, scalarField &Cs)
Calculate Phase change.
Definition: ReactingParcel.C:41
ReactingParcel.C
Foam::ReactingParcel::YLiquid
const scalarField & YLiquid() const
Return const access to mass fractions of liquids.
Definition: ReactingParcelI.H:183
Foam::ReactingParcel::writeObjects
static void writeObjects(const CloudType &c, objectRegistry &obr)
Write particle fields as objects into the obr registry.
Definition: ReactingParcelIO.C:271
Foam::Field< scalar >
ReactingParcelI.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::ReactingParcel::setCellValues
void setCellValues(TrackCloudType &cloud, trackingData &td)
Set cell values.
Definition: ReactingParcel.C:202
coordinates
PtrList< coordinateSystem > coordinates(solidRegions.size())
Pr
dimensionedScalar Pr("Pr", dimless, laminarTransport)
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::ReactingParcel::trackingData
Definition: ReactingParcel.H:119
Foam::Barycentric< scalar >
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::interpolation< scalar >
Foam::ReactingParcel::iNew::iNew
iNew(const polyMesh &mesh)
Definition: ReactingParcel.H:316
Foam::ReactingParcel::YGas
const scalarField & YGas() const
Return const access to mass fractions of gases.
Definition: ReactingParcelI.H:175
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::ReactingParcel::ReactingParcel
ReactingParcel(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti)
Construct from mesh, coordinates and topology.
Definition: ReactingParcelI.H:67
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::ReactingParcel::cellValueSourceCorrection
void cellValueSourceCorrection(TrackCloudType &cloud, trackingData &td, const scalar dt)
Correct cell values using latest transfer information.
Definition: ReactingParcel.C:232
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ReactingParcel::mass0_
scalar mass0_
Initial mass [kg].
Definition: ReactingParcel.H:175
Foam::ReactingParcel::writeFields
static void writeFields(const CloudType &c, const CompositionType &compModel)
Write - composition supplied.
Definition: ReactingParcelIO.C:179
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::cloud
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:57
Foam::ReactingParcel::constantProperties::constantVolume
bool constantVolume() const
Return const access to the constant volume flag.
Definition: ReactingParcelI.H:152
Foam::cp
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
Definition: MSwindows.C:802
Foam::Vector< scalar >
Foam::demandDrivenEntry< scalar >
Foam::ReactingParcel::constantProperties
Class to hold reacting parcel constant properties.
Definition: ReactingParcel.H:82
Foam::ReactingParcel::iNew
Factory class to read-construct particles used for.
Definition: ReactingParcel.H:310
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::Re
scalarField Re(const UList< complex > &cf)
Extract real component.
Definition: complexField.C:159
Foam::ReactingParcel::constantProperties::constantProperties
constantProperties()
Null constructor.
Definition: ReactingParcelI.H:33
Cs
const scalarField & Cs
Definition: solveBulkSurfactant.H:10
particle.H
Foam::ReactingParcel::writeProperties
void writeProperties(Ostream &os, const wordRes &filters, const word &delim, const bool namesOnly=false) const
Write individual parcel properties to stream.
Definition: ReactingParcelIO.C:236
Foam::ReactingParcel::constantProperties::pMin
scalar pMin() const
Return const access to the minimum pressure.
Definition: ReactingParcelI.H:144
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::ReactingParcel::Y_
scalarField Y_
Mass fractions of mixture [].
Definition: ReactingParcel.H:178
Foam::ReactingParcel::iNew::operator()
autoPtr< ReactingParcel< ParcelType > > operator()(Istream &is) const
Definition: ReactingParcel.H:321
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
N
const Vector< label > N(dict.get< Vector< label >>("N"))
Y0
scalarList Y0(nSpecie, Zero)
Foam::ReactingParcel::clone
virtual autoPtr< particle > clone(const polyMesh &mesh) const
Construct and return a (basic particle) clone.
Definition: ReactingParcel.H:300
Foam::ReactingParcel::correctSurfaceValues
void correctSurfaceValues(TrackCloudType &cloud, trackingData &td, const scalar T, const scalarField &Cs, scalar &rhos, scalar &mus, scalar &Prs, scalar &kappas)
Correct surface values due to emitted species.
Definition: ReactingParcel.C:288
Foam::ReactingParcel
Reacting parcel class with one/two-way coupling with the continuous phase.
Definition: ReactingParcel.H:56
Foam::ReactingParcel::sizeofFields
static const std::size_t sizeofFields
Size in bytes of the fields.
Definition: ReactingParcel.H:78
Foam::ReactingParcel::updateMassFraction
scalar updateMassFraction(const scalar mass0, const scalarField &dMass, scalarField &Y) const
Update mass fraction.
Definition: ReactingParcel.C:149