wallCondensation.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) 2026 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 "wallCondensation.H"
27 
28 #include "multiphaseEuler.H"
29 
32 
34 
39 
41 
42 /*---------------------------------------------------------------------------*\
43  Class wallCondensation::properties Declaration
44 \*---------------------------------------------------------------------------*/
45 
47 {
48  //- Typedef to shorten the name of the Jayatilleke wall function
49  typedef
52 
53  //- Wall function field
55 
56  //- Patch index
57  const label patchi;
58 
59  //- Liquid volume fraction
61 
62  //- Vapour volume fraction
64 
65  //- Liquid thermophysical transport model
67 
68  //- Vapour thermophysical transport model
70 
71  //- Liquid convective turbulent thermal diffusivity
73 
74  //- Phase convective turbulent thermal diffusivity
76 
77  //- Patch area by neighbouring cell volume ratio
79 
80  //- Vapour heat capacity
82 
83  //- Cell temperature
85 
86  //- Patch temperature
88 
89  //- Saturation pressure
91 
92  //- Latent heat
93  const scalarField L;
94 
95  //- Patch
96  inline const fvPatch& patch() const
97  {
98  return model.mesh().boundary()[patchi];
99  }
100 
101  //- Constructor
103  (
104  const wallCondensation& model,
105  const label patchi
106  )
107  :
108  model(model),
109  patchi(patchi),
110  alphaLiquid(model.liquid_.boundaryField()[patchi]),
111  alphaVapour(model.vapour_.boundaryField()[patchi]),
112  ttmLiquid
113  (
115  (
116  model.liquid_.name()
117  )
118  ),
119  ttmVapour
120  (
122  (
123  model.vapour_.name()
124  )
125  ),
127  (
129  ),
131  (
133  ),
134  AbyV
135  (
136  patch().magSf()
137  /scalarField
138  (
139  patch().mesh().V(),
140  patch().faceCells()
141  )
142  ),
143  CpVapour(model.vapour_.thermo().Cp().boundaryField()[patchi]),
144  TcVapour
145  (
146  model.vapour_.thermo().T().boundaryField()[patchi]
147  .patchInternalField()
148  ),
149  TwVapour
150  (
151  model.vapour_.thermo().T().boundaryField()[patchi]
152  ),
153  pSat
154  (
155  model.saturationModelPtr_->pSat
156  (
157  TwVapour
158  )
159  ),
160  L
161  (
162  model.L
163  (
164  patchi,
165  TwVapour
166  )
167  )
168  {}
169 };
170 
171 
172 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
173 
174 namespace Foam
175 {
176 namespace fv
177 {
180 }
181 }
182 
183 
184 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
185 
186 void Foam::fv::wallCondensation::readCoeffs(const dictionary& dict)
187 {
189 
190  saturationModelPtr_.reset
191  (
193  (
194  "saturationPressure",
195  dict
196  ).ptr()
197  );
198 
199  Prt_ = dict.lookupOrDefault<scalar>("Prt", dimless, 0.85);
200 
201  Sct_ = dict.lookupOrDefault<scalar>("Sct", dimless, 0.7);
202 
203  specieSemiImplicit_ =
204  dict.lookupOrDefault<bool>("specieSemiImplicit", false);
205 }
206 
207 
208 void Foam::fv::wallCondensation::correctMDot() const
209 {
210  Info<< type() << ": " << name() << endl << incrIndent;
211 
212  //- Reset the phase-change rates in all the near-wall cells
213  forAll(mDot_.boundaryField(), patchi)
214  {
215  if (!isPatchActive(patchi)) continue;
216 
217  const labelUList& faceCells = mesh().boundary()[patchi].faceCells();
218  forAll(faceCells, i)
219  {
220  mDot_[faceCells[i]] = scalar(0);
221  mDotDy_[faceCells[i]] = scalar(0);
222  }
223  }
224 
225  // Loop the active patches, evaluate the model, and sum the phase change
226  // rates into the adjacent cells
227  forAll(mDot_.boundaryField(), patchi)
228  {
229  if (!isPatchActive(patchi)) continue;
230 
231  // Access the wall-condensation phase-change patch field for this patch
232  wallCondensationPhaseChangeRateFvPatchScalarField& mDot =
233  mDotPfRef(patchi);
234 
235  scalarField& mDotDy = mDotDy_.boundaryFieldRef()[patchi];
236 
237  // Construct properties
238  const properties props(*this, patchi);
239 
240  const fluidMulticomponentThermo& thermo =
241  fluidMulticomponentThermos(true, false)[0];
242 
243  const label speciei = specieis()[0];
244 
245  // Calculate effective diffusivity
246  const scalarField DEff
247  (
248  props.ttmVapour.D(vapour_.Y(species()[0]), patchi)
249  + Prt_/Sct_*props.alphatConvVapour
250  );
251 
252  const scalarField xc
253  (
254  vapour_
255  .Y(species()[0]).boundaryField()[patchi].patchInternalField()
256  /thermo.WiValue(speciei)
257  *thermo.W(patchi) // Assuming zeroGradient for species
258  );
259 
260  const scalarField xw(props.pSat/thermo.p().boundaryField()[patchi]);
261 
262  mDot =
263  - props.alphaVapour
264  *props.AbyV
265  *thermo.WiValue(speciei)/thermo.W(patchi)*DEff
266  *props.patch().deltaCoeffs()
267  *log(max(1 - xc, scalar(0.001))/max(1 - xw, scalar(0.001)));
268 
269  if (specieSemiImplicit_)
270  {
271  mDotDy =
272  props.alphaVapour
273  *props.AbyV
274  *DEff
275  *props.patch().deltaCoeffs()
276  /max(1 - xc, scalar(0.001))*pos(xc - xw);
277  }
278  else
279  {
280  mDotDy = Zero;
281  }
282 
283  // Only allow condensation
284  mDot.condensing_ = pos(mDot);
285  mDot = max(mDot, scalar(0));
286 
287  const scalarField gradT
288  (
289  props.patch().deltaCoeffs()
290  *min(props.TwVapour - props.TcVapour, -rootSmall*props.TcVapour)
291  );
292 
293  const scalarField q(mDot*props.L/props.AbyV);
294 
295  const scalarField alphatCondensingVapour
296  (
297  q/props.CpVapour/gradT/max(props.alphaVapour, rootSmall)
298  );
299 
300  mDot.alphatVapour_ = props.alphatConvVapour + alphatCondensingVapour;
301  mDot.alphatLiquid_ = props.alphatConvLiquid;
302 
303  infoField
304  (
305  "mDot[" + mesh().boundary()[patchi].name() + "]",
307  mDot
308  );
309 
310  // Sum the phase change rate into the internal field
311  const labelUList& faceCells = mesh().boundary()[patchi].faceCells();
312  forAll(faceCells, i)
313  {
314  mDot_[faceCells[i]] += mDot[i];
315  mDotDy_[faceCells[i]] += mDotDy[i];
316  }
317  }
318 
319  Info<< decrIndent;
320 }
321 
322 
323 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
324 
326 (
327  const word& name,
328  const word& modelType,
329  const fvMesh& mesh,
330  const dictionary& dict
331 )
332 :
334  (
335  name,
336  modelType,
337  mesh,
338  dict,
339  readSpecie(coeffs(modelType, dict), true)
340  ),
341  liquid_(phases().second()),
342  vapour_(phases().first()),
343  alphatLiquid_(wallPhaseChange::alphats().second()),
344  alphatVapour_(wallPhaseChange::alphats().first()),
345  p_rgh_
346  (
347  mesh().lookupObject<solvers::multiphaseEuler>(solver::typeName).p_rgh
348  ),
349  Prt_(NaN),
350  Sct_(NaN),
351  saturationModelPtr_(nullptr),
352  pressureEquationIndex_(-1),
353  specieSemiImplicit_(false),
354  mDot_
355  (
356  IOobject
357  (
358  name + ":mDot",
359  mesh.time().name(),
360  mesh,
361  IOobject::READ_IF_PRESENT,
362  IOobject::AUTO_WRITE
363  ),
364  mesh,
366  mDotBoundaryTypes
367  (
369  )
370  ),
371  mDotDy_
372  (
373  IOobject
374  (
375  name + ":mDotDy",
376  mesh.time().name(),
377  mesh,
378  IOobject::READ_IF_PRESENT,
379  IOobject::AUTO_WRITE
380  ),
381  mesh,
383  )
384 {
385  readCoeffs(coeffs(dict));
386 }
387 
388 
389 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
390 
392 (
393  const label patchi
394 ) const
395 {
396  return mDotPfRef(patchi).condensing_;
397 }
398 
399 
401 (
402  const label patchi
403 ) const
404 {
405  return
407  (
408  mDotPfRef(patchi).alphatVapour_,
409  mDotPfRef(patchi).alphatLiquid_
410  );
411 }
412 
413 
416 {
417  // Put all the latent heat into the vapour
418  return
420  (
421  name() + ":Lfraction",
422  mesh(),
423  dimensionedScalar(dimless, scalar(0))
424  );
425 }
426 
427 
430 {
431  return mDot_.internalField();
432 }
433 
434 
437 {
438  return mDotDy_.internalField();
439 }
440 
441 
444 {
445  if (!isPatchActive(patchi))
446  {
448  << "Patch " << mesh().boundary()[patchi].name()
449  << " is not a condensation phase change wall" << exit(FatalError);
450  }
451 
452  return
453  refCast<const wallCondensationPhaseChangeRateFvPatchScalarField>
454  (
455  mDot_.boundaryField()[patchi]
456  );
457 }
458 
459 
462 {
463  if (!isPatchActive(patchi))
464  {
466  << "Patch " << mesh().boundary()[patchi].name()
467  << " is not a condensation phase change wall" << exit(FatalError);
468  }
469 
470  return
471  refCast<wallCondensationPhaseChangeRateFvPatchScalarField>
472  (
473  mDot_.boundaryFieldRef()[patchi]
474  );
475 }
476 
477 
479 (
480  const volScalarField& alpha,
481  const volScalarField& rho,
482  fvMatrix<scalar>& eqn
483 ) const
484 {
485  // Pressure equation (i.e., continuity, linearised in the pressure)
486  if
487  (
488  (&alpha == &liquid_ || &alpha == &vapour_)
489  && (&rho == &liquid_.rho() || &rho == &vapour_.rho())
490  && &eqn.psi() == &p_rgh_
491  )
492  {
493  // Ensure that the source is up-to date if this is the first call in
494  // the current phase loop
495  if (pressureEquationIndex_ % 2 == 0) correctMDot();
496  pressureEquationIndex_ ++;
497  }
498 
499  // Let the base class add the actual source
501 }
502 
503 
505 (
506  const volScalarField& alpha,
507  const volScalarField& rho,
508  const volScalarField& heOrYi,
509  fvMatrix<scalar>& eqn
510 ) const
511 {
512  const label i = this->index(phaseNames(), alpha.group());
513 
514  if (!specieSemiImplicit_ || i != 1)
515  {
516  return phaseChange::addSup(alpha, rho, heOrYi, eqn);
517  }
518 
519  const label s = this->sign(phaseNames(), alpha.group());
520 
522  fluidMulticomponentThermos(true, false)[0];
523 
524  const word specieName = heOrYi.member();
525 
526  // Mass fraction equation
527  if (thermo.containsSpecie(specieName))
528  {
529  // A non-transferring specie. Do not add a source.
530  if (!species().found(specieName)) return;
531 
532  // The transferring specie. Add a linearised source.
533  tmp<volScalarField::Internal> tmDot = this->mDot();
534  tmp<volScalarField::Internal> tmDotDy = this->mDotDy();
535 
536  eqn += s*(tmDot() + correction(fvm::Sp(tmDotDy, eqn.psi())));
537 
538  return;
539  }
540 
541  // Something else. Fall back.
542  phaseChange::addSup(alpha, rho, heOrYi, eqn);
543 }
544 
545 
547 {
548  // Reset the p_rgh equation solution counter
549  pressureEquationIndex_ = 0;
550 
551  // Correct the total phase change rate
552  correctMDot();
553 }
554 
555 
557 {
558  if (phaseChange::read(dict))
559  {
560  readCoeffs(coeffs(dict));
561  return true;
562  }
563  else
564  {
565  return false;
566  }
567 }
568 
569 
570 // ************************************************************************* //
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
bool found
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word member(const word &name)
Return member (name without the extension)
Definition: IOobject.C:146
An ordered pair of two objects of type <Type> with first() and second() elements.
Definition: Pair.H:67
This boundary condition provides a thermal wall function for turbulent thermal diffusivity (usuallyal...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base-class for multi-component fluid thermodynamic properties.
Abstract base class for fluid thermophysical transport models RAS, LES and laminar.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:932
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: massTransfer.C:223
void reReadSpecie(const dictionary &dict) const
Re-read the names of the transferring specie.
Definition: phaseChange.C:107
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: phaseChange.C:602
void addSup(const volScalarField &alpha, const volScalarField &rho, const volScalarField &heOrYi, fvMatrix< scalar > &eqn) const
Override the energy equation to add the phase change heat, or.
Definition: phaseChange.C:529
Model for mass diffusion limited wall condensation between two phases on the surface of a number of w...
wallCondensation(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
const wallCondensationPhaseChangeRateFvPatchScalarField & mDotPf(const label patchi) const
Return the mass transfer rate for the given patch.
virtual tmp< DimensionedField< scalar, fvMesh > > Lfraction() const
Return the fraction of the latent heat that is transferred into.
virtual void correct()
Correct the fvModel.
virtual tmp< DimensionedField< scalar, fvMesh > > mDotDy() const
Return the derivative of mass transfer rate.
virtual tmp< DimensionedField< scalar, fvMesh > > mDot() const
Return the mass transfer rate.
virtual const scalarField & active(const label) const
Return a mask indicating whether phase change is occurring.
virtual bool read(const dictionary &dict)
Read source dictionary.
void addSup(const volScalarField &alpha, const volScalarField &rho, const volScalarField &heOrYi, fvMatrix< scalar > &eqn) const
Use phaseChange's source functions.
Definition: phaseChange.C:529
wallCondensationPhaseChangeRateFvPatchScalarField & mDotPfRef(const label patchi) const
Return the mass transfer rate for the given patch.
Base class for fvModels that represent phase change at a wall.
const Pair< const volScalarField & > & alphats() const
Access the turbulent thermal diffusivities.
static autoPtr< saturationPressureModel > New(const word &name, const dictionary &dict)
Select with name within a dictionary.
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
A class for managing temporary objects.
Definition: tmp.H:55
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
This boundary condition is used for the phase change rate field of the wall condensation fvModel....
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionSet time
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
dimensionedScalar pos(const dimensionedScalar &ds)
const dimensionSet & dimless
Definition: dimensions.C:138
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:272
dimensionedScalar sign(const dimensionedScalar &ds)
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:265
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar log(const dimensionedScalar &ds)
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
const dimensionSet & dimTime
Definition: dimensions.C:142
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimDensity
Definition: dimensions.C:158
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
UList< label > labelUList
Definition: UList.H:65
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
faceListList boundary(nPatches)
labelList fv(nPoints)
dictionary dict
PtrList< volScalarField > & Y
fluidMulticomponentThermo & thermo
Definition: createFields.H:15
const scalarField pSat
Saturation pressure.
compressible::alphatJayatillekeWallFunctionFvPatchScalarField alphatJayatillekeWallFunction
Typedef to shorten the name of the Jayatilleke wall function.
const scalarField & CpVapour
Vapour heat capacity.
const scalarField alphatConvVapour
Phase convective turbulent thermal diffusivity.
const wallCondensation & model
Wall function field.
const scalarField TcVapour
Cell temperature.
const scalarField alphatConvLiquid
Liquid convective turbulent thermal diffusivity.
const fluidThermophysicalTransportModel & ttmVapour
Vapour thermophysical transport model.
const fluidThermophysicalTransportModel & ttmLiquid
Liquid thermophysical transport model.
const scalarField TwVapour
Patch temperature.
const scalarField & alphaVapour
Vapour volume fraction.
const scalarField & alphaLiquid
Liquid volume fraction.
properties(const wallCondensation &model, const label patchi)
Constructor.
const fvPatch & patch() const
Patch.
const scalarField AbyV
Patch area by neighbouring cell volume ratio.
const scalarField L
Latent heat.