SprayCloud.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-2022 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 "SprayCloud.H"
27 #include "AtomisationModel.H"
28 #include "BreakupModel.H"
29 #include "parcelThermo.H"
30 
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
32 
33 template<class CloudType>
35 {
36  atomisationModel_.reset
37  (
39  (
40  this->subModelProperties(),
41  *this
42  ).ptr()
43  );
44 
45  breakupModel_.reset
46  (
48  (
49  this->subModelProperties(),
50  *this
51  ).ptr()
52  );
53 }
54 
55 
56 template<class CloudType>
58 (
60 )
61 {
62  CloudType::cloudReset(c);
63 
64  atomisationModel_.reset(c.atomisationModel_.ptr());
65  breakupModel_.reset(c.breakupModel_.ptr());
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 
71 template<class CloudType>
73 (
74  const word& cloudName,
75  const volScalarField& rho,
76  const volVectorField& U,
77  const dimensionedVector& g,
78  const fluidThermo& carrierThermo,
79  bool readFields
80 )
81 :
82  CloudType(cloudName, rho, U, g, carrierThermo, false),
83  cloudCopyPtr_(nullptr),
84  atomisationModel_(nullptr),
85  breakupModel_(nullptr)
86 {
87  setModels();
88 
89  if (readFields)
90  {
91  parcelType::readFields(*this, this->composition());
92  this->deleteLostParticles();
93  }
94 
95  if (this->solution().resetSourcesOnStartup())
96  {
97  CloudType::resetSourceTerms();
98  }
99 }
100 
101 
102 template<class CloudType>
104 (
106  const word& name
107 )
108 :
109  CloudType(c, name),
110  cloudCopyPtr_(nullptr),
111  atomisationModel_(c.atomisationModel_->clone()),
112  breakupModel_(c.breakupModel_->clone())
113 {}
114 
115 
116 template<class CloudType>
118 (
119  const fvMesh& mesh,
120  const word& name,
121  const SprayCloud<CloudType>& c
122 )
123 :
124  CloudType(mesh, name, c),
125  cloudCopyPtr_(nullptr),
126  atomisationModel_(nullptr),
127  breakupModel_(nullptr)
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
133 template<class CloudType>
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
140 template<class CloudType>
142 (
143  parcelType& parcel,
144  const scalar lagrangianDt
145 )
146 {
147  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
148 
149  const liquidMixtureProperties& liqMix = this->composition().liquids();
150 
151  const scalarField& Y(parcel.Y());
152  scalarField X(liqMix.X(Y));
153  const scalar pc = this->p()[parcel.cell()];
154 
155  // override rho and Cp from constantProperties
156  parcel.Cp() = liqMix.Cp(pc, parcel.T(), X);
157  parcel.rho() = liqMix.rho(pc, parcel.T(), X);
158  parcel.sigma() = liqMix.sigma(pc, parcel.T(), X);
159  parcel.mu() = liqMix.mu(pc, parcel.T(), X);
160 }
161 
162 
163 template<class CloudType>
165 (
166  parcelType& parcel,
167  const scalar lagrangianDt,
168  const bool fullyDescribed
169 )
170 {
171  CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
172 
173  // store the injection position and initial drop size
174  parcel.position0() = parcel.position();
175  parcel.d0() = parcel.d();
176 
177  parcel.y() = breakup().y0();
178  parcel.yDot() = breakup().yDot0();
179 
180  parcel.liquidCore() = atomisation().initLiquidCore();
181 }
182 
183 
184 template<class CloudType>
186 {
187  cloudCopyPtr_.reset
188  (
189  static_cast<SprayCloud<CloudType>*>
190  (
191  clone(this->name() + "Copy").ptr()
192  )
193  );
194 }
195 
196 
197 template<class CloudType>
199 {
200  cloudReset(cloudCopyPtr_());
201  cloudCopyPtr_.clear();
202 }
203 
204 
205 template<class CloudType>
207 {
208  if (this->solution().canEvolve())
209  {
210  typename parcelType::trackingData td(*this);
211 
212  this->solve(*this, td);
213  }
214 }
215 
216 
217 template<class CloudType>
219 {
220  CloudType::info();
221  scalar d32 = 1.0e+6*this->Dij(3, 2);
222  scalar d10 = 1.0e+6*this->Dij(1, 0);
223  scalar dMax = 1.0e+6*this->Dmax();
224  scalar pen = this->penetration(0.95);
225 
226  Info << " D10, D32, Dmax (mu) = " << d10 << ", " << d32
227  << ", " << dMax << nl
228  << " Liquid penetration 95% mass (m) = " << pen << endl;
229 }
230 
231 
232 // ************************************************************************* //
scalar Cp(const scalar p, const scalar T, const scalarField &X) const
Calculate the mixture heat capacity [J/kg/K].
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
DSMCCloud< dsmcParcel > CloudType
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
void storeState()
Store the current cloud state.
Definition: SprayCloud.C:185
basicSpecieMixture & composition
void restoreState()
Reset the current cloud to the previously stored state.
Definition: SprayCloud.C:198
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void setModels()
Set cloud sub-models.
Definition: SprayCloud.C:34
Templated atomisation model class.
Definition: SprayCloud.H:52
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
Definition: SprayCloud.C:142
SprayCloud(const word &cloudName, const volScalarField &rho, const volVectorField &U, const dimensionedVector &g, const fluidThermo &carrierThermo, bool readFields=true)
Construct given carrier gas fields.
Definition: SprayCloud.C:73
scalar mu(const scalar p, const scalar T, const scalarField &X) const
Calculate the mixture viscosity [Pa s].
virtual ~SprayCloud()
Destructor.
Definition: SprayCloud.C:134
scalar rho(const scalar p, const scalar T, const scalarField &X) const
Calculate the mixture density [kg/m^3].
T clone(const T &t)
Definition: List.H:54
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
Definition: SprayCloud.C:165
scalarField X(const scalarField &Y) const
Returns the mole fractions corresponding to the given mass fractions.
A class for handling words, derived from string.
Definition: word.H:59
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:53
scalar sigma(const scalar p, const scalar T, const scalarField &X) const
Estimate mixture surface tension [N/m].
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:221
Templated base class for spray cloud.
Definition: SprayCloud.H:69
autoPtr< BreakupModel< SprayCloud< CloudType > > > breakupModel_
Break-up model.
Definition: SprayCloud.H:107
static const char nl
Definition: Ostream.H:260
void evolve()
Evolve the spray (inject, move)
Definition: SprayCloud.C:206
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void info()
Print cloud information.
Definition: SprayCloud.C:218
rhoEqn solve()
PtrList< volScalarField > & Y
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
void cloudReset(SprayCloud< CloudType > &c)
Reset state of cloud.
Definition: SprayCloud.C:58
messageStream Info
Templated break-up model class.
Definition: SprayCloud.H:55
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
volScalarField & p
autoPtr< AtomisationModel< SprayCloud< CloudType > > > atomisationModel_
Atomisation model.
Definition: SprayCloud.H:104