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 | Copyright (C) 2011-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 Class
25  Foam::ReactingParcel
26 
27 Description
28  Reacting parcel class with one/two-way coupling with the continuous
29  phase.
30 
31 SourceFiles
32  ReactingParcelI.H
33  ReactingParcel.C
34  ReactingParcelIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef ReactingParcel_H
39 #define ReactingParcel_H
40 
41 #include "particle.H"
42 #include "SLGThermo.H"
43 #include "demandDrivenEntry.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 template<class ParcelType>
51 class ReactingParcel;
52 
53 template<class ParcelType>
54 Ostream& operator<<
55 (
56  Ostream&,
58 );
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class ReactingParcel Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class ParcelType>
66 class ReactingParcel
67 :
68  public ParcelType
69 {
70  // Private data
71 
72  //- Size in bytes of the fields
73  static const std::size_t sizeofFields_;
74 
75 
76 public:
77 
78  //- Class to hold reacting parcel constant properties
79  class constantProperties
80  :
81  public ParcelType::constantProperties
82  {
83  // Private data
84 
85  //- Minimum pressure [Pa]
87 
88  //- Constant volume flag - e.g. during mass transfer
90 
91 
92  public:
93 
94  // Constructors
95 
96  //- Null constructor
98 
99  //- Copy constructor
101 
102  //- Construct from dictionary
103  constantProperties(const dictionary& parentDict);
104 
105 
106  // Access
107 
108  //- Return const access to the minimum pressure
109  inline scalar pMin() const;
110 
111  //- Return const access to the constant volume flag
112  inline bool constantVolume() const;
113  };
114 
115 
116  template<class CloudType>
117  class TrackingData
118  :
119  public ParcelType::template TrackingData<CloudType>
120  {
121  private:
122 
123  // Private data
124 
125  // Interpolators for continuous phase fields
126 
127  //- Interpolator for continuous phase pressure field
129 
130 
131  public:
132 
133  typedef typename ParcelType::template TrackingData<CloudType>::trackPart
134  trackPart;
135 
136  // Constructors
137 
138  //- Construct from components
139  inline TrackingData
140  (
141  CloudType& cloud,
142  trackPart part = ParcelType::template
144  );
145 
146 
147  // Member functions
148 
149  //- Return const access to the interpolator for continuous phase
150  // pressure field
151  inline const interpolation<scalar>& pInterp() const;
152  };
153 
154 
155 protected:
156 
157  // Protected data
158 
159  // Parcel properties
160 
161  //- Initial mass [kg]
162  scalar mass0_;
163 
164  //- Mass fractions of mixture []
165  scalarField Y_;
166 
167 
168  // Cell-based quantities
169 
170  //- Pressure [Pa]
171  scalar pc_;
172 
173 
174  // Protected Member Functions
175 
176  //- Calculate Phase change
177  template<class TrackData>
178  void calcPhaseChange
179  (
180  TrackData& td,
181  const scalar dt, // timestep
182  const label cellI, // owner cell
183  const scalar Re, // Reynolds number
184  const scalar Pr, // Prandtl number
185  const scalar Ts, // Surface temperature
186  const scalar nus, // Surface kinematic viscosity
187  const scalar d, // diameter
188  const scalar T, // temperature
189  const scalar mass, // mass
190  const label idPhase, // id of phase involved in phase change
191  const scalar YPhase, // total mass fraction
192  const scalarField& YComponents, // component mass fractions
193  scalarField& dMassPC, // mass transfer - local to parcel
194  scalar& Sh, // explicit parcel enthalpy source
195  scalar& N, // flux of species emitted from parcel
196  scalar& NCpW, // sum of N*Cp*W of emission species
197  scalarField& Cs // carrier conc. of emission species
198  );
199 
200  //- Update mass fraction
201  scalar updateMassFraction
202  (
203  const scalar mass0,
204  const scalarField& dMass,
205  scalarField& Y
206  ) const;
207 
208 
209 public:
210 
211  // Static data members
212 
213  //- Runtime type information
214  TypeName("ReactingParcel");
215 
216  //- String representation of properties
218  (
219  ParcelType,
220  " mass0"
221  + " nPhases(Y1..YN)"
222  );
223 
224 
225  // Constructors
226 
227  //- Construct from owner, position, and cloud owner
228  // Other properties initialised as null
229  inline ReactingParcel
230  (
231  const polyMesh& mesh,
232  const vector& position,
233  const label cellI,
234  const label tetFaceI,
235  const label tetPtI
236  );
237 
238  //- Construct from components
239  inline ReactingParcel
240  (
241  const polyMesh& mesh,
242  const vector& position,
243  const label cellI,
244  const label tetFaceI,
245  const label tetPtI,
246  const label typeId,
247  const scalar nParticle0,
248  const scalar d0,
249  const scalar dTarget0,
250  const vector& U0,
251  const vector& f0,
252  const vector& angularMomentum0,
253  const vector& torque0,
254  const scalarField& Y0,
255  const constantProperties& constProps
256  );
257 
258  //- Construct from Istream
260  (
261  const polyMesh& mesh,
262  Istream& is,
263  bool readFields = true
264  );
265 
266  //- Construct as a copy
268  (
269  const ReactingParcel& p,
270  const polyMesh& mesh
271  );
272 
273  //- Construct as a copy
275 
276  //- Construct and return a (basic particle) clone
277  virtual autoPtr<particle> clone() const
278  {
280  }
281 
282  //- Construct and return a (basic particle) clone
283  virtual autoPtr<particle> clone(const polyMesh& mesh) const
284  {
285  return autoPtr<particle>
286  (
287  new ReactingParcel<ParcelType>(*this, mesh)
288  );
289  }
290 
291  //- Factory class to read-construct particles used for
292  // parallel transfer
293  class iNew
294  {
295  const polyMesh& mesh_;
296 
297  public:
298 
299  iNew(const polyMesh& mesh)
300  :
301  mesh_(mesh)
302  {}
303 
305  {
307  (
308  new ReactingParcel<ParcelType>(mesh_, is, true)
309  );
310  }
311  };
312 
313 
314  // Member Functions
315 
316  // Access
317 
318  //- Return const access to initial mass [kg]
319  inline scalar mass0() const;
320 
321  //- Return const access to mass fractions of mixture []
322  inline const scalarField& Y() const;
323 
324  //- Return the owner cell pressure [Pa]
325  inline scalar pc() const;
326 
327  //- Return reference to the owner cell pressure [Pa]
328  inline scalar& pc();
329 
330 
331  // Edit
332 
333  //- Return access to initial mass [kg]
334  inline scalar& mass0();
335 
336  //- Return access to mass fractions of mixture []
337  inline scalarField& Y();
338 
339 
340  // Main calculation loop
341 
342  //- Set cell values
343  template<class TrackData>
344  void setCellValues
345  (
346  TrackData& td,
347  const scalar dt,
348  const label cellI
349  );
350 
351  //- Correct cell values using latest transfer information
352  template<class TrackData>
354  (
355  TrackData& td,
356  const scalar dt,
357  const label cellI
358  );
359 
360  //- Correct surface values due to emitted species
361  template<class TrackData>
363  (
364  TrackData& td,
365  const label cellI,
366  const scalar T,
367  const scalarField& Cs,
368  scalar& rhos,
369  scalar& mus,
370  scalar& Prs,
371  scalar& kappas
372  );
373 
374  //- Update parcel properties over the time interval
375  template<class TrackData>
376  void calc
377  (
378  TrackData& td,
379  const scalar dt,
380  const label cellI
381  );
382 
383 
384  // I-O
385 
386  //- Read
387  template<class CloudType, class CompositionType>
388  static void readFields
389  (
390  CloudType& c,
391  const CompositionType& compModel
392  );
393 
394  //- Read - no composition
395  template<class CloudType>
396  static void readFields(CloudType& c);
397 
398  //- Write
399  template<class CloudType, class CompositionType>
400  static void writeFields
401  (
402  const CloudType& c,
403  const CompositionType& compModel
404  );
405 
406  //- Write - composition supplied
407  template<class CloudType>
408  static void writeFields(const CloudType& c);
409 
410 
411  // Ostream Operator
412 
413  friend Ostream& operator<< <ParcelType>
414  (
415  Ostream&,
417  );
418 };
419 
420 
421 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
422 
423 } // End namespace Foam
424 
425 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
426 
427 #include "ReactingParcelI.H"
429 
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
431 
432 #ifdef NoRepository
433  #include "ReactingParcel.C"
434 #endif
435 
436 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
437 
438 #endif
439 
440 // ************************************************************************* //
Foam::ReactingParcel::mass0
scalar mass0() const
Return const access to initial mass [kg].
Definition: ReactingParcelI.H:146
Foam::ReactingParcel::iNew::mesh_
const polyMesh & mesh_
Definition: ReactingParcel.H:294
Foam::ReactingParcel::AddToPropertyList
AddToPropertyList(ParcelType, " mass0"+" nPhases(Y1..YN)")
String representation of properties.
Foam::ReactingParcel::clone
virtual autoPtr< particle > clone() const
Construct and return a (basic particle) clone.
Definition: ReactingParcel.H:276
Foam::ReactingParcel::constantProperties::constantVolume_
demandDrivenEntry< bool > constantVolume_
Constant volume flag - e.g. during mass transfer.
Definition: ReactingParcel.H:88
Foam::ReactingParcel::TrackingData
Definition: ReactingParcel.H:116
p
p
Definition: pEqn.H:62
Sh
scalar Sh
Definition: solveChemistry.H:2
ReactingParcelTrackingDataI.H
Foam::ReactingParcel::readFields
static void readFields(CloudType &c, const CompositionType &compModel)
Read.
Definition: ReactingParcelIO.C:103
Foam::Re
scalarField Re(const UList< complex > &cf)
Definition: complexFields.C:97
demandDrivenEntry.H
Foam::ReactingParcel::sizeofFields_
static const std::size_t sizeofFields_
Size in bytes of the fields.
Definition: ReactingParcel.H:72
Foam::ReactingParcel::pc
scalar pc() const
Return the owner cell pressure [Pa].
Definition: ReactingParcelI.H:160
Foam::ReactingParcel::TypeName
TypeName("ReactingParcel")
Runtime type information.
Foam::ReactingParcel::TrackingData::trackPart
ParcelType::template TrackingData< CloudType >::trackPart trackPart
Definition: ReactingParcel.H:133
SLGThermo.H
Foam::ReactingParcel::Y
const scalarField & Y() const
Return const access to mass fractions of mixture [].
Definition: ReactingParcelI.H:153
Foam::cp
bool cp(const fileName &src, const fileName &dst)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:755
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::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::ReactingParcel::pc_
scalar pc_
Pressure [Pa].
Definition: ReactingParcel.H:170
Foam::ReactingParcel::constantProperties::pMin_
demandDrivenEntry< scalar > pMin_
Minimum pressure [Pa].
Definition: ReactingParcel.H:85
Foam::ReactingParcel::TrackingData::TrackingData
TrackingData(CloudType &cloud, trackPart part=ParcelType::template TrackingData< CloudType >::tpLinearTrack)
Construct from components.
Definition: ReactingParcelTrackingDataI.H:29
Foam::ReactingParcel::TrackingData::pInterp_
autoPtr< interpolation< scalar > > pInterp_
Interpolator for continuous phase pressure field.
Definition: ReactingParcel.H:127
ReactingParcel.C
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
ReactingParcelI.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Y0
scalarList Y0(nSpecie, 0.0)
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::ReactingParcel::ReactingParcel
ReactingParcel(const polyMesh &mesh, const vector &position, const label cellI, const label tetFaceI, const label tetPtI)
Construct from owner, position, and cloud owner.
Definition: ReactingParcelI.H:64
Pr
dimensionedScalar Pr("Pr", dimless, laminarTransport)
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
Foam::interpolation< scalar >
Foam::ReactingParcel::iNew::iNew
iNew(const polyMesh &mesh)
Definition: ReactingParcel.H:298
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::ReactingParcel::mass0_
scalar mass0_
Initial mass [kg].
Definition: ReactingParcel.H:161
Foam::ReactingParcel::writeFields
static void writeFields(const CloudType &c, const CompositionType &compModel)
Write.
Definition: ReactingParcelIO.C:175
Foam::ReactingParcel::setCellValues
void setCellValues(TrackData &td, const scalar dt, const label cellI)
Set cell values.
Definition: ReactingParcel.C:204
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::cloud
A cloud is a collection of lagrangian particles.
Definition: cloud.H:51
Foam::ReactingParcel::constantProperties::constantVolume
bool constantVolume() const
Return const access to the constant volume flag.
Definition: ReactingParcelI.H:137
Foam::Vector< scalar >
Foam::demandDrivenEntry< scalar >
Foam::ReactingParcel::constantProperties
Class to hold reacting parcel constant properties.
Definition: ReactingParcel.H:78
Foam::ReactingParcel::iNew
Factory class to read-construct particles used for.
Definition: ReactingParcel.H:292
Foam::ReactingParcel::constantProperties::constantProperties
constantProperties()
Null constructor.
Definition: ReactingParcelI.H:30
Foam::ReactingParcel::cellValueSourceCorrection
void cellValueSourceCorrection(TrackData &td, const scalar dt, const label cellI)
Correct cell values using latest transfer information.
Definition: ReactingParcel.C:235
particle.H
Foam::ReactingParcel::constantProperties::pMin
scalar pMin() const
Return const access to the minimum pressure.
Definition: ReactingParcelI.H:129
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:164
Foam::ReactingParcel::iNew::operator()
autoPtr< ReactingParcel< ParcelType > > operator()(Istream &is) const
Definition: ReactingParcel.H:303
Foam::ReactingParcel::calc
void calc(TrackData &td, const scalar dt, const label cellI)
Update parcel properties over the time interval.
Definition: ReactingParcel.C:388
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::ReactingParcel::clone
virtual autoPtr< particle > clone(const polyMesh &mesh) const
Construct and return a (basic particle) clone.
Definition: ReactingParcel.H:282
Foam::ReactingParcel::TrackingData::pInterp
const interpolation< scalar > & pInterp() const
Return const access to the interpolator for continuous phase.
Definition: ReactingParcelTrackingDataI.H:49
Foam::ReactingParcel::correctSurfaceValues
void correctSurfaceValues(TrackData &td, const label cellI, const scalar T, const scalarField &Cs, scalar &rhos, scalar &mus, scalar &Prs, scalar &kappas)
Correct surface values due to emitted species.
Definition: ReactingParcel.C:296
Foam::ReactingParcel
Reacting parcel class with one/two-way coupling with the continuous phase.
Definition: ReactingParcel.H:50
Foam::ReactingParcel::calcPhaseChange
void calcPhaseChange(TrackData &td, const scalar dt, const label cellI, 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:39
Foam::ReactingParcel::updateMassFraction
scalar updateMassFraction(const scalar mass0, const scalarField &dMass, scalarField &Y) const
Update mass fraction.
Definition: ReactingParcel.C:149
N
label N
Definition: createFields.H:22