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-2022 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>
67 (
68  parcelType& p,
69  const polyPatch& pp,
70  bool& keepParticle
71 )
72 {
73  const label patchi = pp.index();
74  const label meshFacei = p.face();
75  const label facei = pp.whichFace(meshFacei);
76 
77  this->initFilmModels();
78 
79  // Check the singleLayer film models
80  if (this->filmModel_ && this->filmModel_->isRegionPatch(patchi))
81  {
82  auto& film = *(this->filmModel_);
83 
84  switch (this->interactionType_)
85  {
87  {
88  this->bounceInteraction(p, pp, facei, keepParticle);
89 
90  break;
91  }
92 
93  case KinematicSurfaceFilm<CloudType>::itAbsorb:
94  {
95  const scalar m = p.nParticle()*p.mass();
96 
97  this->absorbInteraction //<regionFilm>
98  (film, p, pp, facei, m, keepParticle);
99 
100  break;
101  }
102 
103  case KinematicSurfaceFilm<CloudType>::itSplashBai:
104  {
105  // Local pressure
106  const scalar pc = thermo_.thermo().p()[p.cell()];
107  const liquidProperties& liq = thermo_.liquids().properties()[0];
108  const scalar sigma = liq.sigma(pc, p.T());
109  const scalar mu = liq.mu(pc, p.T());
110 
111  const bool dry
112  (
113  this->deltaFilmPatch_[patchi][facei] < this->deltaWet_
114  );
115 
116  if (dry)
117  {
118  this->drySplashInteraction //<CloudType, regionFilm>
119  (film, sigma, mu, p, pp, facei, keepParticle);
120  }
121  else
122  {
123  this->wetSplashInteraction //<regionFilm>
124  (film, sigma, mu, p, pp, facei, keepParticle);
125  }
126 
127  break;
128  }
129 
130  default:
131  {
133  << "Unknown interaction type enumeration"
134  << abort(FatalError);
135  }
136  }
137 
138  // Transfer parcel/parcel interactions complete
139  return true;
140  }
141 
142 
143  // Check the area film models
144  for (areaFilm& film : this->areaFilms_)
145  {
146  const label filmFacei
147  (
148  film.isRegionPatch(patchi)
149  ? film.regionMesh().whichFace(meshFacei)
150  : -1
151  );
152 
153  if (filmFacei < 0)
154  {
155  // Film model does not include this patch face
156  continue;
157  }
158 
159  switch (this->interactionType_)
160  {
161  case KinematicSurfaceFilm<CloudType>::itBounce:
162  {
163  this->bounceInteraction(p, pp, facei, keepParticle);
164 
165  break;
166  }
167 
168  case KinematicSurfaceFilm<CloudType>::itAbsorb:
169  {
170  const scalar m = p.nParticle()*p.mass();
171 
172  this->absorbInteraction //<areaFilm>
173  (
174  film, p, pp, facei, m, keepParticle
175  );
176  break;
177  }
178 
179  case KinematicSurfaceFilm<CloudType>::itSplashBai:
180  {
181  // Local pressure
182  const scalar pc = thermo_.thermo().p()[p.cell()];
183  const liquidProperties& liq = thermo_.liquids().properties()[0];
184  const scalar sigma = liq.sigma(pc, p.T());
185  const scalar mu = liq.mu(pc, p.T());
186 
187  const bool dry
188  (
189  film.h()[filmFacei] < this->deltaWet_
190  );
191 
192  if (dry)
193  {
194  this->drySplashInteraction //<areaFilm>
195  (film, sigma, mu, p, pp, facei, keepParticle);
196  }
197  else
198  {
199  this->wetSplashInteraction //<areaFilm>
200  (film, sigma, mu, p, pp, facei, keepParticle);
201  }
202 
203  break;
204  }
205 
206  default:
207  {
209  << "Unknown interaction type enumeration"
210  << abort(FatalError);
211  }
212  }
213 
214  // Transfer parcel/parcel interactions complete
215  return true;
216  }
217 
218  // Parcel did not interact with film
219  return false;
220 }
221 
222 
223 template<class CloudType>
225 (
226  const label filmPatchi,
227  const label primaryPatchi,
229 )
230 {
232  (
233  filmPatchi,
234  primaryPatchi,
235  filmModel
236  );
237 
238  TFilmPatch_ = filmModel.Ts().boundaryField()[filmPatchi];
239  filmModel.toPrimary(filmPatchi, TFilmPatch_);
240 
241  CpFilmPatch_ = filmModel.Cp().boundaryField()[filmPatchi];
242  filmModel.toPrimary(filmPatchi, CpFilmPatch_);
243 }
244 
245 
246 template<class CloudType>
248 (
250 )
251 {
253 
254  // Direct copy (one-to-one mapping)
255  TFilmPatch_ = film.Tf().primitiveField();
256 
257  // Direct copy (one-to-one mapping)
258  TFilmPatch_ = film.Cp().primitiveField();
259 }
260 
261 
262 template<class CloudType>
264 (
265  parcelType& p,
266  const label filmFacei
267 ) const
268 {
270 
271  // Set parcel properties
272  p.T() = TFilmPatch_[filmFacei];
273  p.Cp() = CpFilmPatch_[filmFacei];
274 }
275 
276 
277 template<class CloudType>
279 {
281 }
282 
283 
284 // ************************************************************************* //
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.
label whichFace(const label facei) const noexcept
Return label of face in patch from global face label.
Definition: polyPatch.H:563
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
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:120
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:578
ThermoSurfaceFilm(const dictionary &dict, CloudType &owner)
Construct from components.
label whichFace(const label meshFacei) const
The area-face corresponding to the mesh-face, -1 if not found.
Definition: faMeshI.H:141
virtual const areaScalarField & Cp() const =0
Access const reference Cp.
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
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.
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: SLGThermo.H:60
errorManip< error > abort(error &err)
Definition: errorManip.H:139
Kinematic parcel surface film model.
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].
label index() const noexcept
The index of this patch in the boundaryMesh.
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 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.