liquidFilmThermo.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) 2013-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "liquidFilmThermo.H"
29#include "demandDrivenData.H"
30#include "thermoSingleLayer.H"
31#include "SLGThermo.H"
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37namespace Foam
38{
39namespace regionModels
40{
41namespace surfaceFilmModels
42{
43
44// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45
47
49(
53);
54
55
56// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
57
59{
60 if (!isA<thermoSingleLayer>(filmModel_))
61 {
63 << "Thermo model requires a " << thermoSingleLayer::typeName
64 << " film to supply the pressure and temperature, but "
65 << filmModel_.type() << " film model selected. "
66 << "Use the 'useReferenceValues' flag to employ reference "
67 << "pressure and temperature" << exit(FatalError);
68 }
69
70 return refCast<const thermoSingleLayer>(filmModel_);
71}
72
73
75{
76 if (liquidPtr_ != nullptr)
77 {
78 return;
79 }
80
81 dict.readEntry("liquid", name_);
82
83 const SLGThermo* thermoPtr =
85
86 if (thermoPtr)
87 {
88 // Retrieve from film thermo
89 ownLiquid_ = false;
90
91 const SLGThermo& thermo = *thermoPtr;
92
93 const label id = thermo.liquidId(name_);
94
95 liquidPtr_ = &thermo.liquids().properties()[id];
96 }
97 else
98 {
99 // New liquid create
100 ownLiquid_ = true;
101
102 liquidPtr_ =
104 }
105}
106
107
108// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
109
111(
113 const dictionary& dict
114)
115:
116 filmThermoModel(typeName, film, dict),
117 name_("unknown_liquid"),
118 liquidPtr_(nullptr),
119 ownLiquid_(false),
120 useReferenceValues_(coeffDict_.get<bool>("useReferenceValues")),
121 pRef_(0.0),
122 TRef_(0.0)
123{
125
127 {
128 coeffDict_.readEntry("pRef", pRef_);
129 coeffDict_.readEntry("TRef", TRef_);
130 }
131}
132
133
134// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
135
137{
138 if (ownLiquid_)
139 {
141 }
142}
143
144
145// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
146
148{
149 return name_;
150}
151
152
154(
155 const scalar p,
156 const scalar T
157) const
158{
159 return liquidPtr_->rho(p, T);
160}
161
162
164(
165 const scalar p,
166 const scalar T
167) const
168{
169 return liquidPtr_->mu(p, T);
170}
171
172
174(
175 const scalar p,
176 const scalar T
177) const
178{
179 return liquidPtr_->sigma(p, T);
180}
181
182
184(
185 const scalar p,
186 const scalar T
187) const
188{
189 return liquidPtr_->Cp(p, T);
190}
191
192
194(
195 const scalar p,
196 const scalar T
197) const
198{
199 return liquidPtr_->kappa(p, T);
200}
201
202
204(
205 const scalar p,
206 const scalar T
207) const
208{
209 return liquidPtr_->D(p, T);
210}
211
212
214(
215 const scalar p,
216 const scalar T
217) const
218{
219 return liquidPtr_->hl(p, T);
220}
221
222
224(
225 const scalar p,
226 const scalar T
227) const
228{
229 return liquidPtr_->pv(p, T);
230}
231
232
234{
235 return liquidPtr_->W();
236}
237
238
239scalar liquidFilmThermo::Tb(const scalar p) const
240{
241 return liquidPtr_->pvInvert(p);
242}
243
244
246{
248 (
250 (
252 (
253 type() + ":rho",
254 film().time().timeName(),
255 film().regionMesh(),
258 ),
259 film().regionMesh(),
261 extrapolatedCalculatedFvPatchScalarField::typeName
262 )
263 );
264
265 scalarField& rho = trho.ref().primitiveFieldRef();
266
268 {
269 rho = this->rho(pRef_, TRef_);
270 }
271 else
272 {
274
275 const volScalarField& T = film.T();
276 const volScalarField& p = film.pPrimary();
277
278 forAll(rho, celli)
279 {
280 rho[celli] = this->rho(p[celli], T[celli]);
281 }
282 }
283
284 trho.ref().correctBoundaryConditions();
285
286 return trho;
287}
288
289
291{
293 (
295 (
297 (
298 type() + ":mu",
299 film().time().timeName(),
300 film().regionMesh(),
303 ),
304 film().regionMesh(),
306 extrapolatedCalculatedFvPatchScalarField::typeName
307 )
308 );
309
310 scalarField& mu = tmu.ref().primitiveFieldRef();
311
313 {
314 mu = this->mu(pRef_, TRef_);
315 }
316 else
317 {
319
320 const volScalarField& T = film.T();
321 const volScalarField& p = film.pPrimary();
322
323 forAll(mu, celli)
324 {
325 mu[celli] = this->mu(p[celli], T[celli]);
326 }
327 }
328
329 tmu.ref().correctBoundaryConditions();
330
331 return tmu;
332}
333
334
336{
338 (
340 (
342 (
343 type() + ":sigma",
344 film().time().timeName(),
345 film().regionMesh(),
348 ),
349 film().regionMesh(),
351 extrapolatedCalculatedFvPatchScalarField::typeName
352 )
353 );
354
355 scalarField& sigma = tsigma.ref().primitiveFieldRef();
356
358 {
359 sigma = this->sigma(pRef_, TRef_);
360 }
361 else
362 {
364
365 const volScalarField& T = film.T();
366 const volScalarField& p = film.pPrimary();
367
368 forAll(sigma, celli)
369 {
370 sigma[celli] = this->sigma(p[celli], T[celli]);
371 }
372 }
373
374 tsigma.ref().correctBoundaryConditions();
375
376 return tsigma;
377}
378
379
381{
383 (
385 (
387 (
388 type() + ":Cp",
389 film().time().timeName(),
390 film().regionMesh(),
393 ),
394 film().regionMesh(),
396 extrapolatedCalculatedFvPatchScalarField::typeName
397 )
398 );
399
400 scalarField& Cp = tCp.ref().primitiveFieldRef();
401
403 {
404 Cp = this->Cp(pRef_, TRef_);
405 }
406 else
407 {
409
410 const volScalarField& T = film.T();
411 const volScalarField& p = film.pPrimary();
412
413 forAll(Cp, celli)
414 {
415 Cp[celli] = this->Cp(p[celli], T[celli]);
416 }
417 }
418
419 tCp.ref().correctBoundaryConditions();
420
421 return tCp;
422}
423
424
426{
428 (
430 (
432 (
433 type() + ":kappa",
434 film().time().timeName(),
435 film().regionMesh(),
438 ),
439 film().regionMesh(),
441 extrapolatedCalculatedFvPatchScalarField::typeName
442 )
443 );
444
445 scalarField& kappa = tkappa.ref().primitiveFieldRef();
446
448 {
449 kappa = this->kappa(pRef_, TRef_);
450 }
451 else
452 {
454
455 const volScalarField& T = film.T();
456 const volScalarField& p = film.pPrimary();
457
458 forAll(kappa, celli)
459 {
460 kappa[celli] = this->kappa(p[celli], T[celli]);
461 }
462 }
463
464 tkappa.ref().correctBoundaryConditions();
465
466 return tkappa;
467}
468
469
470// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
471
472} // End namespace surfaceFilmModels
473} // End namespace regionModels
474} // End namespace Foam
475
476// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package,...
Definition: SLGThermo.H:67
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:577
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
virtual tmp< volScalarField > Tb() const
Burnt gas temperature [K].
virtual scalar mu(scalar p, scalar T) const =0
Liquid viscosity [Pa s].
virtual scalar D(scalar p, scalar T) const =0
Vapour diffusivity [m2/s].
virtual scalar hl(scalar p, scalar T) const =0
Heat of vapourisation [J/kg].
virtual scalar sigma(scalar p, scalar T) const =0
Surface tension [N/m].
virtual scalar pv(scalar p, scalar T) const =0
Vapour pressure [Pa].
virtual scalar pvInvert(scalar p) const
Invert the vapour pressure relationship to retrieve the.
virtual scalar kappa(scalar p, scalar T) const =0
Liquid thermal conductivity [W/(m K)].
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const fvMesh & primaryMesh() const
Return the reference to the primary mesh database.
Definition: regionModelI.H:34
const surfaceFilmRegionModel & film() const
Return const access to the film surface film model.
surfaceFilmRegionModel & filmModel_
Reference to the film surface film model.
virtual scalar W() const
Return molecular weight [kg/kmol].
const thermoSingleLayer & thermoFilm() const
Return a reference to a thermo film.
virtual tmp< volScalarField > Cp() const
Return specific heat capacity [J/kg/K].
virtual tmp< volScalarField > kappa() const
Return thermal conductivity [W/m/K].
bool useReferenceValues_
Flag to indicate that reference values of p and T should be used.
virtual const word & name() const
Return the specie name.
virtual scalar pv(const scalar p, const scalar T) const
Return vapour pressure [Pa].
void initLiquid(const dictionary &dict)
Initialise the liquid pointer.
virtual tmp< volScalarField > sigma() const
Return surface tension [kg/s2].
virtual scalar hl(const scalar p, const scalar T) const
Return latent heat [J/kg].
virtual tmp< volScalarField > mu() const
Return dynamic viscosity [Pa.s].
bool ownLiquid_
Flag to indicate that model owns the liquid object.
virtual tmp< volScalarField > rho() const
Return density [kg/m3].
const liquidProperties * liquidPtr_
Pointer to the liquid properties.
virtual const volScalarField & T() const =0
Return the film mean temperature [K].
Thermodynamic form of single-cell layer surface film model.
const dictionary coeffDict_
Coefficients dictionary.
Definition: subModelBase.H:82
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:113
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
scalar W() const
Molecular weight [kg/kmol].
virtual scalar rho(scalar p, scalar T) const =0
Liquid density [kg/m^3].
virtual scalar Cp(const scalar p, const scalar T) const =0
Heat capacity at constant pressure [J/(kg K)].
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
const volScalarField & T
const tmp< volScalarField > & tCp
Definition: EEqn.H:4
bool
Definition: EEqn.H:20
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
word timeName
Definition: getTimeIndex.H:3
Namespace for OpenFOAM.
const dimensionSet dimPressure
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimPower
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimEnergy
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
const dimensionSet dimDensity
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
void deleteDemandDrivenData(DataPtr &dataPtr)
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:51
dictionary dict
tmp< volScalarField > trho
const dimensionedScalar & D
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
static const char *const typeName
The type name used in ensight case files.