28 #include "heatTransferModel.H" 34 template<
class BasePhaseSystem>
39 autoPtr<phaseSystem::dmdtfTable> dmdtPtr(
new phaseSystem::dmdtfTable);
40 phaseSystem::dmdtfTable& dmdtfs = dmdtPtr();
44 interfaceCompositionModelTable,
45 interfaceCompositionModels_,
46 interfaceCompositionModelIter
49 const phasePair& pair =
50 this->phasePairs_[interfaceCompositionModelIter.key()];
54 const autoPtr<interfaceCompositionModel>& compositionModelPtr =
55 interfaceCompositionModelIter()[pairIter.index()];
57 if (!compositionModelPtr.valid())
continue;
59 const interfaceCompositionModel& compositionModel =
60 compositionModelPtr();
62 const phaseModel& phase = *pairIter;
67 compositionModel.species(),
71 const word& specie = *specieIter;
73 tmp<volScalarField> dmidtf
75 (pairIter.index() == 0 ? +1 : -1)
77 *(*dmidtfSus_[pair])[specie]
78 + *(*dmidtfSps_[pair])[specie]*phase.Y(specie)
82 if (dmdtfs.found(pair))
84 *dmdtfs[pair] += dmidtf;
88 dmdtfs.insert(pair, dmidtf.ptr());
98 template<
class BasePhaseSystem>
103 autoPtr<phaseSystem::dmidtfTable> dmidtfsPtr(
new phaseSystem::dmidtfTable);
104 phaseSystem::dmidtfTable& dmidtfs = dmidtfsPtr();
108 interfaceCompositionModelTable,
109 interfaceCompositionModels_,
110 interfaceCompositionModelIter
113 const phasePair& pair =
114 this->phasePairs_[interfaceCompositionModelIter.key()];
116 if (!dmidtfs.found(pair))
118 dmidtfs.insert(pair,
new HashPtrTable<volScalarField>());
123 const autoPtr<interfaceCompositionModel>& compositionModelPtr =
124 interfaceCompositionModelIter()[pairIter.index()];
126 if (!compositionModelPtr.valid())
continue;
128 const interfaceCompositionModel& compositionModel =
129 compositionModelPtr();
131 const phaseModel& phase = *pairIter;
136 compositionModel.species(),
140 const word& specie = *specieIter;
143 tmp<volScalarField> dmidtf
145 (pairIter.index() == 0 ? +1 : -1)
147 *(*dmidtfSus_[pair])[specie]
148 + *(*dmidtfSps_[pair])[specie]*phase.Y(specie)
152 if (dmidtfs[pair]->
found(specie))
154 *(*dmidtfs[pair])[specie] += dmidtf;
158 dmidtfs[pair]->insert(specie, dmidtf.ptr());
170 template<
class BasePhaseSystem>
177 BasePhaseSystem(mesh),
178 nInterfaceCorrectors_
180 this->template lookupOrDefault<
label>(
"nInterfaceCorrectors", 1)
185 "interfaceComposition",
186 interfaceCompositionModels_
191 "diffusiveMassTransfer",
192 diffusiveMassTransferModels_,
199 interfaceCompositionModelTable,
200 interfaceCompositionModels_,
201 interfaceCompositionModelIter
204 const phasePair& pair =
205 this->
phasePairs_[interfaceCompositionModelIter.key()];
207 if (!this->diffusiveMassTransferModels_.found(pair))
210 <<
"A diffusive mass transfer model the " << pair
211 <<
" pair is not specified. This is required by the " 212 <<
"corresponding interface composition model." 220 interfaceCompositionModelIter()[pairIter.index()].valid()
221 && !diffusiveMassTransferModels_[pair][pairIter.index()].valid()
225 <<
"A mass transfer model for the " << (*pairIter).name()
226 <<
" side of the " << pair <<
" pair is not " 227 <<
"specified. This is required by the corresponding " 228 <<
"interface composition model." 235 !this->heatTransferModels_.found(pair)
236 || !this->heatTransferModels_[pair].first().valid()
237 || !this->heatTransferModels_[pair].second().valid()
241 <<
"A heat transfer model for both sides of the " << pair
242 <<
"pair is not specified. This is required by the " 243 <<
"corresponding interface composition model" 251 interfaceCompositionModelTable,
252 interfaceCompositionModels_,
253 interfaceCompositionModelIter
256 const phasePair& pair =
257 this->
phasePairs_[interfaceCompositionModelIter.key()];
259 dmidtfSus_.
insert(pair,
new HashPtrTable<volScalarField>());
260 dmidtfSps_.insert(pair,
new HashPtrTable<volScalarField>());
264 const autoPtr<interfaceCompositionModel>& compositionModelPtr =
265 interfaceCompositionModelIter()[pairIter.index()];
267 if (!compositionModelPtr.valid())
continue;
269 const interfaceCompositionModel& compositionModel =
270 compositionModelPtr();
275 compositionModel.species(),
279 const word& specie = *specieIter;
281 dmidtfSus_[pair]->insert
292 "interfaceCompositionPhaseChange:dmidtfSu",
305 dmidtfSps_[pair]->insert
316 "interfaceCompositionPhaseChange:dmidtfSp",
336 template<
class BasePhaseSystem>
344 template<
class BasePhaseSystem>
348 const phasePairKey& key
351 tmp<volScalarField> tDmdtf = BasePhaseSystem::dmdtf(key);
353 if (interfaceCompositionModels_.found(key))
359 const autoPtr<interfaceCompositionModel>& compositionModelPtr =
360 interfaceCompositionModels_[key][pairIter.index()];
362 if (!compositionModelPtr.valid())
continue;
364 const interfaceCompositionModel& compositionModel =
365 compositionModelPtr();
367 const phaseModel& phase = *pairIter;
372 compositionModel.species(),
376 const word& specie = *specieIter;
381 *(*dmidtfSus_[pair])[specie]
382 - *(*dmidtfSps_[pair])[specie]*phase.Y(specie)
392 template<
class BasePhaseSystem>
396 PtrList<volScalarField>
dmdts(BasePhaseSystem::dmdts());
398 autoPtr<phaseSystem::dmdtfTable> dmdtfsPtr = this->dmdtfs();
403 const phasePair& pair = this->
phasePairs_[dmdtfsIter.key()];
404 const phaseModel& phase = pair.phase1();
405 const phaseModel& otherPhase = pair.phase2();
407 addField(phase,
"dmdt", *dmdtfsIter(),
dmdts);
408 addField(otherPhase,
"dmdt", - *dmdtfsIter(),
dmdts);
415 template<
class BasePhaseSystem>
420 autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
425 this->addDmdtUfs(dmdtfs(), eqns);
431 template<
class BasePhaseSystem>
436 autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
437 BasePhaseSystem::momentumTransferf();
441 this->addDmdtUfs(dmdtfs(), eqns);
447 template<
class BasePhaseSystem>
452 autoPtr<phaseSystem::heatTransferTable> eqnsPtr =
453 BasePhaseSystem::heatTransfer();
457 this->addDmidtHef(dmidtfs(), eqns);
463 template<
class BasePhaseSystem>
468 autoPtr<phaseSystem::specieTransferTable> eqnsPtr =
481 interfaceCompositionModelTable,
482 interfaceCompositionModels_,
483 interfaceCompositionModelIter
486 const phasePair& pair =
487 this->
phasePairs_[interfaceCompositionModelIter.key()];
491 const autoPtr<interfaceCompositionModel>& compositionModelPtr =
492 interfaceCompositionModelIter()[pairIter.index()];
494 if (!compositionModelPtr.valid())
continue;
496 const interfaceCompositionModel& compositionModel =
497 compositionModelPtr();
499 const phaseModel& phase = *pairIter;
500 const phaseModel& otherPhase = pairIter.otherPhase();
505 compositionModel.species(),
509 const word& specie = *specieIter;
512 *eqns[phase.Y(specie).name()] +=
513 *(*dmidtfSus_[pair])[specie]
514 +
fvm::Sp(*(*dmidtfSps_[pair])[specie], phase.Y(specie));
519 *eqns[otherPhase.Y(specie).name()] -=
520 *(*dmidtfSus_[pair])[specie]
521 + *(*dmidtfSps_[pair])[specie]*phase.Y(specie);
531 template<
class BasePhaseSystem>
540 interfaceCompositionModelTable,
541 interfaceCompositionModels_,
542 interfaceCompositionModelIter
545 const phasePair& pair =
546 this->
phasePairs_[interfaceCompositionModelIter.key()];
552 const autoPtr<interfaceCompositionModel>& compositionModelPtr =
553 interfaceCompositionModelIter()[pairIter.index()];
555 if (!compositionModelPtr.valid())
continue;
557 const interfaceCompositionModel& compositionModel =
558 compositionModelPtr();
560 const phaseModel& phase = *pairIter;
564 diffusiveMassTransferModels_[pair][pairIter.index()]->K()
570 compositionModel.species(),
574 const word& specie = *specieIter;
579 *(*dmidtfSus_[pair])[specie] = phase.rho()*KD*Yf;
580 *(*dmidtfSps_[pair])[specie] = - phase.rho()*KD;
587 template<
class BasePhaseSystem>
615 interfaceCompositionModelTable,
616 interfaceCompositionModels_,
617 interfaceCompositionModelIter
620 const phasePair& pair =
621 this->
phasePairs_[interfaceCompositionModelIter.key()];
624 const volScalarField H2(this->heatTransferModels_[pair].second()->
K());
629 for (
label i = 0; i < nInterfaceCorrectors_; ++ i)
631 tmp<volScalarField> dmdtLf =
638 tmp<volScalarField> dmdtLfPrime =
647 if (this->interfaceCompositionModels_[pair].
first().valid())
649 this->interfaceCompositionModels_[pair].first()->addDmdtL
651 diffusiveMassTransferModels_[pair].
first()->
K(),
657 if (this->interfaceCompositionModels_[pair].second().valid())
659 this->interfaceCompositionModels_[pair].second()->addDmdtL
661 - diffusiveMassTransferModels_[pair].second()->
K(),
672 H1*(Tf - pair.phase1().thermo().T())
673 + H2*(Tf - pair.phase2().thermo().T())
677 max(H1 + H2 - dmdtLfPrime, HSmall)
680 Tf.correctBoundaryConditions();
682 Info<<
"Tf." << pair.name()
683 <<
": min = " <<
min(Tf.primitiveField())
684 <<
", mean = " <<
average(Tf.primitiveField())
685 <<
", max = " <<
max(Tf.primitiveField())
689 if (this->interfaceCompositionModels_[pair].
first().valid())
691 this->interfaceCompositionModels_[pair].first()->update(Tf);
693 if (this->interfaceCompositionModels_[pair].second().valid())
695 this->interfaceCompositionModels_[pair].second()->update(Tf);
702 template<
class BasePhaseSystem>
virtual autoPtr< phaseSystem::specieTransferTable > specieTransfer() const
Return the specie transfer matrices.
virtual ~InterfaceCompositionPhaseChangePhaseSystem()
Destructor.
virtual PtrList< volScalarField > dmdts() const
Return the mass transfer rates for each phase.
intWM_LABEL_SIZE_t 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)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
HashPtrTable< fvVectorMatrix > momentumTransferTable
InterfaceCompositionPhaseChangePhaseSystem(const fvMesh &)
Construct from fvMesh.
phasePairTable phasePairs_
Phase pairs.
static int compare(const Pair< Type > &a, const Pair< Type > &b)
Compare Pairs.
IOobject(const word &name, const fileName &instance, const objectRegistry ®istry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true)
Construct from name, instance, registry, io options.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Internal &, const PtrList< fvPatchField< scalar >> &)
Return a temporary field constructed from name,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< volScalarField > K(const phaseModel &alpha1, const phaseModel &alpha2) const
Curvature of interface between two phases.
HashPtrTable< fvScalarMatrix > heatTransferTable
HashPtrTable< fvScalarMatrix > specieTransferTable
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
const Time & time() const
Return the top-level database.
CGAL::Exact_predicates_exact_constructions_kernel K
virtual void correctInterfaceThermo()
Correct the interface temperatures.
virtual tmp< volScalarField > dmdtf(const phasePairKey &key) const
Return the mass transfer rate for an interface.
static const dimensionSet dimK
Coefficient dimensions.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
const dimensionSet dimVolume(pow3(dimLength))
static word groupName(Name name, const word &group)
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
HashPtrTable< volScalarField, phasePairKey, phasePairKey::hash > dmdtfTable
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
virtual PtrList< volScalarField > dmdts() const
Return the mass transfer rates for each phase.
virtual void correct()
Correct the fluid properties other than those listed below.
phaseSystem::specieTransferTable & specieTransfer(specieTransferPtr())
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(rho0+psi *p, rhoMin);# 1 "/home/ubuntu/OpenFOAM-8/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
virtual autoPtr< phaseSystem::momentumTransferTable > momentumTransfer()
Return the momentum transfer matrices for the cell-based algorithm.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const dimensionSet dimEnergy
phaseSystem::momentumTransferTable & momentumTransfer(momentumTransferPtr())
const dimensionSet dimDensity
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...
void generatePairsAndSubModels(const word &modelName, HashTable< autoPtr< modelType >, phasePairKey, phasePairKey::hash > &models, const bool correctFixedFluxBCs=true)
Generate pairs and sub-model tables.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A class for managing temporary objects.
T * first()
Return the first entry.
virtual autoPtr< phaseSystem::momentumTransferTable > momentumTransferf()
Return the momentum transfer matrices for the face-based algorithm.
const fvMesh & mesh() const
Return the mesh.
virtual autoPtr< phaseSystem::heatTransferTable > heatTransfer() const
Return the heat transfer matrices.
virtual bool read()
Read base phaseProperties dictionary.
Calculate the matrix for implicit and explicit sources.
Class to provide interfacial heat and mass transfer between a number of phases according to a interfa...