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
880 lines
20 KiB
C++
880 lines
20 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 "phaseSystem.H"
|
|
#include "interfaceSurfaceTensionModel.H"
|
|
#include "surfaceInterpolate.H"
|
|
#include "fvcDdt.H"
|
|
#include "localEulerDdtScheme.H"
|
|
#include "fvcDiv.H"
|
|
#include "fvcGrad.H"
|
|
#include "fvcSnGrad.H"
|
|
#include "fvCorrectPhi.H"
|
|
#include "fvcMeshPhi.H"
|
|
#include "correctContactAngle.H"
|
|
#include "dragModel.H"
|
|
#include "movingWallVelocityFvPatchVectorField.H"
|
|
#include "pressureReference.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
defineTypeNameAndDebug(phaseSystem, 0);
|
|
defineRunTimeSelectionTable(phaseSystem, dictionary);
|
|
}
|
|
|
|
const Foam::word Foam::phaseSystem::propertiesName("phaseProperties");
|
|
|
|
|
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
|
|
|
Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::calcPhi
|
|
(
|
|
const phaseModelList& phaseModels
|
|
) const
|
|
{
|
|
tmp<surfaceScalarField> tmpPhi
|
|
(
|
|
surfaceScalarField::New
|
|
(
|
|
"phi",
|
|
fvc::interpolate(phaseModels[0])*phaseModels[0].phi()
|
|
)
|
|
);
|
|
|
|
for (label phasei=1; phasei<phaseModels.size(); phasei++)
|
|
{
|
|
tmpPhi.ref() +=
|
|
fvc::interpolate(phaseModels[phasei])*phaseModels[phasei].phi();
|
|
}
|
|
|
|
return tmpPhi;
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volScalarField> Foam::phaseSystem::sumAlphaMoving() const
|
|
{
|
|
tmp<volScalarField> sumAlphaMoving
|
|
(
|
|
volScalarField::New
|
|
(
|
|
"sumAlphaMoving",
|
|
movingPhaseModels_[0],
|
|
calculatedFvPatchScalarField::typeName
|
|
)
|
|
);
|
|
|
|
for
|
|
(
|
|
label movingPhasei=1;
|
|
movingPhasei<movingPhaseModels_.size();
|
|
movingPhasei++
|
|
)
|
|
{
|
|
sumAlphaMoving.ref() += movingPhaseModels_[movingPhasei];
|
|
}
|
|
|
|
return sumAlphaMoving;
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::setMixtureU(const volVectorField& Um0)
|
|
{
|
|
// Calculate the mean velocity difference with respect to Um0
|
|
// from the current velocity of the moving phases
|
|
volVectorField dUm(Um0);
|
|
|
|
forAll(movingPhaseModels_, movingPhasei)
|
|
{
|
|
dUm -=
|
|
movingPhaseModels_[movingPhasei]
|
|
*movingPhaseModels_[movingPhasei].U();
|
|
}
|
|
|
|
forAll(movingPhaseModels_, movingPhasei)
|
|
{
|
|
movingPhaseModels_[movingPhasei].URef() += dUm;
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::setMixturePhi
|
|
(
|
|
const PtrList<surfaceScalarField>& alphafs,
|
|
const surfaceScalarField& phim0
|
|
)
|
|
{
|
|
// Calculate the mean flux difference with respect to phim0
|
|
// from the current flux of the moving phases
|
|
surfaceScalarField dphim(phim0);
|
|
|
|
forAll(movingPhaseModels_, movingPhasei)
|
|
{
|
|
dphim -=
|
|
alphafs[movingPhaseModels_[movingPhasei].index()]
|
|
*movingPhaseModels_[movingPhasei].phi();
|
|
}
|
|
|
|
forAll(movingPhaseModels_, movingPhasei)
|
|
{
|
|
movingPhaseModels_[movingPhasei].phiRef() += dphim;
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::surfaceVectorField> Foam::phaseSystem::nHatfv
|
|
(
|
|
const volScalarField& alpha1,
|
|
const volScalarField& alpha2
|
|
) const
|
|
{
|
|
/*
|
|
// Cell gradient of alpha
|
|
volVectorField gradAlpha =
|
|
alpha2*fvc::grad(alpha1) - alpha1*fvc::grad(alpha2);
|
|
|
|
// Interpolated face-gradient of alpha
|
|
surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
|
|
*/
|
|
|
|
surfaceVectorField gradAlphaf
|
|
(
|
|
fvc::interpolate(alpha2)*fvc::interpolate(fvc::grad(alpha1))
|
|
- fvc::interpolate(alpha1)*fvc::interpolate(fvc::grad(alpha2))
|
|
);
|
|
|
|
// Face unit interface normal
|
|
return gradAlphaf/(mag(gradAlphaf) + deltaN_);
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::nHatf
|
|
(
|
|
const volScalarField& alpha1,
|
|
const volScalarField& alpha2
|
|
) const
|
|
{
|
|
// Face unit interface normal flux
|
|
return nHatfv(alpha1, alpha2) & mesh_.Sf();
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volScalarField> Foam::phaseSystem::K
|
|
(
|
|
const phaseModel& phase1,
|
|
const phaseModel& phase2
|
|
) const
|
|
{
|
|
tmp<surfaceVectorField> tnHatfv = nHatfv(phase1, phase2);
|
|
|
|
correctContactAngle
|
|
(
|
|
phase1,
|
|
phase2,
|
|
phase1.U()().boundaryField(),
|
|
deltaN_,
|
|
tnHatfv.ref().boundaryFieldRef()
|
|
);
|
|
|
|
// Simple expression for curvature
|
|
return -fvc::div(tnHatfv & mesh_.Sf());
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::phaseSystem::phaseSystem
|
|
(
|
|
const fvMesh& mesh
|
|
)
|
|
:
|
|
IOdictionary
|
|
(
|
|
IOobject
|
|
(
|
|
propertiesName,
|
|
mesh.time().constant(),
|
|
mesh,
|
|
IOobject::MUST_READ_IF_MODIFIED,
|
|
IOobject::NO_WRITE
|
|
)
|
|
),
|
|
|
|
mesh_(mesh),
|
|
|
|
pimple_(mesh_.lookupObject<pimpleNoLoopControl>("solutionControl")),
|
|
|
|
MRF_(mesh_),
|
|
|
|
referencePhaseName_(lookupOrDefault("referencePhase", word::null)),
|
|
|
|
phaseModels_
|
|
(
|
|
lookup("phases"),
|
|
phaseModel::iNew(*this, referencePhaseName_)
|
|
),
|
|
|
|
phi_("phi", calcPhi(phaseModels_)),
|
|
|
|
dpdt_
|
|
(
|
|
IOobject
|
|
(
|
|
"dpdt",
|
|
mesh.time().name(),
|
|
mesh
|
|
),
|
|
mesh,
|
|
dimensionedScalar(dimPressure/dimTime, 0)
|
|
),
|
|
|
|
deltaN_
|
|
(
|
|
"deltaN",
|
|
1e-8/pow(average(mesh_.V()), 1.0/3.0)
|
|
)
|
|
{
|
|
// Groupings
|
|
label movingPhasei = 0;
|
|
label stationaryPhasei = 0;
|
|
label anisothermalPhasei = 0;
|
|
label multicomponentPhasei = 0;
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModel& phase = phaseModels_[phasei];
|
|
movingPhasei += !phase.stationary();
|
|
stationaryPhasei += phase.stationary();
|
|
anisothermalPhasei += !phase.isothermal();
|
|
multicomponentPhasei += !phase.pure();
|
|
}
|
|
movingPhaseModels_.resize(movingPhasei);
|
|
stationaryPhaseModels_.resize(stationaryPhasei);
|
|
anisothermalPhaseModels_.resize(anisothermalPhasei);
|
|
multicomponentPhaseModels_.resize(multicomponentPhasei);
|
|
|
|
movingPhasei = 0;
|
|
stationaryPhasei = 0;
|
|
anisothermalPhasei = 0;
|
|
multicomponentPhasei = 0;
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModel& phase = phaseModels_[phasei];
|
|
if (!phase.stationary())
|
|
{
|
|
movingPhaseModels_.set(movingPhasei++, &phase);
|
|
}
|
|
if (phase.stationary())
|
|
{
|
|
stationaryPhaseModels_.set(stationaryPhasei++, &phase);
|
|
}
|
|
if (!phase.isothermal())
|
|
{
|
|
anisothermalPhaseModels_.set(anisothermalPhasei++, &phase);
|
|
}
|
|
if (!phase.pure())
|
|
{
|
|
multicomponentPhaseModels_.set(multicomponentPhasei++, &phase);
|
|
}
|
|
}
|
|
|
|
// Write phi
|
|
phi_.writeOpt() = IOobject::AUTO_WRITE;
|
|
|
|
// Interface compression coefficients
|
|
if (this->found("interfaceCompression"))
|
|
{
|
|
generateInterfacialValues("interfaceCompression", cAlphas_);
|
|
}
|
|
|
|
// Surface tension models
|
|
generateInterfacialModels(interfaceSurfaceTensionModels_);
|
|
|
|
// Update motion fields
|
|
correctKinematics();
|
|
|
|
// Set the optional reference phase fraction from the other phases
|
|
if (referencePhaseName_ != word::null)
|
|
{
|
|
phaseModel* referencePhasePtr = &phases()[referencePhaseName_];
|
|
volScalarField& referenceAlpha = *referencePhasePtr;
|
|
|
|
referenceAlpha = 1;
|
|
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
if (&phaseModels_[phasei] != referencePhasePtr)
|
|
{
|
|
referenceAlpha -= phaseModels_[phasei];
|
|
}
|
|
}
|
|
}
|
|
|
|
forAll(phases(), phasei)
|
|
{
|
|
const volScalarField& alphai = phases()[phasei];
|
|
mesh_.schemes().setFluxRequired(alphai.name());
|
|
}
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
Foam::phaseSystem::~phaseSystem()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
|
|
|
Foam::tmp<Foam::volScalarField> Foam::phaseSystem::rho() const
|
|
{
|
|
tmp<volScalarField> rho(movingPhaseModels_[0]*movingPhaseModels_[0].rho());
|
|
|
|
for
|
|
(
|
|
label movingPhasei=1;
|
|
movingPhasei<movingPhaseModels_.size();
|
|
movingPhasei++
|
|
)
|
|
{
|
|
rho.ref() +=
|
|
movingPhaseModels_[movingPhasei]
|
|
*movingPhaseModels_[movingPhasei].rho();
|
|
}
|
|
|
|
if (stationaryPhaseModels_.empty())
|
|
{
|
|
return rho;
|
|
}
|
|
else
|
|
{
|
|
return rho/sumAlphaMoving();
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volVectorField> Foam::phaseSystem::U() const
|
|
{
|
|
tmp<volVectorField> U(movingPhaseModels_[0]*movingPhaseModels_[0].U());
|
|
|
|
for
|
|
(
|
|
label movingPhasei=1;
|
|
movingPhasei<movingPhaseModels_.size();
|
|
movingPhasei++
|
|
)
|
|
{
|
|
U.ref() +=
|
|
movingPhaseModels_[movingPhasei]
|
|
*movingPhaseModels_[movingPhasei].U();
|
|
}
|
|
|
|
if (stationaryPhaseModels_.empty())
|
|
{
|
|
return U;
|
|
}
|
|
else
|
|
{
|
|
return U/sumAlphaMoving();
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volScalarField>
|
|
Foam::phaseSystem::sigma(const phaseInterfaceKey& key) const
|
|
{
|
|
if (interfaceSurfaceTensionModels_.found(key))
|
|
{
|
|
return interfaceSurfaceTensionModels_[key]->sigma();
|
|
}
|
|
else
|
|
{
|
|
return volScalarField::New
|
|
(
|
|
interfaceSurfaceTensionModel::typeName + ":sigma",
|
|
mesh_,
|
|
dimensionedScalar(interfaceSurfaceTensionModel::dimSigma, 0)
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::scalarField>
|
|
Foam::phaseSystem::sigma(const phaseInterfaceKey& key, const label patchi) const
|
|
{
|
|
if (interfaceSurfaceTensionModels_.found(key))
|
|
{
|
|
return interfaceSurfaceTensionModels_[key]->sigma(patchi);
|
|
}
|
|
else
|
|
{
|
|
return tmp<scalarField>
|
|
(
|
|
new scalarField(mesh_.boundary()[patchi].size(), 0)
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volScalarField>
|
|
Foam::phaseSystem::nearInterface() const
|
|
{
|
|
tmp<volScalarField> tnearInt
|
|
(
|
|
volScalarField::New
|
|
(
|
|
"nearInterface",
|
|
mesh_,
|
|
dimensionedScalar(dimless, 0)
|
|
)
|
|
);
|
|
|
|
forAll(phases(), phasei)
|
|
{
|
|
tnearInt.ref() = max
|
|
(
|
|
tnearInt(),
|
|
pos0(phases()[phasei] - 0.01)*pos0(0.99 - phases()[phasei])
|
|
);
|
|
}
|
|
|
|
return tnearInt;
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volScalarField> Foam::phaseSystem::dmdtf
|
|
(
|
|
const phaseInterfaceKey& key
|
|
) const
|
|
{
|
|
return volScalarField::New
|
|
(
|
|
IOobject::groupName("dmdtf", phaseInterface(*this, key).name()),
|
|
mesh(),
|
|
dimensionedScalar(dimDensity/dimTime, 0)
|
|
);
|
|
}
|
|
|
|
|
|
Foam::PtrList<Foam::volScalarField> Foam::phaseSystem::dmdts() const
|
|
{
|
|
return PtrList<volScalarField>(phaseModels_.size());
|
|
}
|
|
|
|
|
|
Foam::PtrList<Foam::volScalarField> Foam::phaseSystem::d2mdtdps() const
|
|
{
|
|
return PtrList<volScalarField>(phaseModels_.size());
|
|
}
|
|
|
|
|
|
bool Foam::phaseSystem::incompressible() const
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
if (!phaseModels_[phasei].incompressible())
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
bool Foam::phaseSystem::implicitPhasePressure(const phaseModel& phase) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
bool Foam::phaseSystem::implicitPhasePressure() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::surfaceScalarField> Foam::phaseSystem::surfaceTension
|
|
(
|
|
const phaseModel& phase1
|
|
) const
|
|
{
|
|
tmp<surfaceScalarField> tSurfaceTension
|
|
(
|
|
surfaceScalarField::New
|
|
(
|
|
"surfaceTension",
|
|
mesh_,
|
|
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), 0)
|
|
)
|
|
);
|
|
|
|
forAll(phases(), phasej)
|
|
{
|
|
const phaseModel& phase2 = phases()[phasej];
|
|
|
|
if (&phase2 != &phase1)
|
|
{
|
|
const phaseInterface interface(phase1, phase2);
|
|
|
|
if (cAlphas_.found(interface))
|
|
{
|
|
tSurfaceTension.ref() +=
|
|
fvc::interpolate(sigma(interface)*K(phase1, phase2))
|
|
*(
|
|
fvc::interpolate(phase2)*fvc::snGrad(phase1)
|
|
- fvc::interpolate(phase1)*fvc::snGrad(phase2)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
return tSurfaceTension;
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correct()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correct();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctContinuityError()
|
|
{
|
|
const PtrList<volScalarField> dmdts = this->dmdts();
|
|
|
|
forAll(movingPhaseModels_, movingPhasei)
|
|
{
|
|
phaseModel& phase = movingPhaseModels_[movingPhasei];
|
|
const volScalarField& alpha = phase;
|
|
volScalarField& rho = phase.rho();
|
|
|
|
volScalarField source
|
|
(
|
|
volScalarField::New
|
|
(
|
|
IOobject::groupName("source", phase.name()),
|
|
mesh_,
|
|
dimensionedScalar(dimDensity/dimTime, 0)
|
|
)
|
|
);
|
|
|
|
if (fvModels().addsSupToField(rho.name()))
|
|
{
|
|
source += fvModels().source(alpha, rho)ρ
|
|
}
|
|
|
|
if (dmdts.set(phase.index()))
|
|
{
|
|
source += dmdts[phase.index()];
|
|
}
|
|
|
|
phase.correctContinuityError(source);
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctKinematics()
|
|
{
|
|
bool updateDpdt = false;
|
|
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correctKinematics();
|
|
|
|
updateDpdt = updateDpdt || phaseModels_[phasei].thermo().dpdt();
|
|
}
|
|
|
|
// Update the pressure time-derivative if required
|
|
if (updateDpdt)
|
|
{
|
|
dpdt_ = fvc::ddt(phaseModels_.begin()().thermo().p());
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctThermo()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correctThermo();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctReactions()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correctReactions();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctSpecies()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correctSpecies();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::predictMomentumTransport()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].predictMomentumTransport();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::predictThermophysicalTransport()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].predictThermophysicalTransport();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctMomentumTransport()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correctMomentumTransport();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctThermophysicalTransport()
|
|
{
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
phaseModels_[phasei].correctThermophysicalTransport();
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::meshUpdate()
|
|
{
|
|
if (mesh_.changing())
|
|
{
|
|
MRF_.update();
|
|
|
|
// forAll(phaseModels_, phasei)
|
|
// {
|
|
// phaseModels_[phasei].meshUpdate();
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctBoundaryFlux()
|
|
{
|
|
forAll(movingPhases(), movingPhasei)
|
|
{
|
|
phaseModel& phase = movingPhases()[movingPhasei];
|
|
|
|
tmp<volVectorField> tU(phase.U());
|
|
const volVectorField::Boundary& UBf = tU().boundaryField();
|
|
|
|
FieldField<fvsPatchField, scalar> phiRelBf
|
|
(
|
|
MRF_.relative(mesh_.Sf().boundaryField() & UBf)
|
|
);
|
|
|
|
surfaceScalarField::Boundary& phiBf = phase.phiRef().boundaryFieldRef();
|
|
|
|
forAll(mesh_.boundary(), patchi)
|
|
{
|
|
if
|
|
(
|
|
isA<fixedValueFvsPatchScalarField>(phiBf[patchi])
|
|
&& !isA<movingWallVelocityFvPatchVectorField>(UBf[patchi])
|
|
)
|
|
{
|
|
phiBf[patchi] == phiRelBf[patchi];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::phaseSystem::correctPhi
|
|
(
|
|
const volScalarField& p_rgh,
|
|
const autoPtr<volScalarField>& divU,
|
|
const pressureReference& pressureReference,
|
|
nonOrthogonalSolutionControl& pimple
|
|
)
|
|
{
|
|
forAll(movingPhases(), movingPhasei)
|
|
{
|
|
phaseModel& phase = movingPhases()[movingPhasei];
|
|
|
|
volVectorField::Boundary& Ubf = phase.URef().boundaryFieldRef();
|
|
surfaceVectorField::Boundary& UfBf = phase.UfRef().boundaryFieldRef();
|
|
|
|
forAll(Ubf, patchi)
|
|
{
|
|
if (Ubf[patchi].fixesValue())
|
|
{
|
|
Ubf[patchi].initEvaluate();
|
|
}
|
|
}
|
|
|
|
forAll(Ubf, patchi)
|
|
{
|
|
if (Ubf[patchi].fixesValue())
|
|
{
|
|
Ubf[patchi].evaluate();
|
|
UfBf[patchi] = Ubf[patchi];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Correct fixed-flux BCs to be consistent with the velocity BCs
|
|
correctBoundaryFlux();
|
|
|
|
phi_ = Zero;
|
|
PtrList<surfaceScalarField> alphafs(phaseModels_.size());
|
|
forAll(movingPhases(), movingPhasei)
|
|
{
|
|
phaseModel& phase = movingPhases()[movingPhasei];
|
|
const label phasei = phase.index();
|
|
const volScalarField& alpha = phase;
|
|
|
|
alphafs.set(phasei, fvc::interpolate(alpha).ptr());
|
|
|
|
// Calculate absolute flux
|
|
// from the mapped surface velocity
|
|
phi_ += alphafs[phasei]*(mesh_.Sf() & phase.UfRef());
|
|
}
|
|
|
|
if (incompressible())
|
|
{
|
|
fv::correctPhi
|
|
(
|
|
phi_,
|
|
movingPhases()[0].U(),
|
|
p_rgh,
|
|
autoPtr<volScalarField>(),
|
|
divU,
|
|
pressureReference,
|
|
pimple
|
|
);
|
|
}
|
|
else
|
|
{
|
|
volScalarField psi
|
|
(
|
|
volScalarField::New
|
|
(
|
|
"psi",
|
|
mesh_,
|
|
dimensionedScalar(dimless/dimPressure, 0)
|
|
)
|
|
);
|
|
|
|
forAll(phases(), phasei)
|
|
{
|
|
phaseModel& phase = phases()[phasei];
|
|
const volScalarField& alpha = phase;
|
|
|
|
psi += alpha*phase.thermo().psi()/phase.rho();
|
|
}
|
|
|
|
fv::correctPhi
|
|
(
|
|
phi_,
|
|
p_rgh,
|
|
psi,
|
|
autoPtr<volScalarField>(),
|
|
divU(),
|
|
pimple
|
|
);
|
|
}
|
|
|
|
// Make the flux relative to the mesh motion
|
|
fvc::makeRelative(phi_, movingPhases()[0].U());
|
|
|
|
setMixturePhi(alphafs, phi_);
|
|
}
|
|
|
|
|
|
bool Foam::phaseSystem::read()
|
|
{
|
|
if (regIOobject::read())
|
|
{
|
|
bool readOK = true;
|
|
|
|
forAll(phaseModels_, phasei)
|
|
{
|
|
readOK &= phaseModels_[phasei].read();
|
|
}
|
|
|
|
// models ...
|
|
|
|
return readOK;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::volScalarField> Foam::byDt(const volScalarField& vf)
|
|
{
|
|
if (fv::localEulerDdt::enabled(vf.mesh()))
|
|
{
|
|
return fv::localEulerDdt::localRDeltaT(vf.mesh())*vf;
|
|
}
|
|
else
|
|
{
|
|
return vf/vf.mesh().time().deltaT();
|
|
}
|
|
}
|
|
|
|
|
|
Foam::tmp<Foam::surfaceScalarField> Foam::byDt(const surfaceScalarField& sf)
|
|
{
|
|
if (fv::localEulerDdt::enabled(sf.mesh()))
|
|
{
|
|
return fv::localEulerDdt::localRDeltaTf(sf.mesh())*sf;
|
|
}
|
|
else
|
|
{
|
|
return sf/sf.mesh().time().deltaT();
|
|
}
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|