27 #include "heatTransferModel.H" 35 template<
class BasePhaseSystem>
38 PtrList<volScalarField>& dmdts
43 const phaseInterface interface(*
this, dmdtfIter.key());
45 addField(interface.phase1(),
"dmdt", *dmdtfIter(), dmdts);
46 addField(interface.phase2(),
"dmdt", - *dmdtfIter(), dmdts);
51 const phaseInterface interface(*
this, nDmdtfIter.key());
53 addField(interface.phase1(),
"dmdt", *nDmdtfIter(), dmdts);
54 addField(interface.phase2(),
"dmdt", - *nDmdtfIter(), dmdts);
61 template<
class BasePhaseSystem>
68 BasePhaseSystem(mesh),
69 volatile_(this->template lookupOrDefault<word>(
"volatile",
"none")),
70 dmdt0s_(this->
phases().size()),
73 this->template lookupOrDefault<Switch>(
"pressureImplicit", true)
76 this->generateInterfacialModels(saturationModels_);
86 const phaseInterface&
interface = saturationModelIter()->interface();
87 const phaseModel& phase1 = interface.phase1();
88 const phaseModel& phase2 = interface.phase2();
90 this->
template validateMassTransfer<saturationModel>(interface);
94 !this->heatTransferModels_.found(interface)
95 || !this->heatTransferModels_[interface]->haveModelInThe(phase1)
96 || !this->heatTransferModels_[interface]->haveModelInThe(phase2)
100 <<
"A heat transfer model for both sides of the " 101 << interface.name() <<
" interface is not specified. This is " 102 <<
"required by the corresponding saturation model" 110 saturationModelTable,
115 const phaseInterface&
interface = saturationModelIter()->interface();
126 "thermalPhaseChange:dmdtf",
129 this->
mesh().time().timeName(),
148 "thermalPhaseChange:d2mdtdpf",
151 this->
mesh().time().timeName(),
170 "thermalPhaseChange:Tf",
173 this->
mesh().time().timeName(),
179 interface.phase1().thermo().T()
180 + interface.phase2().thermo().T()
194 "thermalPhaseChange:nucleation:dmdtf",
197 this->
mesh().time().timeName(),
212 template<
class BasePhaseSystem>
220 template<
class BasePhaseSystem>
224 const phaseInterfaceKey& key
227 return saturationModels_[key];
231 template<
class BasePhaseSystem>
235 const phaseInterfaceKey& key
238 tmp<volScalarField> tDmdtf = BasePhaseSystem::dmdtf(key);
240 if (dmdtfs_.
found(key))
242 tDmdtf.ref() += *dmdtfs_[key];
245 if (nDmdtfs_.found(key))
247 tDmdtf.ref() += *nDmdtfs_[key];
254 template<
class BasePhaseSystem>
258 PtrList<volScalarField>
dmdts(BasePhaseSystem::dmdts());
266 template<
class BasePhaseSystem>
274 const phaseInterface interface(*
this, d2mdtdpfIter.key());
276 addField(interface.phase1(),
"d2mdtdp", *d2mdtdpfIter(),
d2mdtdps);
277 addField(interface.phase2(),
"d2mdtdp", - *d2mdtdpfIter(),
d2mdtdps);
284 template<
class BasePhaseSystem>
289 autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
294 this->addDmdtUfs(dmdtfs_, eqns);
295 this->addDmdtUfs(nDmdtfs_, eqns);
301 template<
class BasePhaseSystem>
306 autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
307 BasePhaseSystem::momentumTransferf();
311 this->addDmdtUfs(dmdtfs_, eqns);
312 this->addDmdtUfs(nDmdtfs_, eqns);
318 template<
class BasePhaseSystem>
322 autoPtr<phaseSystem::heatTransferTable> eqnsPtr =
323 BasePhaseSystem::heatTransfer();
331 const phaseInterface interface(*
this, nDmdtfIter.key());
332 const saturationModel& satModel = this->saturation(nDmdtfIter.key());
337 satModel.Tsat(interface.phase1().thermo().p()).ptr()
342 if (volatile_ !=
"none")
349 const phaseInterface interface(*
this, dmdtfIter.key());
351 dmidtfs.insert(interface,
new HashPtrTable<volScalarField>());
352 dmidtfs[interface]->insert
363 latentHeatScheme::upwind,
364 latentHeatTransfer::heat,
373 const phaseInterface interface(*
this, nDmdtfIter.key());
375 nDmidtfs.insert(interface,
new HashPtrTable<volScalarField>());
376 nDmidtfs[interface]->insert
388 latentHeatScheme::upwind,
399 latentHeatScheme::upwind,
400 latentHeatTransfer::heat,
408 latentHeatScheme::upwind,
415 PtrList<volScalarField>
dmdts(this->
phases().size());
421 const phaseModel& phase = phaseIter();
423 if (dmdt0s_.set(phase.index()))
425 *eqns[phase.name()] +=
428 dmdt0s_[phase.index()] - dmdts[phase.index()],
439 template<
class BasePhaseSystem>
443 autoPtr<phaseSystem::specieTransferTable> eqnsPtr =
448 if (volatile_ !=
"none")
455 const phaseInterface interface(*
this, dmdtfIter.key());
457 dmidtfs.insert(interface,
new HashPtrTable<volScalarField>());
458 dmidtfs[interface]->insert
465 this->addDmidtYf(dmidtfs, eqns);
473 const phaseInterface interface(*
this, nDmdtfIter.key());
475 nDmidtfs.insert(interface,
new HashPtrTable<volScalarField>());
476 nDmidtfs[interface]->insert
483 this->addDmidtYf(nDmidtfs, eqns);
488 this->addDmdtYfs(dmdtfs_, eqns);
489 this->addDmdtYfs(nDmdtfs_, eqns);
496 template<
class BasePhaseSystem>
500 dmdt0s_ = PtrList<volScalarField>(this->
phases().size());
504 BasePhaseSystem::correctContinuityError();
508 template<
class BasePhaseSystem>
512 typedef compressible::alphatPhaseChangeWallFunctionFvPatchScalarField
513 alphatPhaseChangeWallFunction;
517 saturationModelTable,
522 const phaseInterface&
interface = saturationModelIter()->interface();
523 const phaseModel& phase1 = interface.phase1();
524 const phaseModel& phase2 = interface.phase2();
525 const rhoThermo& thermo1 = phase1.thermo();
526 const rhoThermo& thermo2 = phase2.thermo();
530 const sidedBlendedHeatTransferModel& heatTransferModel =
531 this->heatTransferModels_[interface];
538 const volScalarField Tsat(saturationModelIter()->Tsat(thermo1.p()));
549 latentHeatScheme::upwind
556 latentHeatScheme::upwind
565 if (volatile_ !=
"none")
568 neg0(dmdtfNew)*phase1.Y(volatile_)
569 +
pos(dmdtfNew)*phase2.Y(volatile_);
572 if (pressureImplicit_)
581 saturationModelIter()->Tsat(thermo1.p() + dp/2)
582 - saturationModelIter()->Tsat(thermo1.p() - dp/2)
586 d2mdtdpf = (H1 + H2)*dTsatdp/L;
588 if (volatile_ !=
"none")
591 neg0(dmdtfNew)*phase1.Y(volatile_)
592 +
pos(dmdtfNew)*phase2.Y(volatile_);
596 H1 = heatTransferModel.modelInThe(phase1).K();
597 H2 = heatTransferModel.modelInThe(phase2).K();
603 Tf = (H1*T1 + H2*T2 + dmdtfNew*L)/(H1 + H2);
606 <<
": min = " <<
min(Tf.primitiveField())
607 <<
", mean = " <<
average(Tf.primitiveField())
608 <<
", max = " <<
max(Tf.primitiveField())
611 const scalar dmdtfRelax =
612 this->
mesh().solution().fieldRelaxationFactor(
dmdtf.member());
614 dmdtf = (1 - dmdtfRelax)*
dmdtf + dmdtfRelax*dmdtfNew;
617 <<
": min = " <<
min(
dmdtf.primitiveField())
619 <<
", max = " <<
max(
dmdtf.primitiveField())
630 bool wallBoilingActive =
false;
634 const phaseModel& phase = interfaceIter();
636 const word alphatName =
647 alphat.boundaryField()[
patchi];
649 if (isA<alphatPhaseChangeWallFunction>(alphatp))
651 const alphatPhaseChangeWallFunction& alphatw =
652 refCast<const alphatPhaseChangeWallFunction>
657 if (alphatw.activeInterface(interface))
659 wallBoilingActive =
true;
662 alphatw.dmdtf(interface);
665 interfaceIter.index() == 0 ? +1 : -1;
670 alphatw.patch().faceCells()[facei];
671 nDmdtf[celli] -= sign*patchDmdtf[facei];
679 if (wallBoilingActive)
682 <<
": min = " <<
min(nDmdtf.primitiveField())
683 <<
", mean = " <<
average(nDmdtf.primitiveField())
684 <<
", max = " <<
max(nDmdtf.primitiveField())
693 template<
class BasePhaseSystem>
dimensionedScalar sign(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual PtrList< volScalarField > dmdts() const
Return the mass transfer rates for each phase.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
ThermalPhaseChangePhaseSystem(const fvMesh &)
Construct from fvMesh.
HashPtrTable< fvVectorMatrix > momentumTransferTable
const dimensionSet dimPressure
virtual autoPtr< phaseSystem::specieTransferTable > specieTransfer() const
Return the specie transfer matrices.
Ostream & endl(Ostream &os)
Add newline and flush stream.
HashPtrTable< HashPtrTable< volScalarField >, phaseInterfaceKey, phaseInterfaceKey::hash > dmidtfTable
virtual PtrList< volScalarField > dmdts() const
Return the mass transfer rates for each phase.
HashPtrTable< fvScalarMatrix > heatTransferTable
dimensioned< Type > domainIntegrate(const GeometricField< Type, fvPatchField, volMesh > &vf)
HashPtrTable< fvScalarMatrix > specieTransferTable
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
Class to provide interfacial heat and mass transfer between a number of phases according the interfac...
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedScalar pos(const dimensionedScalar &ds)
const dimensionSet dimTime
virtual PtrList< volScalarField > d2mdtdps() const
Return the mass transfer linearisation coeffs for each phase.
virtual void correctInterfaceThermo()
Correct the interface thermodynamics.
bool found(const Key &) const
Return true if hashedEntry is found in table.
fvPatchField< scalar > fvPatchScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static word groupName(Name name, const word &group)
const dimensionSet dimDensity
dimensionedScalar neg0(const dimensionedScalar &ds)
PtrListDictionary< phaseModel > phaseModelList
virtual autoPtr< phaseSystem::heatTransferTable > heatTransfer() const
Return the heat transfer matrices.
virtual autoPtr< phaseSystem::momentumTransferTable > momentumTransferf()
Return the momentum transfer matrices for the face-based algorithm.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Volume integrate volField creating a volField.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
phaseSystem::specieTransferTable & specieTransfer(specieTransferPtr())
const Mesh & mesh() const
Return mesh.
virtual bool read()
Read base phaseProperties dictionary.
HashPtrTable< volScalarField, phaseInterfaceKey, phaseInterfaceKey::hash > dmdtfTable
Model to describe the dependence of saturation pressure on temperature, and vice versa.
phaseSystem::momentumTransferTable & momentumTransfer(momentumTransferPtr())
virtual ~ThermalPhaseChangePhaseSystem()
Destructor.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
virtual void correctContinuityError()
Store phase dmdts at the during the continuity error update.
phaseSystem::phaseModelList & phases
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
virtual tmp< volScalarField > dmdtf(const phaseInterfaceKey &key) const
Return the mass transfer rate for an interface.
A class for managing temporary objects.
virtual tmp< volScalarField > dmdtf(const phaseInterfaceKey &key) const
Return the mass transfer rate for an interface.
virtual autoPtr< phaseSystem::momentumTransferTable > momentumTransfer()
Return the momentum transfer matrices for the cell-based algorithm.
Calculate the matrix for implicit and explicit sources.
PtrList< volScalarField > d2mdtdps(fluid.d2mdtdps())
const saturationModel & saturation(const phaseInterfaceKey &key) const
Return the saturationModel.