ThermoSurfaceFilm.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2023 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 \*---------------------------------------------------------------------------*/
28 
29 #include "ThermoSurfaceFilm.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 (
36  const dictionary& dict,
37  CloudType& owner
38 )
39 :
40  KinematicSurfaceFilm<CloudType>(dict, owner, typeName, false),
41  thermo_
42  (
43  owner.db().objectRegistry::template lookupObject<SLGThermo>("SLGThermo")
44  ),
45  TFilmPatch_(),
46  CpFilmPatch_()
47 {}
48 
49 
50 template<class CloudType>
52 (
54 )
55 :
56  KinematicSurfaceFilm<CloudType>(sfm, false),
57  thermo_(sfm.thermo_),
58  TFilmPatch_(sfm.TFilmPatch_),
59  CpFilmPatch_(sfm.CpFilmPatch_)
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class CloudType>
66 template<class filmType>
68 (
69  filmType& film,
70  const parcelType& p,
71  const polyPatch& pp,
72  const label facei,
73  const scalar mass,
74  bool& keepParticle
75 )
76 {
77  DebugInfo<< "Parcel " << p.origId() << " absorbInteraction" << endl;
78 
79  // Patch face normal
80  const vector& nf = pp.faceNormals()[facei];
81 
82  // Patch velocity
83  const vector& Up = this->owner().U().boundaryField()[pp.index()][facei];
84 
85  // Relative parcel velocity
86  const vector Urel(p.U() - Up);
87 
88  // Parcel normal velocity
89  const vector Un(nf*(Urel & nf));
90 
91  // Parcel tangential velocity
92  const vector Ut(Urel - Un);
93 
94  film.addSources
95  (
96  pp.index(),
97  facei,
98  mass, // mass
99  mass*Ut, // tangential momentum
100  mass*mag(Un), // impingement pressure
101  mass*p.hs() // energy
102  );
103 
104  this->nParcelsTransferred()++;
105 
106  this->totalMassTransferred() += mass;
108  keepParticle = false;
109 }
110 
111 
112 template<class CloudType>
114 (
115  parcelType& p,
116  const polyPatch& pp,
117  bool& keepParticle
118 )
119 {
120  const label patchi = pp.index();
121  const label meshFacei = p.face();
122  const label facei = pp.whichFace(meshFacei);
123 
124  this->initFilmModels();
125 
126  // Check the singleLayer film models
127  if (this->filmModel_ && this->filmModel_->isRegionPatch(patchi))
128  {
129  auto& film = *(this->filmModel_);
130 
131  switch (this->interactionType_)
132  {
134  {
135  this->bounceInteraction(p, pp, facei, keepParticle);
136 
137  break;
138  }
139 
141  {
142  const scalar m = p.nParticle()*p.mass();
143 
144  this->absorbInteraction //<regionFilm>
145  (film, p, pp, facei, m, keepParticle);
146 
147  break;
148  }
149 
151  {
152  // Local pressure
153  const scalar pc = thermo_.thermo().p()[p.cell()];
154  const liquidProperties& liq = thermo_.liquids().properties()[0];
155  const scalar sigma = liq.sigma(pc, p.T());
156  const scalar mu = liq.mu(pc, p.T());
157 
158  const bool dry
159  (
160  this->deltaFilmPatch_[patchi][facei] < this->deltaWet_
161  );
162 
163  if (dry)
164  {
165  this->drySplashInteraction //<CloudType, regionFilm>
166  (film, sigma, mu, p, pp, facei, keepParticle);
167  }
168  else
169  {
170  this->wetSplashInteraction //<regionFilm>
171  (film, sigma, mu, p, pp, facei, keepParticle);
172  }
173 
174  break;
175  }
176 
177  default:
178  {
180  << "Unknown interaction type enumeration"
181  << abort(FatalError);
182  }
183  }
184 
185  // Transfer parcel/parcel interactions complete
186  return true;
187  }
188 
189 
190  // Check the area film models
191  for (areaFilm& film : this->areaFilms_)
192  {
193  const label filmFacei
194  (
195  film.isRegionPatch(patchi)
196  ? film.regionMesh().whichFace(meshFacei)
197  : -1
198  );
199 
200  if (filmFacei < 0)
201  {
202  // Film model does not include this patch face
203  continue;
204  }
205 
206  switch (this->interactionType_)
207  {
209  {
210  this->bounceInteraction(p, pp, facei, keepParticle);
211 
212  break;
213  }
214 
216  {
217  const scalar m = p.nParticle()*p.mass();
218 
219  this->absorbInteraction //<areaFilm>
220  (
221  film, p, pp, facei, m, keepParticle
222  );
223  break;
224  }
225 
227  {
228  // Local pressure
229  const scalar pc = thermo_.thermo().p()[p.cell()];
230  const liquidProperties& liq = thermo_.liquids().properties()[0];
231  const scalar sigma = liq.sigma(pc, p.T());
232  const scalar mu = liq.mu(pc, p.T());
233 
234  const bool dry
235  (
236  film.h()[filmFacei] < this->deltaWet_
237  );
238 
239  if (dry)
240  {
241  this->drySplashInteraction //<areaFilm>
242  (film, sigma, mu, p, pp, facei, keepParticle);
243  }
244  else
245  {
246  this->wetSplashInteraction //<areaFilm>
247  (film, sigma, mu, p, pp, facei, keepParticle);
248  }
249 
250  break;
251  }
252 
253  default:
254  {
256  << "Unknown interaction type enumeration"
257  << abort(FatalError);
258  }
259  }
260 
261  // Transfer parcel/parcel interactions complete
262  return true;
263  }
264 
265  // Parcel did not interact with film
266  return false;
267 }
268 
269 
270 template<class CloudType>
272 (
273  const label filmPatchi,
274  const label primaryPatchi,
276 )
277 {
279  (
280  filmPatchi,
281  primaryPatchi,
282  filmModel
283  );
284 
285  TFilmPatch_ = filmModel.Ts().boundaryField()[filmPatchi];
286  filmModel.toPrimary(filmPatchi, TFilmPatch_);
287 
288  CpFilmPatch_ = filmModel.Cp().boundaryField()[filmPatchi];
289  filmModel.toPrimary(filmPatchi, CpFilmPatch_);
290 }
291 
292 
293 template<class CloudType>
295 (
297 )
298 {
300 
301  // Direct copy (one-to-one mapping)
302  TFilmPatch_ = film.Tf().primitiveField();
303 
304  // Direct copy (one-to-one mapping)
305  TFilmPatch_ = film.Cp().primitiveField();
306 }
307 
308 
309 template<class CloudType>
311 (
312  parcelType& p,
313  const label filmFacei
314 ) const
315 {
317 
318  // Set parcel properties
319  p.T() = TFilmPatch_[filmFacei];
320  p.Cp() = CpFilmPatch_[filmFacei];
321 }
322 
323 
324 template<class CloudType>
326 {
328 }
329 
330 
331 // ************************************************************************* //
Thermo parcel surface film model.
dictionary dict
virtual void info()
Write surface film info.
bool isRegionPatch(const label patchi) const
True if patchi on the primary region is coupled to this region.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const areaScalarField & h() const
Access const reference h.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void setParcelProperties(parcelType &p, const label filmFacei) const
Set the individual parcel properties.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
void absorbInteraction(filmType &, const parcelType &p, const polyPatch &pp, const label facei, const scalar mass, bool &keepParticle)
Absorb parcel into film.
ThermoSurfaceFilm(const dictionary &dict, CloudType &owner)
Construct from components.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
label whichFace(const label meshFacei) const
The area-face corresponding to the mesh-face, -1 if not found.
Definition: faMeshI.H:129
virtual const areaScalarField & Cp() const =0
Access const reference Cp.
virtual void setParcelProperties(parcelType &p, const label filmFacei) const
Set the individual parcel properties.
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
virtual scalar sigma(scalar p, scalar T) const =0
Surface tension [N/m].
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
CloudType::parcelType parcelType
Convenience typedef to the cloud&#39;s parcel type.
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
virtual void cacheFilmFields(const areaFilm &film)
Cache the film fields in preparation for injection.
virtual void cacheFilmFields(const label filmPatchi, const label primaryPatchi, const regionFilm &)
Cache the film fields in preparation for injection.
const faMesh & regionMesh() const
Return the region mesh database.
The thermophysical properties of a liquid.
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: SLGThermo.H:60
Urel
Definition: pEqn.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:139
#define DebugInfo
Report an information message using Foam::Info.
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field)
Kinematic parcel surface film model.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual const areaScalarField & Tf() const =0
Access const reference Tf.
virtual const volScalarField & Ts() const =0
Return the film surface temperature [K].
const dimensionedScalar mu
Atomic mass unit.
virtual const volScalarField & Cp() const =0
Return the film specific heat capacity [J/kg/K].
volScalarField & p
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
virtual scalar mu(scalar p, scalar T) const =0
Liquid viscosity [Pa s].
virtual bool transferParcel(parcelType &p, const polyPatch &pp, bool &keepParticle)
Transfer parcel from cloud to surface film.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
virtual void info()
Write surface film info.