Files
OpenFOAM-12/applications/modules/multiphaseEuler/phaseSystems/PhaseSystems/InterfaceCompositionPhaseChangePhaseSystem/InterfaceCompositionPhaseChangePhaseSystem.C
Henry Weller e744fdb5f1 Modular solvers: Reorganised directory structure of applications and tutorials
The new flexible and extensible modular solvers structure already provides most
of the simulation functionality needed for single phase, multiphase,
multicomponent etc. fluid flow problems as well as a very effective method of
combining these with solid heat transfer, solid stress, surface film to solve
complex multi-region, multi-physics problems and are now the primary mechanism
for the further development of OpenFOAM simulation capability in future.  To
emphasis this for both users and developers the applications/solvers directory
has been separated into applications/modules containing all the solver modules:

├── modules
│   ├── compressibleMultiphaseVoF
│   ├── compressibleVoF
│   ├── film
│   ├── fluid
│   ├── fluidSolver
│   ├── functions
│   ├── incompressibleDenseParticleFluid
│   ├── incompressibleDriftFlux
│   ├── incompressibleFluid
│   ├── incompressibleMultiphaseVoF
│   ├── incompressibleVoF
│   ├── isothermalFilm
│   ├── isothermalFluid
│   ├── movingMesh
│   ├── multicomponentFluid
│   ├── multiphaseEuler
│   ├── multiphaseVoFSolver
│   ├── shockFluid
│   ├── solid
│   ├── solidDisplacement
│   ├── twoPhaseSolver
│   ├── twoPhaseVoFSolver
│   ├── VoFSolver
│   └── XiFluid

applications/solvers containing the foamRun and foamMultiRun solver applications
which instantiate and execute the chosen solver modules and also standalone
solver applications for special initialisation and test activities:

├── solvers
│   ├── boundaryFoam
│   ├── chemFoam
│   ├── foamMultiRun
│   ├── foamRun
│   └── potentialFoam

and applications/legacy containing legacy solver applications which are not
currently being actively developed but the functionality of which will be merged
into the solver modules or form the basis of new solver modules as the need
arises:

├── legacy
│   ├── basic
│   │   ├── financialFoam
│   │   └── laplacianFoam
│   ├── combustion
│   │   └── PDRFoam
│   ├── compressible
│   │   └── rhoPorousSimpleFoam
│   ├── electromagnetics
│   │   ├── electrostaticFoam
│   │   ├── magneticFoam
│   │   └── mhdFoam
│   ├── incompressible
│   │   ├── adjointShapeOptimisationFoam
│   │   ├── dnsFoam
│   │   ├── icoFoam
│   │   ├── porousSimpleFoam
│   │   └── shallowWaterFoam
│   └── lagrangian
│       ├── dsmcFoam
│       ├── mdEquilibrationFoam
│       └── mdFoam

Correspondingly the tutorials directory structure has been reorganised with the
modular solver directories at the top level with names that make it easier for
users to find example cases relating to their particular requirements and a
legacy sub-directory containing cases corresponding to the legacy solver
applications listed above:

├── compressibleMultiphaseVoF
│   └── damBreak4phaseLaminar
├── compressibleVoF
│   ├── ballValve
│   ├── climbingRod
│   ├── damBreak
│   ├── depthCharge2D
│   ├── depthCharge3D
│   ├── sloshingTank2D
│   └── throttle
├── film
│   └── rivuletPanel
├── fluid
│   ├── aerofoilNACA0012
│   ├── aerofoilNACA0012Steady
│   ├── angledDuct
│   ├── angledDuctExplicitFixedCoeff
│   ├── angledDuctLTS
│   ├── annularThermalMixer
│   ├── BernardCells
│   ├── blockedChannel
│   ├── buoyantCavity
│   ├── cavity
│   ├── decompressionTank
│   ├── externalCoupledCavity
│   ├── forwardStep
│   ├── helmholtzResonance
│   ├── hotRadiationRoom
│   ├── hotRadiationRoomFvDOM
│   ├── hotRoom
│   ├── hotRoomBoussinesq
│   ├── hotRoomBoussinesqSteady
│   ├── hotRoomComfort
│   ├── iglooWithFridges
│   ├── mixerVessel2DMRF
│   ├── nacaAirfoil
│   ├── pitzDaily
│   ├── prism
│   ├── shockTube
│   ├── squareBend
│   ├── squareBendLiq
│   └── squareBendLiqSteady
├── incompressibleDenseParticleFluid
│   ├── column
│   ├── cyclone
│   ├── Goldschmidt
│   ├── GoldschmidtMPPIC
│   └── injectionChannel
├── incompressibleDriftFlux
│   ├── dahl
│   ├── mixerVessel2DMRF
│   └── tank3D
├── incompressibleFluid
│   ├── airFoil2D
│   ├── ballValve
│   ├── blockedChannel
│   ├── cavity
│   ├── cavityCoupledU
│   ├── channel395
│   ├── drivaerFastback
│   ├── ductSecondaryFlow
│   ├── elipsekkLOmega
│   ├── flowWithOpenBoundary
│   ├── hopperParticles
│   ├── impeller
│   ├── mixerSRF
│   ├── mixerVessel2D
│   ├── mixerVessel2DMRF
│   ├── mixerVesselHorizontal2DParticles
│   ├── motorBike
│   ├── motorBikeSteady
│   ├── movingCone
│   ├── offsetCylinder
│   ├── oscillatingInlet
│   ├── pipeCyclic
│   ├── pitzDaily
│   ├── pitzDailyLES
│   ├── pitzDailyLESDevelopedInlet
│   ├── pitzDailyLTS
│   ├── pitzDailyPulse
│   ├── pitzDailyScalarTransport
│   ├── pitzDailySteady
│   ├── pitzDailySteadyExperimentalInlet
│   ├── pitzDailySteadyMappedToPart
│   ├── pitzDailySteadyMappedToRefined
│   ├── planarContraction
│   ├── planarCouette
│   ├── planarPoiseuille
│   ├── porousBlockage
│   ├── propeller
│   ├── roomResidenceTime
│   ├── rotor2DRotating
│   ├── rotor2DSRF
│   ├── rotorDisk
│   ├── T3A
│   ├── TJunction
│   ├── TJunctionFan
│   ├── turbineSiting
│   ├── waveSubSurface
│   ├── windAroundBuildings
│   └── wingMotion
├── incompressibleMultiphaseVoF
│   ├── damBreak4phase
│   ├── damBreak4phaseFineLaminar
│   ├── damBreak4phaseLaminar
│   └── mixerVessel2DMRF
├── incompressibleVoF
│   ├── angledDuct
│   ├── capillaryRise
│   ├── cavitatingBullet
│   ├── climbingRod
│   ├── containerDischarge2D
│   ├── damBreak
│   ├── damBreakLaminar
│   ├── damBreakPorousBaffle
│   ├── damBreakWithObstacle
│   ├── DTCHull
│   ├── DTCHullMoving
│   ├── DTCHullWave
│   ├── floatingObject
│   ├── floatingObjectWaves
│   ├── forcedUpstreamWave
│   ├── mixerVessel
│   ├── mixerVessel2DMRF
│   ├── mixerVesselHorizontal2D
│   ├── nozzleFlow2D
│   ├── planingHullW3
│   ├── propeller
│   ├── sloshingCylinder
│   ├── sloshingTank2D
│   ├── sloshingTank2D3DoF
│   ├── sloshingTank3D
│   ├── sloshingTank3D3DoF
│   ├── sloshingTank3D6DoF
│   ├── testTubeMixer
│   ├── waterChannel
│   ├── wave
│   ├── wave3D
│   └── weirOverflow
├── isothermalFilm
│   └── rivuletPanel
├── isothermalFluid
│   ├── potentialFreeSurfaceMovingOscillatingBox
│   └── potentialFreeSurfaceOscillatingBox
├── legacy
│   ├── basic
│   │   ├── financialFoam
│   │   │   └── europeanCall
│   │   └── laplacianFoam
│   │       └── flange
│   ├── combustion
│   │   └── PDRFoam
│   │       └── flamePropagationWithObstacles
│   ├── compressible
│   │   └── rhoPorousSimpleFoam
│   │       ├── angledDuctExplicit
│   │       └── angledDuctImplicit
│   ├── electromagnetics
│   │   ├── electrostaticFoam
│   │   │   └── chargedWire
│   │   └── mhdFoam
│   │       └── hartmann
│   ├── incompressible
│   │   ├── adjointShapeOptimisationFoam
│   │   │   └── pitzDaily
│   │   ├── dnsFoam
│   │   │   └── boxTurb16
│   │   ├── icoFoam
│   │   │   ├── cavity
│   │   │   └── elbow
│   │   ├── porousSimpleFoam
│   │   │   ├── angledDuctExplicit
│   │   │   └── angledDuctImplicit
│   │   └── shallowWaterFoam
│   │       └── squareBump
│   ├── lagrangian
│   │   ├── dsmcFoam
│   │   │   ├── freeSpacePeriodic
│   │   │   ├── freeSpaceStream
│   │   │   ├── supersonicCorner
│   │   │   └── wedge15Ma5
│   │   ├── mdEquilibrationFoam
│   │   │   ├── periodicCubeArgon
│   │   │   └── periodicCubeWater
│   │   └── mdFoam
│   │       └── nanoNozzle
├── mesh
│   ├── blockMesh
│   │   ├── pipe
│   │   ├── sphere
│   │   ├── sphere7
│   │   └── sphere7ProjectedEdges
│   ├── refineMesh
│   │   └── refineFieldDirs
│   └── snappyHexMesh
│       ├── flange
│       └── pipe
├── movingMesh
│   └── SnakeRiverCanyon
├── multicomponentFluid
│   ├── aachenBomb
│   ├── counterFlowFlame2D
│   ├── counterFlowFlame2D_GRI
│   ├── counterFlowFlame2D_GRI_TDAC
│   ├── counterFlowFlame2DLTS
│   ├── counterFlowFlame2DLTS_GRI_TDAC
│   ├── DLR_A_LTS
│   ├── filter
│   ├── lockExchange
│   ├── membrane
│   ├── nc7h16
│   ├── parcelInBox
│   ├── SandiaD_LTS
│   ├── simplifiedSiwek
│   ├── smallPoolFire2D
│   ├── smallPoolFire3D
│   ├── verticalChannel
│   ├── verticalChannelLTS
│   └── verticalChannelSteady
├── multiphaseEuler
│   ├── bed
│   ├── bubbleColumn
│   ├── bubbleColumnEvaporating
│   ├── bubbleColumnEvaporatingDissolving
│   ├── bubbleColumnEvaporatingReacting
│   ├── bubbleColumnIATE
│   ├── bubbleColumnLaminar
│   ├── bubbleColumnLES
│   ├── bubblePipe
│   ├── damBreak4phase
│   ├── fluidisedBed
│   ├── fluidisedBedLaminar
│   ├── Grossetete
│   ├── hydrofoil
│   ├── injection
│   ├── LBend
│   ├── mixerVessel2D
│   ├── mixerVessel2DMRF
│   ├── pipeBend
│   ├── steamInjection
│   ├── titaniaSynthesis
│   ├── titaniaSynthesisSurface
│   ├── wallBoilingIATE
│   ├── wallBoilingPolydisperse
│   └── wallBoilingPolydisperseTwoGroups
├── multiRegion
│   ├── CHT
│   │   ├── circuitBoardCooling
│   │   ├── coolingCylinder2D
│   │   ├── coolingSphere
│   │   ├── heatedDuct
│   │   ├── heatExchanger
│   │   ├── multiphaseCoolingCylinder2D
│   │   ├── reverseBurner
│   │   ├── shellAndTubeHeatExchanger
│   │   ├── VoFcoolingCylinder2D
│   │   └── wallBoiling
│   └── film
│       ├── cylinder
│       ├── cylinderDripping
│       ├── cylinderVoF
│       ├── hotBoxes
│       ├── rivuletBox
│       ├── rivuletPanel
│       ├── splashPanel
│       └── VoFToFilm
├── potentialFoam
│   ├── cylinder
│   └── pitzDaily
├── resources
│   ├── blockMesh
│   ├── geometry
│   └── thermoData
├── shockFluid
│   ├── biconic25-55Run35
│   ├── forwardStep
│   ├── LadenburgJet60psi
│   ├── movingCone
│   ├── obliqueShock
│   ├── shockTube
│   └── wedge15Ma5
├── solidDisplacement
│   ├── beamEndLoad
│   └── plateHole
└── XiFluid
    ├── kivaTest
    └── moriyoshiHomogeneous
2023-05-25 18:14:41 +01:00

767 lines
24 KiB
C++

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "InterfaceCompositionPhaseChangePhaseSystem.H"
#include "interfaceCompositionModel.H"
#include "heatTransferModel.H"
#include "diffusiveMassTransferModel.H"
#include "fvmSup.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class BasePhaseSystem>
void Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
correctDmdtfs()
{
forAllConstIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
const sidedInterfaceCompositionModel& compositionModel =
interfaceCompositionModelIter();
const phaseInterface& interface = compositionModel.interface();
*dmdtfs_[interface] = Zero;
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
if (!compositionModel.haveModelInThe(phase)) continue;
forAllConstIter
(
hashedWordList,
compositionModel.modelInThe(phase).species(),
specieIter
)
{
const word& specie = *specieIter;
*dmdtfs_[interface] +=
(interfaceIter.index() == 0 ? +1 : -1)
*(
*(*dmidtfSus_[interface])[specie]
+ *(*dmidtfSps_[interface])[specie]*phase.Y(specie)
);
}
}
}
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::dmidtfTable>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
totalDmidtfs() const
{
autoPtr<phaseSystem::dmidtfTable> totalDmidtfsPtr
(
new phaseSystem::dmidtfTable
);
phaseSystem::dmidtfTable& totalDmidtfs = totalDmidtfsPtr();
forAllConstIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
const sidedInterfaceCompositionModel& compositionModel =
interfaceCompositionModelIter();
const phaseInterface& interface = compositionModel.interface();
if (!totalDmidtfs.found(interface))
{
totalDmidtfs.insert(interface, new HashPtrTable<volScalarField>());
}
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
if (!compositionModel.haveModelInThe(phase)) continue;
forAllConstIter
(
hashedWordList,
compositionModel.modelInThe(phase).species(),
specieIter
)
{
const word& specie = *specieIter;
tmp<volScalarField> dmidtf
(
(interfaceIter.index() == 0 ? +1 : -1)
*(
*(*dmidtfSus_[interface])[specie]
+ *(*dmidtfSps_[interface])[specie]*phase.Y(specie)
)
);
if (totalDmidtfs[interface]->found(specie))
{
*(*totalDmidtfs[interface])[specie] += dmidtf;
}
else
{
totalDmidtfs[interface]->insert(specie, dmidtf.ptr());
}
}
}
}
return totalDmidtfsPtr;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasePhaseSystem>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
InterfaceCompositionPhaseChangePhaseSystem
(
const fvMesh& mesh
)
:
BasePhaseSystem(mesh),
nInterfaceCorrectors_
(
this->template lookupOrDefault<label>("nInterfaceCorrectors", 1)
)
{
this->generateInterfacialModels(interfaceCompositionModels_);
this->generateInterfacialModels(diffusiveMassTransferModels_);
// Check that models have been specified in the correct combinations
forAllConstIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
const sidedInterfaceCompositionModel& sidedCompositionModel =
interfaceCompositionModelIter();
const phaseInterface& interface = sidedCompositionModel.interface();
const phaseModel& phase1 = interface.phase1();
const phaseModel& phase2 = interface.phase2();
this->template
validateMassTransfer<interfaceCompositionModel>(interface);
if (!this->diffusiveMassTransferModels_.found(interface))
{
FatalErrorInFunction
<< "A diffusive mass transfer model for the " << interface
<< " interface is not specified. This is required by the "
<< "corresponding interface composition model."
<< exit(FatalError);
}
forAllConstIter(phaseInterface, interface, interfaceIter)
{
if
(
sidedCompositionModel.haveModelInThe(interfaceIter())
&& !diffusiveMassTransferModels_[interface]
->haveModelInThe(interfaceIter())
)
{
FatalErrorInFunction
<< "A diffusive mass transfer model for the "
<< interfaceIter().name() << " side of the "
<< interface.name() << " interface is not "
<< "specified. This is required by the corresponding "
<< "interface composition model."
<< exit(FatalError);
}
}
if
(
!this->heatTransferModels_.found(interface)
|| !this->heatTransferModels_[interface]->haveModelInThe(phase1)
|| !this->heatTransferModels_[interface]->haveModelInThe(phase2)
)
{
FatalErrorInFunction
<< "A heat transfer model for both sides of the "
<< interface.name()
<< " interface is not specified. This is required by the "
<< "corresponding interface composition model"
<< exit(FatalError);
}
}
// Generate mass transfer fields, initially assumed to be zero
forAllConstIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
const sidedInterfaceCompositionModel& sidedCompositionModel =
interfaceCompositionModelIter();
const phaseInterface& interface = sidedCompositionModel.interface();
dmdtfs_.insert
(
interface,
new volScalarField
(
IOobject
(
IOobject::groupName
(
"interfaceCompositionPhaseChange:dmdtf",
interface.name()
),
this->mesh().time().name(),
this->mesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
this->mesh(),
dimensionedScalar(dimDensity/dimTime, Zero)
)
);
dmidtfSus_.insert(interface, new HashPtrTable<volScalarField>());
dmidtfSps_.insert(interface, new HashPtrTable<volScalarField>());
Tfs_.insert
(
interface,
new volScalarField
(
IOobject
(
IOobject::groupName
(
"interfaceCompositionPhaseChange:Tf",
interface.name()
),
this->mesh().time().name(),
this->mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
(
interface.phase1().thermo().T()
+ interface.phase2().thermo().T()
)/2
)
);
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
if (!sidedCompositionModel.haveModelInThe(phase)) continue;
const interfaceCompositionModel& compositionModel =
sidedCompositionModel.modelInThe(phase);
forAllConstIter
(
hashedWordList,
compositionModel.species(),
specieIter
)
{
const word& specie = *specieIter;
dmidtfSus_[interface]->insert
(
specie,
new volScalarField
(
IOobject
(
IOobject::groupName
(
IOobject::groupName
(
"interfaceCompositionPhaseChange:dmidtfSu",
specie
),
interface.name()
),
this->mesh().time().name(),
this->mesh()
),
this->mesh(),
dimensionedScalar(dimDensity/dimTime, 0)
)
);
dmidtfSps_[interface]->insert
(
specie,
new volScalarField
(
IOobject
(
IOobject::groupName
(
IOobject::groupName
(
"interfaceCompositionPhaseChange:dmidtfSp",
specie
),
interface.name()
),
this->mesh().time().name(),
this->mesh()
),
this->mesh(),
dimensionedScalar(dimDensity/dimTime, 0)
)
);
}
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class BasePhaseSystem>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
~InterfaceCompositionPhaseChangePhaseSystem()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class BasePhaseSystem>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::dmdtf
(
const phaseInterfaceKey& key
) const
{
tmp<volScalarField> tDmdtf = BasePhaseSystem::dmdtf(key);
if (dmdtfs_.found(key))
{
tDmdtf.ref() += *dmdtfs_[key];
}
return tDmdtf;
}
template<class BasePhaseSystem>
Foam::PtrList<Foam::volScalarField>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::dmdts() const
{
PtrList<volScalarField> dmdts(BasePhaseSystem::dmdts());
forAllConstIter(phaseSystem::dmdtfTable, dmdtfs_, dmdtfIter)
{
const phaseInterface interface(*this, dmdtfIter.key());
addField(interface.phase1(), "dmdt", *dmdtfIter(), dmdts);
addField(interface.phase2(), "dmdt", - *dmdtfIter(), dmdts);
}
return dmdts;
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::momentumTransferTable>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
momentumTransfer()
{
autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
BasePhaseSystem::momentumTransfer();
phaseSystem::momentumTransferTable& eqns = eqnsPtr();
this->addDmdtUfs(dmdtfs_, eqns);
return eqnsPtr;
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::momentumTransferTable>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
momentumTransferf()
{
autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
BasePhaseSystem::momentumTransferf();
phaseSystem::momentumTransferTable& eqns = eqnsPtr();
this->addDmdtUfs(dmdtfs_, eqns);
return eqnsPtr;
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::heatTransferTable>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
heatTransfer() const
{
autoPtr<phaseSystem::heatTransferTable> eqnsPtr =
BasePhaseSystem::heatTransfer();
phaseSystem::heatTransferTable& eqns = eqnsPtr();
this->addDmidtHefs
(
totalDmidtfs(),
Tfs_,
latentHeatScheme::symmetric,
latentHeatTransfer::mass,
eqns
);
return eqnsPtr;
}
template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::specieTransferTable>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
specieTransfer() const
{
autoPtr<phaseSystem::specieTransferTable> eqnsPtr =
BasePhaseSystem::specieTransfer();
phaseSystem::specieTransferTable& eqns = eqnsPtr();
// Explicit
/*
this->addDmidtYf(totalDmidtfs(), eqns);
*/
// Semi-implicit
forAllConstIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
const sidedInterfaceCompositionModel& compositionModel =
interfaceCompositionModelIter();
const phaseInterface& interface = compositionModel.interface();
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
const phaseModel& otherPhase = interfaceIter.otherPhase();
if (!compositionModel.haveModelInThe(phase)) continue;
forAllConstIter
(
hashedWordList,
compositionModel.modelInThe(phase).species(),
specieIter
)
{
const word& specie = *specieIter;
// Implicit transport through this phase
*eqns[phase.Y(specie).name()] +=
*(*dmidtfSus_[interface])[specie]
+ fvm::Sp(*(*dmidtfSps_[interface])[specie], phase.Y(specie));
// Explicit transport out of the other phase
if (eqns.found(IOobject::groupName(specie, otherPhase.name())))
{
*eqns[otherPhase.Y(specie).name()] -=
*(*dmidtfSus_[interface])[specie]
+ *(*dmidtfSps_[interface])[specie]*phase.Y(specie);
}
}
}
}
return eqnsPtr;
}
template<class BasePhaseSystem>
void Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
correct()
{
BasePhaseSystem::correct();
// Sum up the contribution from each interface composition model
forAllConstIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
const sidedInterfaceCompositionModel& compositionModel =
interfaceCompositionModelIter();
const phaseInterface& interface = compositionModel.interface();
const volScalarField& Tf(*this->Tfs_[interface]);
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
if (!compositionModel.haveModelInThe(phase)) continue;
const volScalarField K
(
diffusiveMassTransferModels_[interface]->modelInThe(phase).K()
);
forAllConstIter
(
hashedWordList,
compositionModel.modelInThe(phase).species(),
specieIter
)
{
const word& specie = *specieIter;
const volScalarField KD
(
K*compositionModel.modelInThe(phase).D(specie)
);
const volScalarField Yf
(
compositionModel.modelInThe(phase).Yf(specie, Tf)
);
*(*dmidtfSus_[interface])[specie] = phase.rho()*KD*Yf;
*(*dmidtfSps_[interface])[specie] = - phase.rho()*KD;
}
}
}
correctDmdtfs();
}
template<class BasePhaseSystem>
void Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
correctSpecies()
{
BasePhaseSystem::correctSpecies();
correctDmdtfs();
}
template<class BasePhaseSystem>
void Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::
correctInterfaceThermo()
{
// This loop solves for the interface temperatures, Tf, and updates the
// interface composition models.
//
// In the presence of thermally-coupled mass transfer, the relation between
// heat transfers across the interface between phases 1 and 2 is:
//
// Q1 + Q2 = mDot*L
// H1*(Tf - T1) + H2*(Tf - T1) = K*rho*(Yfi - Yi)*Li
//
// Where Q1 and Q2 are the net transfer into phases 1 and 2 respectively,
// H1 and H2 are the heat transfer coefficients on either side, Tf is the
// temperature at the interface, mDot is the mass transfer rate from phase
// 2 to phase 1, and L is the latent heat of phase 2 minus phase 1, K is
// the diffusive mass transfer coefficient, Yfi - Yi is the concentration
// difference of a transferring specie between the interface and the bulk
// driving the transfer, Li is the latent heat change of the specie, and
// rho is the density in the phase in which the diffusive mass transfer is
// being represented.
//
// Yfi is likely to be a strong non-linear (typically exponential) function
// of Tf, so the solution for the temperature is newton-accelerated.
forAllIter
(
interfaceCompositionModelTable,
interfaceCompositionModels_,
interfaceCompositionModelIter
)
{
sidedInterfaceCompositionModel& compositionModel =
*interfaceCompositionModelIter();
const phaseInterface& interface = compositionModel.interface();
const phaseModel& phase1 = interface.phase1();
const phaseModel& phase2 = interface.phase2();
const sidedBlendedHeatTransferModel& heatTransferModel =
this->heatTransferModels_[interface];
const sidedBlendedDiffusiveMassTransferModel&
diffusiveMassTransferModel =
diffusiveMassTransferModels_[interface];
const volScalarField H1(heatTransferModel.modelInThe(phase1).K());
const volScalarField H2(heatTransferModel.modelInThe(phase2).K());
const dimensionedScalar HSmall("small", heatTransferModel::dimK, small);
volScalarField& Tf = *this->Tfs_[interface];
for (label i = 0; i < nInterfaceCorrectors_; ++ i)
{
tmp<volScalarField> dmdtLf =
volScalarField::New
(
IOobject::groupName("dmdtLf", interface.name()),
this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, 0)
);
tmp<volScalarField> dmdtLfPrime =
volScalarField::New
(
IOobject::groupName("dmdtLfPrime", interface.name()),
this->mesh(),
dimensionedScalar(dmdtLf().dimensions()/dimTemperature, 0)
);
// Add latent heats from forward and backward models
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
if (!compositionModel.haveModelInThe(phase)) continue;
const label sign = interfaceIter.index() == 0 ? 1 : -1;
forAllConstIter
(
hashedWordList,
compositionModel.modelInThe(phase).species(),
specieIter
)
{
const word& specie = *specieIter;
const volScalarField dY
(
compositionModel.modelInThe(phase).dY(specie, Tf)
);
const volScalarField dYfPrime
(
compositionModel.modelInThe(phase).dYfPrime(specie, Tf)
);
const volScalarField rhoKDL
(
phase.rho()
*diffusiveMassTransferModel.modelInThe(phase).K()
*compositionModel.modelInThe(phase).D(specie)
*this->Li
(
interface,
specie,
dY,
Tf,
latentHeatScheme::symmetric
)
);
dmdtLf.ref() += sign*rhoKDL*dY;
dmdtLfPrime.ref() += sign*rhoKDL*dYfPrime;
}
}
// Update the interface temperature by applying one step of newton's
// method to the interface relation
Tf -=
(
H1*(Tf - interface.phase1().thermo().T())
+ H2*(Tf - interface.phase2().thermo().T())
- dmdtLf
)
/(
max(H1 + H2 - dmdtLfPrime, HSmall)
);
Tf.correctBoundaryConditions();
Info<< "Tf." << interface.name()
<< ": min = " << min(Tf.primitiveField())
<< ", mean = " << average(Tf.primitiveField())
<< ", max = " << max(Tf.primitiveField())
<< endl;
// Update the interface compositions
forAllConstIter(phaseInterface, interface, interfaceIter)
{
const phaseModel& phase = interfaceIter();
if (!compositionModel.haveModelInThe(phase)) continue;
compositionModel.modelInThe(phase).update(Tf);
}
}
}
}
template<class BasePhaseSystem>
bool Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::read()
{
if (BasePhaseSystem::read())
{
bool readOK = true;
// Models ...
return readOK;
}
else
{
return false;
}
}
// ************************************************************************* //