ENH: Final stage for laserDTRM model and new icoReactingMultiphaseFoam

This commit is contained in:
sergio
2017-08-10 09:17:55 -07:00
committed by Andrew Heather
parent 9887c8f504
commit d68adc4d31
96 changed files with 15574 additions and 0 deletions

View File

@ -0,0 +1,11 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
wclean libso phasesSystem
wclean libso meltingEvaporationModel
wclean libso CompressibleMultiPhaseTurbulenceModels
wclean libso laserDTRM
wclean
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
wmakeLnInclude meltingEvaporationModel
wmake libso phasesSystem
wmake libso meltingEvaporationModel
wmake libso CompressibleMultiPhaseTurbulenceModels
wmake libso laserDTRM
wmake
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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 "CompressibleTurbulenceModel.H"
#include "compressibleTurbulenceModel.H"
#include "multiphaseSystem.H"
#include "addToRunTimeSelectionTable.H"
#include "makeTurbulenceModel.H"
#include "ThermalDiffusivity.H"
#include "laminarModel.H"
#include "RASModel.H"
#include "LESModel.H"
makeBaseTurbulenceModel
(
geometricOneField,
volScalarField,
compressibleTurbulenceModel,
CompressibleTurbulenceModel,
ThermalDiffusivity,
multiphaseSystem
);
#define makeLaminarModel(Type) \
makeTemplatedLaminarModel \
(multiphaseSystemCompressibleTurbulenceModel, laminar, Type)
#define makeRASModel(Type) \
makeTemplatedTurbulenceModel \
(multiphaseSystemCompressibleTurbulenceModel, RAS, Type)
#define makeLESModel(Type) \
makeTemplatedTurbulenceModel \
(multiphaseSystemCompressibleTurbulenceModel, LES, Type)
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "kEpsilon.H"
makeRASModel(kEpsilon);
#include "Smagorinsky.H"
makeLESModel(Smagorinsky);
#include "kEqn.H"
makeLESModel(kEqn);
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
CompressibleMultiPhaseTurbulenceModels.C
LIB = $(FOAM_LIBBIN)/libCompressibleMultiPhaseTurbulenceModels

View File

@ -0,0 +1,11 @@
EXE_INC = \
-I../phasesSystem/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude

View File

@ -0,0 +1,3 @@
icoReactingMultiphaseInterFoam.C
EXE = $(FOAM_USER_APPBIN)/icoReactingMultiphaseInterFoam

View File

@ -0,0 +1,34 @@
EXE_INC = \
-I./phasesSystem/lnInclude \
-I./CompressibleMultiPhaseTurbulenceModels/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude\
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude
EXE_LIBS = \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lcompressibleTransportModels \
-lfiniteVolume \
-lmeshTools \
-lfvOptions \
-lsampling \
-lradiationModels \
-lfluidThermophysicalModels \
-lIncompressibleMultiphaseSystems \
-lCompressibleMultiPhaseTurbulenceModels \
-lmeltingEvaporationModels \
-lsolidThermo \
-lsolidSpecie \
-ltwoPhaseProperties

View File

@ -0,0 +1,102 @@
{
radiation->correct();
tmp<volScalarField> texpSource
(
new volScalarField
(
IOobject
(
"texpSource",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimTemperature/dimTime, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& expSource = texpSource.ref();
tmp<volScalarField> tkappaEff
(
new volScalarField
(
IOobject
(
"kappaEff",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", sqr(dimLength)/dimTime, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& kappaEff = tkappaEff.ref();
//const surfaceScalarField rhoTempPhi("phi", rhoPhi/fvc::interpolate(rho));
const surfaceScalarField rhoTempPhi("phi", fluid.phi());
const volScalarField divU(fvc::div(phi));
forAllIter(UPtrList<phaseModel>, fluid.phases(), iter)
{
phaseModel& phase = iter();
const volScalarField& alpha = phase;
const volScalarField DDtAlpha(fvc::DDt(phi, alpha));
const volScalarField invCpRho(1.0/phase.rho()/phase.Cp());
if (fluid.dpdt())
{
const volScalarField ddtp(fvc::ddt(p));
expSource += (DDtAlpha*p + alpha*(p*divU + ddtp))*invCpRho;
}
else
{
expSource += (DDtAlpha*p + alpha*(p*divU))*invCpRho;
}
kappaEff += alpha*phase.kappa()*invCpRho;
DebugVar(max(alpha*phase.kappa()));
DebugVar(max(alpha*phase.Cp()));
}
kappaEff += turbulence->nut()/fluid.Prt();
if (mesh.time().outputTime())
{
expSource.write();
kappaEff.write();
}
//dimensionedScalar S("S", dimEnergy/dimVolume/dimTime, 1.225e8);
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(rhoTempPhi, T)
- fvm::laplacian(kappaEff, T, "laplacian(kappa,T)")
==
fluid.heatTransfer(T)
+ expSource
+ radiation->ST(fluid.Cp()*rho, T)
// + S/Cp/rho
);
TEqn.relax();
TEqn.solve();
fluid.correct();
Info<< "min/max(T) = "
<< min(T).value() << ", " << max(T).value() << endl;
}

View File

@ -0,0 +1,34 @@
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(rhoPhi, U)
+ turbulence->divDevRhoReff(U)
==
fvOptions(rho, U)
);
UEqn.relax();
fluid.addInterfacePorosity(UEqn);
if (pimple.momentumPredictor())
{
solve
(
UEqn
==
fvc::reconstruct
(
(
fluid.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
- fvc::snGrad(p_rgh)
) * mesh.magSf()
)
);
fvOptions.correct(U);
K = 0.5*magSqr(U);
}

View File

@ -0,0 +1,76 @@
{
// Semi-implicit mass transfer for species
// Initilize dmdt for alpha Eq's for mass transfers driven by species
autoPtr<phaseSystem::massTransferTable>
massTransferPtr(fluid.massTransfer(T));
//phaseSystem::massTransferTable& massTransfer(massTransferPtr());
forAllIter(UPtrList<phaseModel>, fluid.phases(), iter)
{
phaseModel& phase = iter();
PtrList<volScalarField>& Y = phase.Y();
//const surfaceScalarField& alphaPhi = phase.alphaPhi();
if (!Y.empty())
{
const volScalarField& alpha = phase;
label inertIndex = -1;
volScalarField Yt(0.0*Y[0]);
forAll(Y, i)
{
tmp<fvScalarMatrix> YiEqn(phase.YiEqn(Y[i]));
if (YiEqn.valid())
{
YiEqn.ref() =
(
YiEqn()
- fvm::laplacian
(
alpha*turbulence->nuEff(),
Y[i]
)
==
// (*massTransfer[Y[i].name()])(/phase.rho()
fvc::ddt(alpha)
*pos
(
fluid.dmdtYi(Y[i].name())
- dimensionedScalar("zero", dimDensity/dimTime, 1e-3)
)
//fluid.dmdtYi(Y[i].name())/phase.rho()
//explicit mass sources (P or T)
);
YiEqn->relax();
YiEqn->solve(mesh.solver("Yi"));
Y[i].max(0.0);
Y[i].min(1.0);
Yt += Y[i];
}
else
{
inertIndex = i;
}
// if (mesh.time().outputTime())
// {
// volScalarField dmdtYi("dmdtYi", pos(fluid.dmdtYi(Y[i].name())));
// dmdtYi.write();
// }
Info << "Min/Max : " << min(Y[i]) << " " << max(Y[i]) << endl;
Info<< "Max dmdtYi : "
<< max(fluid.dmdtYi(Y[i].name())().internalField()) << endl;
Info<< "Min dmdtYi : "
<< min(fluid.dmdtYi(Y[i].name())().internalField()) << endl;
}
Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].max(0.0);
}
}
}

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 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/>.
Global
alphaCourantNo
Description
Calculates and outputs the mean and maximum Courant Numbers.
\*---------------------------------------------------------------------------*/
scalar maxAlphaCo
(
readScalar(runTime.controlDict().lookup("maxAlphaCo"))
);
scalar alphaCoNum = 0.0;
scalar meanAlphaCoNum = 0.0;
if (mesh.nInternalFaces())
{
scalarField sumPhi
(
fluid.nearInterface()().internalField()
*fvc::surfaceSum(mag(phi))().internalField()
);
alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();
meanAlphaCoNum =
0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();
}
Info<< "Interface Courant Number mean: " << meanAlphaCoNum
<< " max: " << alphaCoNum << endl;
// ************************************************************************* //

View File

@ -0,0 +1,137 @@
Info<< "Reading field p_rgh\n" << endl;
volScalarField p_rgh
(
IOobject
(
"p_rgh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Calculating field g.h\n" << endl;
volScalarField gh("gh", g & mesh.C());
surfaceScalarField ghf("ghf", g & mesh.Cf());
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p_rgh //+ rho*gh
);
Info<< "Creating multiphaseSystem\n" << endl;
autoPtr<multiphaseSystem> fluidPtr = multiphaseSystem::New(mesh);
multiphaseSystem& fluid = fluidPtr();
//volScalarField& e = fluid.he();
volScalarField& T = fluid.T();
// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
fluid.rho()
);
rho.oldTime();
// Update p using fluid.rho()
p = p_rgh + rho*gh;
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
pimple.dict(),
pRefCell,
pRefValue
);
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
// Total volumetric flux
surfaceScalarField& phi = fluid.phi();
// Mass flux
surfaceScalarField& rhoPhi = fluid.rhoPhi();
// Construct incompressible turbulence model
autoPtr<CompressibleTurbulenceModel<multiphaseSystem> > turbulence
(
CompressibleTurbulenceModel<multiphaseSystem>::New
(
rho,
U,
rhoPhi,
fluid
)
);
// Creating radiation model
autoPtr<radiation::radiationModel> radiation
(
radiation::radiationModel::New(T)
);
/*
Info<< "Calculating field kappaEff\n" << endl;
volScalarField kappaEff
(
IOobject
(
"kappaEff",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
fluid.kappa()
);
kappaEff.correctBoundaryConditions();
*/
Info<< "Creating field kinetic energy K\n" << endl;
volScalarField K("K", 0.5*magSqr(U));

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Application
icoReactingMultiphaseInterFoam
Group
grpMultiphaseSolvers
Description
Solver for n incompressible, non-isothermal immiscible fluids with
phase-change (evaporation-condensation). Uses a VOF (volume of fluid)
phase-fraction based interface capturing approach.
The momentum, energy and other fluid properties are of the "mixture" and a
single momentum equation is solved.
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "CMULES.H"
#include "subCycle.H"
#include "multiphaseSystem.H"
#include "turbulentFluidThermoModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "fixedFluxPressureFvPatchScalarField.H"
#include "radiationModel.H"
#include "HashPtrTable.H"
#include "fvcDDt.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
pimpleControl pimple(mesh);
#include "readGravitationalAcceleration.H"
#include "createFields.H"
#include "createFvOptions.H"
#include "createTimeControls.H"
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
fluid.solve();
rho = fluid.rho();
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
solve(fvm::ddt(rho) + fvc::div(rhoPhi));
#include "UEqn.H"
#include "YEqns.H"
#include "TEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence->correct();
}
}
rho = fluid.rho();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,256 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd
\\/ 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 "DTRMParticle.H"
#include "constants.H"
#include "physicoChemicalConstants.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::DTRMParticle::DTRMParticle
(
const polyMesh& mesh,
const vector& position,
const vector& targetPosition,
const scalar I,
const label cellI,
const scalar dA,
const label reflectedId,
const scalar Imin,
bool doCellFacePt
)
:
particle(mesh, position, cellI, doCellFacePt),
p0_(position),
p1_(targetPosition),
I0_(I),
I_(I),
dA_(dA),
reflectedId_(reflectedId),
Imin_(Imin)
{}
Foam::DTRMParticle::DTRMParticle(const DTRMParticle& p)
:
particle(p),
p0_(p.p0_),
p1_(p.p1_),
I0_(p.I0_),
I_(p.I_),
dA_(p.dA_),
reflectedId_(p.reflectedId_),
Imin_(p.Imin_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::DTRMParticle::move
(
trackingData& td,
const scalar trackTime
)
{
td.switchProcessor = false;
td.keepParticle = true;
const polyBoundaryMesh& pbMesh = mesh_.boundaryMesh();
while (td.keepParticle && !td.switchProcessor)
{
point p0 = position();
label cell0 = cell();
scalar dt = trackToFace(p1_, td);
// Consider the cell between f0(start of tracking) and f1
label celli = cell();
const vector dsv = position() - p0;
const scalar ds = mag(dsv);
// Boltzman constant
const scalar sigma = physicoChemical::sigma.value();
if
(
(!td.relfectedCells()[celli] > 0 && reflectedId_ == 0)
|| reflectedId_ > 0
)
{
scalar a = td.aInterp().interpolate(position(), cell0);
scalar e = td.eInterp().interpolate(position(), cell0);
scalar E = td.EInterp().interpolate(position(), cell0);
scalar T = td.TInterp().interpolate(position(), cell0);
const scalar I1 =
(
I_
+ ds*(e*sigma*pow4(T)/mathematical::pi + E)
) / (1 + ds*a);
td.Q(cell0) += (I_ - I1)*dA_;
I_ = I1;
if ((I_ <= 0.01*I0_) || (I_ < Imin_))
{
break;
}
}
else
{
scalar rho(0);
// Create a new reflected particle when the particles is not
// transmissive and larger than an absolute I
if (reflectedId_ == 0 && I_ > Imin_)
{
vector pDir = dsv/ds;
cellPointWeight cpw(mesh_, position(), celli, face());
//vector nHat = td.nHatCells()[celli];
vector nHat = td.nHatInterp().interpolate(cpw);
nHat /= mag(nHat);
scalar cosTheta(-pDir & nHat);
// Only new incoming rays
if (cosTheta > SMALL)
{
vector newDir = td.reflection().R(pDir, nHat);
//scalar theta = acos(-pDir & nHat);
// reflectivity
rho = min(max(td.reflection().rho(cosTheta), 0.0), 0.98);
scalar delaM = sqrt(mesh_.cellVolumes()[cell0]);
DTRMParticle* pPtr = new DTRMParticle
(
mesh_,
position() - pDir*0.1*delaM,
position() + newDir*mesh_.bounds().mag(),
I_*rho,
cell0,
dA_,
reflectedId_,
Imin_,
true
);
// Add to cloud
td.cloud().addParticle(pPtr);
}
}
reflectedId_++;
const point p0 = position();
// Try to locate this particle across the reflecting surface in
// a pure phase face
scalar dt = trackToFace(p1_, td);
const scalar ds = mag(position() - p0);
scalar a = td.aInterp().interpolate(position(), celli);
scalar e = td.eInterp().interpolate(position(), celli);
scalar E = td.EInterp().interpolate(position(), celli);
scalar T = td.TInterp().interpolate(position(), celli);
// Left intensity after reflection
const scalar Itran = I_*(1.0 - rho);
const scalar I1 =
(
Itran
+ ds*(e*sigma*pow4(T)/mathematical::pi + E)
) / (1 + ds*a);
td.Q(celli) += (Itran - I1)*dA_;
I_ = I1;
if (I_ <= 0.01*I0_ || I_ < Imin_)
{
break;
}
}
if (onBoundary() && td.keepParticle)
{
if (isA<processorPolyPatch>(pbMesh[patch(face())]))
{
td.switchProcessor = true;
}
}
}
return td.keepParticle;
}
bool Foam::DTRMParticle::hitPatch
(
const polyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>&,
const label,
const scalar,
const tetIndices&
)
{
return false;
}
void Foam::DTRMParticle::hitProcessorPatch
(
const processorPolyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>& td
)
{
td.switchProcessor = true;
}
void Foam::DTRMParticle::hitWallPatch
(
const wallPolyPatch& wpp,
particle::TrackingData<Cloud<DTRMParticle>>& td,
const tetIndices& tetIs
)
{
td.keepParticle = false;
}
void Foam::DTRMParticle::hitPatch
(
const polyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>& td
)
{
td.keepParticle = false;
}
// ************************************************************************* //

View File

@ -0,0 +1,347 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd
\\/ 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/>.
Class
Foam::DTRMParticle
Description
Discrete Transfer Radiation Model (DTRM) particle
SourceFiles
DTRMParticle.H
\*---------------------------------------------------------------------------*/
#ifndef DTRMParticle_H
#define DTRMParticle_H
#include "particle.H"
#include "IOstream.H"
#include "autoPtr.H"
#include "interpolationCell.H"
#include "volFieldsFwd.H"
#include "reflectionModel.H"
#include "interpolationCellPoint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class DTRMParticle;
using namespace Foam::radiation;
// Forward declaration of friend functions
Ostream& operator<<(Ostream&, const DTRMParticle&);
/*---------------------------------------------------------------------------*\
Class DTRMParticle Declaration
\*---------------------------------------------------------------------------*/
class DTRMParticle
:
public particle
{
private:
// Private data
//- Size in bytes of the fields
static const std::size_t sizeofFields_;
//- Initial position
point p0_;
//- Target position
point p1_;
//- Initial radiation intensity [W/m2]
scalar I0_;
//- Radiation intensity [W/m2]
scalar I_;
//- Area of radiation
scalar dA_;
//- Reflected index
label reflectedId_;
//- Minimum radiation intensity to which the particle is tracked [W/m2]
scalar Imin_;
public:
friend class Cloud<DTRMParticle>;
//- Class used to pass tracking data to the trackToFace function
class trackingData
:
public particle::TrackingData<Cloud<DTRMParticle>>
{
// Interpolators for continuous phase fields
const interpolationCell<scalar>& aInterp_;
const interpolationCell<scalar>& eInterp_;
const interpolationCell<scalar>& EInterp_;
const interpolationCell<scalar>& TInterp_;
const interpolationCellPoint<vector>& nHatInterp_;
const labelField& relfectedCells_;
const reflectionModel& reflection_;
//- Heat source term
volScalarField& Q_;
public:
// Constructors
inline trackingData
(
Cloud<DTRMParticle>& spc,
const interpolationCell<scalar>& aInterp,
const interpolationCell<scalar>& eInterp,
const interpolationCell<scalar>& EInterp,
const interpolationCell<scalar>& TInterp,
const interpolationCellPoint<vector>& nHatInterp,
const labelField&,
const reflectionModel&,
volScalarField& Q
);
// Public data
// Member functions
inline const interpolationCell<scalar>& aInterp() const;
inline const interpolationCell<scalar>& eInterp() const;
inline const interpolationCell<scalar>& EInterp() const;
inline const interpolationCell<scalar>& TInterp() const;
inline const interpolationCellPoint<vector>& nHatInterp() const;
inline const labelField& relfectedCells() const;
inline const reflectionModel& reflection() const;
inline scalar& Q(label celli);
};
// Static data members
//- String representation of properties
AddToPropertyList
(
particle,
" p0"
+ " p1"
+ " I0"
+ " I"
+ " dA";
);
//- String representation of property types
AddToPropertyTypes
(
particle,
"{point"
+ " point"
+ " scalar"
+ " scalar}"
);
// Constructors
//- Construct from components, with searching for tetFace and
// tetPt unless disabled by doCellFacePt = false.
DTRMParticle
(
const polyMesh& mesh,
const vector& position,
const vector& targetPosition,
const scalar I,
const label cellI,
const scalar dA,
const label reflectedId,
const scalar Imin,
bool doCellFacePt = true
);
//- Construct from Istream
DTRMParticle
(
const polyMesh& mesh,
Istream& is,
bool readFields = true
);
//- Construct as copy
DTRMParticle(const DTRMParticle& p);
//- Construct and return a clone
virtual autoPtr<particle> clone() const
{
return autoPtr<particle>(new DTRMParticle(*this));
}
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;
public:
iNew(const polyMesh& mesh)
:
mesh_(mesh)
{}
autoPtr<DTRMParticle> operator()(Istream& is) const
{
return autoPtr<DTRMParticle>
(
new DTRMParticle(mesh_, is, true)
);
}
};
// Access
//- Return const access to the initial position
inline const point& p0() const;
//- Return const access to the target position
inline const point& p1() const;
//- Return const access to the initial intensity
inline scalar I0() const;
//- Return const access to the current intensity
inline scalar I() const;
//- Return const access dA
inline scalar dA() const;
// Edit
//- Return access to the initial position
inline point& p0();
//- Return access to the target position
inline point& p1();
//- Return access to the initial intensity
inline scalar& I0();
//- Return access to the current intensity
inline scalar& I();
//- Return access to dA
inline scalar& dA();
//- Return access to reflectedId
inline label& reflectedId();
//- Return access to initial tet face
//inline label& tetFace0();
//- Return access to initial tet point
//inline label& tetPt0();
//- Return access to initial proc Id
//inline label& origProc0();
// Tracking
//- Move
bool move(trackingData&, const scalar);
// Member Operators
//- Overridable function to handle the particle hitting a patch
// Executed before other patch-hitting functions
bool hitPatch
(
const polyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
);
//- Overridable function to handle the particle hitting a processorPatch
void hitProcessorPatch
(
const processorPolyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>& td
);
//- Overridable function to handle the particle hitting a wallPatch
void hitWallPatch
(
const wallPolyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>& td,
const tetIndices&
);
//- Overridable function to handle the particle hitting a polyPatch
void hitPatch
(
const polyPatch&,
particle::TrackingData<Cloud<DTRMParticle>>& td
);
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const DTRMParticle& p);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DTRMParticleI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,174 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::DTRMParticle::trackingData::trackingData
(
Cloud<DTRMParticle>& spc,
const interpolationCell<scalar>& aInterp,
const interpolationCell<scalar>& eInterp,
const interpolationCell<scalar>& EInterp,
const interpolationCell<scalar>& TInterp,
const interpolationCellPoint<vector>& nHatInterp,
const labelField& relfectedCell,
const reflectionModel& reflection,
volScalarField& Q
)
:
particle::TrackingData<Cloud<DTRMParticle>>(spc),
aInterp_(aInterp),
eInterp_(eInterp),
EInterp_(EInterp),
TInterp_(TInterp),
nHatInterp_(nHatInterp),
relfectedCells_(relfectedCell),
reflection_(reflection),
Q_(Q)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::interpolationCell<Foam::scalar>&
Foam::DTRMParticle::trackingData::aInterp() const
{
return aInterp_;
}
inline const Foam::interpolationCell<Foam::scalar>&
Foam::DTRMParticle::trackingData::eInterp() const
{
return eInterp_;
}
inline const Foam::interpolationCell<Foam::scalar>&
Foam::DTRMParticle::trackingData::EInterp() const
{
return EInterp_;
}
inline const Foam::interpolationCell<Foam::scalar>&
Foam::DTRMParticle::trackingData::TInterp() const
{
return TInterp_;
}
inline const Foam::interpolationCellPoint<Foam::vector>&
Foam::DTRMParticle::trackingData::nHatInterp() const
{
return nHatInterp_;
}
inline const Foam::labelField&
Foam::DTRMParticle::trackingData::relfectedCells() const
{
return relfectedCells_;
}
inline const Foam::reflectionModel&
Foam::DTRMParticle::trackingData::reflection() const
{
return reflection_;
}
inline Foam::scalar& Foam::DTRMParticle::trackingData::Q(label celli)
{
return Q_[celli];
}
inline const Foam::point& Foam::DTRMParticle::p0() const
{
return p0_;
}
inline const Foam::point& Foam::DTRMParticle::p1() const
{
return p1_;
}
inline Foam::scalar Foam::DTRMParticle::I0() const
{
return I0_;
}
inline Foam::scalar Foam::DTRMParticle::I() const
{
return I_;
}
inline Foam::scalar Foam::DTRMParticle::dA() const
{
return dA_;
}
inline Foam::scalar& Foam::DTRMParticle::dA()
{
return dA_;
}
inline Foam::point& Foam::DTRMParticle::p0()
{
return p0_;
}
inline Foam::label& Foam::DTRMParticle::reflectedId()
{
return reflectedId_;
}
inline Foam::point& Foam::DTRMParticle::p1()
{
return p1_;
}
inline Foam::scalar& Foam::DTRMParticle::I0()
{
return I0_;
}
inline Foam::scalar& Foam::DTRMParticle::I()
{
return I_;
}
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd
\\/ 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 "DTRMParticle.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::string Foam::DTRMParticle::propertyList_ =
Foam::DTRMParticle::propertyList();
const std::size_t Foam::DTRMParticle::sizeofFields_
(
sizeof(DTRMParticle) - sizeof(particle)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::DTRMParticle::DTRMParticle
(
const polyMesh& mesh,
Istream& is,
bool readFields
)
:
particle(mesh, is, readFields),
p0_(position_),
p1_(point::zero),
I0_(0),
I_(0),
dA_(0)
{
if (readFields)
{
if (is.format() == IOstream::ASCII)
{
is >> p0_ >> p1_ >> I0_ >> I_ >> dA_;
}
else
{
is.read(reinterpret_cast<char*>(&p0_), sizeofFields_);
}
}
}
Foam::Ostream& Foam::operator<<(Ostream& os, const DTRMParticle& p)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const particle&>(p)
<< token::SPACE << p.p0_
<< token::SPACE << p.p1_
<< token::SPACE << p.I0_
<< token::SPACE << p.I_
<< token::SPACE << p.dA_;
}
else
{
os << static_cast<const particle&>(p);
os.write
(
reinterpret_cast<const char*>(&p.p0_),
DTRMParticle::sizeofFields_
);
}
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const DTRMParticle&)");
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,13 @@
laserDTRM.C
DTRMParticle/DTRMParticle.C
DTRMParticle/DTRMParticleIO.C
localDensityAbsorptionEmission/localDensityAbsorptionEmission.C
reflectionModel/reflectionModel/reflectionModel.C
reflectionModel/reflectionModel/reflectionModelNew.C
reflectionModel/noReflection/noReflection.C
reflectionModel/FresnelLaser/FresnelLaser.C
reflectionModel/Fresnel/Fresnel.C
LIB = $(FOAM_LIBBIN)/liblaserDTRM

View File

@ -0,0 +1,11 @@
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \
-lradiationModels \
-llagrangian \
-lfiniteVolume

View File

@ -0,0 +1,753 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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 "laserDTRM.H"
#include "fvmLaplacian.H"
#include "fvmSup.H"
#include "absorptionEmissionModel.H"
#include "scatterModel.H"
#include "constants.H"
#include "addToRunTimeSelectionTable.H"
#include "unitConversion.H"
#include "interpolationCell.H"
#include "interpolationCellPoint.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(laserDTRM, 0);
addToRadiationRunTimeSelectionTables(laserDTRM);
}
defineTemplateTypeNameAndDebugWithName
(
Cloud<DTRMParticle>,
"DTRMCloud",
0
);
namespace radiation
{
template<>
const char* Foam::NamedEnum
<
Foam::radiation::laserDTRM::powerDistributionMode,
3
>::names[] =
{
"Gaussian",
"manual",
"uniform"
};
}
}
const Foam::NamedEnum
<
Foam::radiation::laserDTRM::powerDistributionMode,
3
> Foam::radiation::laserDTRM::powerDistypeNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::radiation::laserDTRM::calculateIp(scalar r, scalar theta)
{
const scalar t = mesh_.time().value();
switch(mode_)
{
case pdGaussian:
{
scalar I0 =
laserPower_->value(t)/(mathematical::twoPi*sqr(sigma_));
return(I0*exp(-sqr(r)/2.0/sqr(sigma_)));
break;
}
case pdManual:
{
return(laserPower_->value(t)*powerDistribution_()(theta, r));
break;
}
case pdUniform:
{
return
(
laserPower_->value(t)/(mathematical::pi*sqr(focalLaserRadius_))
);
}
default:
{
FatalErrorInFunction
<< "Unhandled type " << powerDistypeNames_
<< abort(FatalError);
return(0);
}
}
}
Foam::tmp<Foam::volVectorField> Foam::radiation::laserDTRM::nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
const dimensionedScalar deltaN
(
"deltaN",
1e-8/pow(average(mesh_.V()), 1.0/3.0)
);
const dimensionedScalar minAlpha
(
"minAlpha", dimless, 1e-3
);
volVectorField gradAlphaf
(
"gradAlphaf",
(alpha2 + minAlpha)*fvc::grad(alpha1)
- (alpha1 + minAlpha)*fvc::grad(alpha2)
);
// Face unit interface normal
return gradAlphaf/(mag(gradAlphaf)+ deltaN);
}
Foam::tmp<Foam::volScalarField>Foam::radiation::laserDTRM::nearInterface
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const
{
return
pos(alpha1 - 0.1)*pos(0.9 - alpha1)
* pos(alpha2 - 0.1)*pos(0.9 - alpha2);
}
void Foam::radiation::laserDTRM::initialise()
{
// Initialise the DTRM particles
DTRMCloud_.clear();
const scalar t = mesh_.time().value();
const vector lPosition = focalLaserPosition_->value(t);
vector lDir = laserDirection_->value(t);
lDir /= mag(lDir);
if (debug)
{
Info << "Laser position : " << lPosition << endl;
Info << "Laser direction : " << lDir << endl;
}
// Find a vector on the area plane. Normal to laser direction
vector rArea = vector::zero;
scalar magr = 0.0;
cachedRandom rnd(1234, -1);
while (magr < VSMALL)
{
vector v = rnd.sample01<vector>();
rArea = v - (v & lDir)*lDir;
magr = mag(rArea);
}
rArea /= mag(rArea);
scalar dr = focalLaserRadius_/ndr_;
scalar dTheta = mathematical::twoPi/ndTheta_;
nParticles_ = ndr_*ndTheta_;
switch(mode_)
{
case pdGaussian:
{
sigma_ = readScalar(lookup("sigma"));
break;
}
case pdManual:
{
powerDistribution_.reset
(
new interpolation2DTable<scalar>(*this)
);
// Check dimensions ndr and ndTheta
// if
// (
// (powerDistribution_->size() != ndTheta_)
// || (powerDistribution_().first().second().size() != ndr_)
// )
// {
// FatalErrorInFunction
// << " The table dimensions should correspond with ndTheta "
// << " and ndr "
// << exit(FatalError);
// }
break;
}
case pdUniform:
{
break;
}
}
// Target position
point p1 = vector::zero;
// Seed DTRM particles
// TODO: currently only applicable to 3-D cases
point p0 = lPosition;
scalar power(0.0);
scalar area(0.0);
p1 = p0;
if (mesh_.nGeometricD() == 3)
{
//scalar r0 = dr/2.0;
//scalar r1Max0 = drMax/2.0;
for (label ri = 0; ri < ndr_; ri++)
{
scalar r1 = SMALL + dr*ri;
scalar r2 = r1 + dr;
scalar rP = ((r1 + r2)/2);
// local radius on disk
vector localR = ((r1 + r2)/2)*rArea;
// local final radius on disk
vector finalR = rP*rArea;
scalar theta0 = 0.0;//dTheta/2.0;
for (label thetai = 0; thetai < ndTheta_; thetai++)
{
scalar theta1 = theta0 + SMALL + dTheta*thetai;
scalar theta2 = theta1 + dTheta;
scalar thetaP = (theta1 + theta2)/2.0;
quaternion Q(lDir, thetaP);
// Initial position on disk
vector initialPos = (Q.R() & localR);
// Final position on disk
vector finalPos = (Q.R() & finalR);
// Initial position
p0 = lPosition + initialPos;
// calculate target point using new deviation rl
p1 = lPosition + finalPos + (0.5*maxTrackLength_*lDir);
//scalar p = magSqr(p0 - lPosition);
scalar Ip = calculateIp(rP, thetaP);
scalar dAi = (sqr(r2) - sqr(r1))*(theta2 - theta1)/2.0;
power += Ip*dAi;
area += dAi;
label cellI = mesh_.findCell(p0);
if (cellI != -1)
{
// Create a new particle
DTRMParticle* pPtr = new DTRMParticle
(mesh_, p0, p1, Ip, cellI, dAi, 0 , 0.01*Ip, true);
// Add to cloud
DTRMCloud_.addParticle(pPtr);
}
if (returnReduce(cellI, maxOp<label>()) == -1)
{
WarningIn("void Foam::radiation::laserDTRM::initialise()")
<< "Cannot find owner cell for particle at position " << p0
<< endl;
}
}
}
}
else
{
FatalErrorIn("void Foam::radiation::laserDTRM::initialise()")
<< "Current functionality limited to 3-D cases"
<< exit(FatalError);
}
if (debug)
{
Info << "Total Power in the laser : " << power << endl;
Info << "Total Area in the laser : " << area << endl;
Info << "Number of particles in the laser : "
<< returnReduce(DTRMCloud_.size(), sumOp<label>()) << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
:
radiationModel(typeName, T),
mode_(powerDistypeNames_.read(lookup("mode"))),
DTRMCloud_(mesh_, "DTRMCloud", IDLList<DTRMParticle>()),
nParticles_(0),
ndTheta_(readLabel(lookup("nTheta"))),
ndr_(readLabel(lookup("nr"))),
maxTrackLength_(mesh_.bounds().mag()),
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this)
),
focalLaserRadius_(readScalar(lookup("focalLaserRadius"))),
qualityBeamLaser_
(
lookupOrDefault<scalar>("qualityBeamLaser", 0.0)
),
sigma_(0),
laserPower_(Function1<scalar>::New("laserPower", *this)),
powerDistribution_(),
reflection_(reflectionModel::New(*this, mesh_).ptr()),
reflectionSwitch_(lookupOrDefault("reflection", false)),
initialPhase_(lookupOrDefault("initialPhase", word::null)),
alpha1_(lookupOrDefault("alpha1", word::null)),
alpha2_(lookupOrDefault("alpha2", word::null)),
Qin_
(
IOobject
(
"Qin",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Qin", dimPower/dimArea, 0.0)
),
a_
(
IOobject
(
"a",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)
),
e_
(
IOobject
(
"e",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)
),
E_
(
IOobject
(
"E",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
),
Q_
(
IOobject
(
"Q",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Q", dimPower/dimVolume, 0.0)
)
{
initialise();
}
Foam::radiation::laserDTRM::laserDTRM
(
const dictionary& dict,
const volScalarField& T
)
:
radiationModel(typeName, dict, T),
mode_(powerDistypeNames_.read(lookup("mode"))),
DTRMCloud_(mesh_, "DTRMCloud", IDLList<DTRMParticle>()),
nParticles_(0),
ndTheta_(readLabel(lookup("nTheta"))),
ndr_(readLabel(lookup("nr"))),
maxTrackLength_(mesh_.bounds().mag()),
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this)
),
focalLaserRadius_(readScalar(lookup("focalLaserRadius"))),
qualityBeamLaser_
(
lookupOrDefault<scalar>("qualityBeamLaser", 0.0)
),
sigma_(0),
laserPower_(Function1<scalar>::New("laserPower", *this)),
powerDistribution_(),
reflection_(reflectionModel::New(*this, mesh_).ptr()),
reflectionSwitch_(dict.lookupOrDefault("reflection", false)),
initialPhase_(lookupOrDefault("initialPhase", word::null)),
alpha1_(lookupOrDefault("alpha1", word::null)),
alpha2_(lookupOrDefault("alpha2", word::null)),
Qin_
(
IOobject
(
"Qin",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Qin", dimPower/dimArea, 0.0)
),
a_
(
IOobject
(
"a",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)
),
e_
(
IOobject
(
"e",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)
),
E_
(
IOobject
(
"E",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
),
Q_
(
IOobject
(
"Q",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("Q", dimPower/pow3(dimLength), 0.0)
)
{
initialise();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::laserDTRM::~laserDTRM()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::radiation::laserDTRM::read()
{
if (radiationModel::read())
{
return true;
}
else
{
return false;
}
}
void Foam::radiation::laserDTRM::calculate()
{
tmp<volScalarField> treflectingCells
(
new volScalarField
(
IOobject
(
"reflectingCellsVol",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimless, 0)
)
);
volScalarField& reflectingCellsVol = treflectingCells.ref();
// Reset the fields
Qin_ == dimensionedScalar("zero", Qin_.dimensions(), 0);
Q_ == dimensionedScalar("zero", Q_.dimensions(), 0);
a_ = absorptionEmission_->a();
e_ = absorptionEmission_->e();
E_ = absorptionEmission_->E();
const interpolationCell<scalar> aInterp(a_);
const interpolationCell<scalar> eInterp(e_);
const interpolationCell<scalar> EInterp(E_);
const interpolationCell<scalar> TInterp(T_);
labelField reflectingCells(mesh_.nCells(), 0);
tmp<volVectorField> tnHat
(
new volVectorField
(
IOobject
(
"nHat",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedVector("zero", dimless, vector::zero)
)
);
volVectorField& nHat = tnHat.ref();
autoPtr<interpolationCellPoint<vector>> nHatIntrPtr;
if (reflectionSwitch_)
{
const volScalarField& initialPhase =
mesh_.lookupObject<volScalarField>(initialPhase_);
if (alpha1_ != word::null)
{
const volScalarField& alpha1 =
mesh_.lookupObject<volScalarField>(alpha1_);
nHat = nHatfv(initialPhase, alpha1);
forAll(alpha1, cellI)
{
if ((alpha1[cellI] > 0.9) && (mag(nHat[cellI]) > 0.9))
{
reflectingCells[cellI] = 1;
reflectingCellsVol[cellI] = 1.0;
}
}
}
if (alpha2_ != word::null)
{
const volScalarField& alpha2 =
mesh_.lookupObject<volScalarField>(alpha2_);
nHat += nHatfv(initialPhase, alpha2);
forAll(alpha2, cellI)
{
if ((alpha2[cellI] > 0.9) && (mag(nHat[cellI]) > 0.9))
{
reflectingCells[cellI] = 1;
reflectingCellsVol[cellI] = 1.0;
}
}
}
nHatIntrPtr.reset
(
new interpolationCellPoint<vector>(nHat)
);
}
DTRMParticle::trackingData td
(
DTRMCloud_,
aInterp,
eInterp,
EInterp,
TInterp,
nHatIntrPtr,
reflectingCells,
reflection_,
Q_
);
Info << "Move particles..."
<< returnReduce(DTRMCloud_.size(), sumOp<label>()) << endl;
DTRMCloud_.move(td, mesh_.time().deltaTValue());
// Normalize by cell volume
Q_.primitiveFieldRef() /= mesh_.V();
if (debug)
{
OFstream osRef
(
type() + ":particlePath.obj"
);
label vertI = 0;
forAllIter(Cloud<DTRMParticle>, DTRMCloud_, iter)
{
DTRMParticle& p = iter();
meshTools::writeOBJ(osRef, p.position());
vertI++;
meshTools::writeOBJ(osRef, p.p0());
vertI++;
osRef << "l " << vertI-1 << ' ' << vertI << nl;
}
osRef.flush();
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
Info << "Total energy absorbed [W]: " << totalQ << endl;
if (mesh_.time().outputTime())
{
reflectingCellsVol.write();
}
}
// Clear and initialise the cloud
// NOTE: Possible to reset original particles, but this requires
// data transfer for the cloud in differet processors.
initialise();
}
Foam::tmp<Foam::volScalarField> Foam::radiation::laserDTRM::Rp() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"zero",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar
(
"zero",
dimPower/dimVolume/pow4(dimTemperature),
0.0
)
)
);
}
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::radiation::laserDTRM::Ru() const
{
return Q_.internalField();
}
// ************************************************************************* //

View File

@ -0,0 +1,257 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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/>.
Class
Foam::radiation::laserDTRM
Description
Works well for combustion applications where optical thickness, tau is
large, i.e. tau = a*L > 3 (L = distance between objects)
Assumes
- all surfaces are diffuse
- tends to over predict radiative fluxes from sources/sinks
*** SOURCES NOT CURRENTLY INCLUDED ***
SourceFiles
laserDTRM.C
\*---------------------------------------------------------------------------*/
#ifndef radiationModellaserDTRM_H
#define radiationModellaserDTRM_H
#include "radiationModel.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "Cloud.H"
#include "DTRMParticle.H"
#include "reflectionModel.H"
#include "Function1.H"
#include "interpolation2DTable.H"
#include "labelField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class laserDTRM Declaration
\*---------------------------------------------------------------------------*/
class laserDTRM
:
public radiationModel
{
public:
// Public enumeration
//- Modes of power distribution
enum powerDistributionMode
{
pdGaussian,
pdManual,
pdUniform
};
private:
// Private data
static const NamedEnum<powerDistributionMode, 3> powerDistypeNames_;
//- Operating mode for power distribution
powerDistributionMode mode_;
//- DTRM particle cloud
Cloud<DTRMParticle> DTRMCloud_;
//- Number of particles
label nParticles_;
//- Number of theta angles
label ndTheta_;
//- Number of radials
label ndr_;
//- Maximum tracking length for particles
scalar maxTrackLength_;
// Laser parameters
//- Focal laser position
autoPtr<Function1<point>> focalLaserPosition_;
//- Direction
autoPtr<Function1<vector>> laserDirection_;
//- Focal lase radius
scalar focalLaserRadius_;
//- Quality beam laser (tan of the angle between the main direction
// (laserDirection) and the spreading rays (0: flat, 1:fully)
scalar qualityBeamLaser_;
// Gaussian power distribution entries
//- Sigma deviation
scalar sigma_;
//- Power
autoPtr<Function1<scalar>> laserPower_;
// Manual power distribution entries
//- Manual power distribution table. (theta, radius)
autoPtr<interpolation2DTable<scalar>> powerDistribution_;
// Reflection sub-model
//- Reflection model
autoPtr<reflectionModel> reflection_;
//- Reflection switch
bool reflectionSwitch_;
//- Phase in which the particles are inserted
word initialPhase_;
//- Phase name for absorbing medium 1
word alpha1_;
//- Phase name for absorbing medium 2
word alpha2_;
// Fields
//- Incident radiative heat flux [W/m2]
volScalarField Qin_;
//- Absorption coefficient
volScalarField a_;
//- Emission coefficient
volScalarField e_;
//- Emission contribution
volScalarField E_;
//- Volumetric heat source [W/m3]
volScalarField Q_;
// Private Member Functions
//- Initialise
void initialise();
//- Calculate Intensity of the laser at p(t, theta) [W/m2]
scalar calculateIp(scalar r, scalar theta);
// Normal surface on the interface
tmp<volVectorField> nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
//- Indicator of the proximity of the interface
// Field values are 1 near and 0 away for the interface.
tmp<volScalarField> nearInterface
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
//- Disallow default bitwise copy construct
laserDTRM(const laserDTRM&);
//- Disallow default bitwise assignment
void operator=(const laserDTRM&);
public:
//- Runtime type information
TypeName("laserDTRM");
// Constructors
//- Construct from components
laserDTRM(const volScalarField& T);
//- Construct from components
laserDTRM(const dictionary& dict, const volScalarField& T);
//- Destructor
virtual ~laserDTRM();
// Member functions
// Edit
//- Solve radiation equation(s)
void calculate();
//- Read radiation properties dictionary
bool read();
// Access
//- Source term component (for power of T^4)
virtual tmp<volScalarField> Rp() const;
//- Source term component (constant)
virtual tmp<DimensionedField<scalar, volMesh> > Ru() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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 "localDensityAbsorptionEmission.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(localDensityAbsorptionEmission, 0);
addToRunTimeSelectionTable
(
absorptionEmissionModel,
localDensityAbsorptionEmission,
dictionary
);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::volScalarField&
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
{
if (!mesh_.foundObject<volScalarField>(alphaName))
{
FatalErrorIn
(
"const Foam::volScalarField& "
"Foam::radiation::localDensityAbsorptionEmission::alpha() const"
)
<< "Unable to retrieve density field " << alphaName << " from "
<< "database. Available objects:" << mesh_.sortedNames()
<< exit(FatalError);
}
return mesh_.lookupObject<volScalarField>(alphaName);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::localDensityAbsorptionEmission::localDensityAbsorptionEmission
(
const dictionary& dict,
const fvMesh& mesh
)
:
absorptionEmissionModel(dict, mesh),
coeffsDict_(dict.subDict(typeName + "Coeffs")),
alphaNames_(coeffsDict_.lookup("alphaNames")),
aCoeff_(coeffsDict_.lookup("aCoeff")),
eCoeff_(coeffsDict_.lookup("eCoeff")),
ECoeff_(coeffsDict_.lookup("ECoeff"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::localDensityAbsorptionEmission::~localDensityAbsorptionEmission()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
{
tmp<volScalarField> ta
(
new volScalarField
(
IOobject
(
"a",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimless/dimLength, 0)
)
);
scalarField& a = ta.ref().primitiveFieldRef();
forAll(alphaNames_, i)
{
dimensionedScalar aPhase("a", dimless/dimLength, aCoeff_[i]);
a += max(alpha(alphaNames_[i]), 0.0)*aPhase;
}
return ta;
}
Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
{
tmp<volScalarField> te
(
new volScalarField
(
IOobject
(
"e",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimless/dimLength, 0)
)
);
scalarField& e = te.ref().primitiveFieldRef();
forAll(alphaNames_, i)
{
dimensionedScalar ePhase("e", dimless/dimLength, eCoeff_[i]);
e += max(alpha(alphaNames_[i]), 0.0)*ePhase;
}
return te;
}
Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const
{
tmp<volScalarField> tE
(
new volScalarField
(
IOobject
(
"E",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimMass/dimLength/pow3(dimTime), 0.0)
)
);
scalarField& E = tE.ref().primitiveFieldRef();
forAll(alphaNames_, i)
{
dimensionedScalar EPhase
(
"E",
dimMass/dimLength/pow3(dimTime),
ECoeff_[i]
);
E += max(alpha(alphaNames_[i]), 0.0)*EPhase;
}
return tE;
}
// ************************************************************************* //

View File

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd
\\/ 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/>.
Class
Foam::radiation::localDensityAbsorptionEmission
Description
Constant radiation absorption and emission coefficients for continuous
phase
SourceFiles
localDensityAbsorptionEmission.C
\*---------------------------------------------------------------------------*/
#ifndef radiationLocalDensityAbsorptionEmission_H
#define radiationLocalDensityAbsorptionEmission_H
#include "absorptionEmissionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class localDensityAbsorptionEmission Declaration
\*---------------------------------------------------------------------------*/
class localDensityAbsorptionEmission
:
public absorptionEmissionModel
{
// Private data
//- Absorption model dictionary
dictionary coeffsDict_;
//- Name of phase fields
List<word> alphaNames_;
//- Absorption coefficients
List<scalar> aCoeff_;
//- Emission coefficients
List<scalar> eCoeff_;
//- Emission contributions
List<scalar> ECoeff_;
// Private Member Functions
//- Retrieve the phase field from the database
const volScalarField& alpha(word) const;
public:
//- Runtime type information
TypeName("localDensityAbsorptionEmission");
// Constructors
//- Construct from components
localDensityAbsorptionEmission
(
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~localDensityAbsorptionEmission();
// Member Functions
// Access
// Absorption coefficient
//- Absorption coefficient for continuous phase
tmp<volScalarField> aCont(const label bandI = 0) const;
// Emission coefficient
//- Emission coefficient for continuous phase
tmp<volScalarField> eCont(const label bandI = 0) const;
// Emission contribution
//- Emission contribution for continuous phase
tmp<volScalarField> ECont(const label bandI = 0) const;
// Member Functions
inline bool isGrey() const
{
return true;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "Fresnel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(Fresnel, 0);
addToRunTimeSelectionTable
(
reflectionModel,
Fresnel,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::Fresnel::Fresnel
(
const dictionary& dict,
const fvMesh& mesh
)
:
reflectionModel(dict, mesh),
coeffsDict_(dict.subDict(typeName + "Coeffs")),
nk1_(coeffsDict_.lookup("nk1")),
nk2_(coeffsDict_.lookup("nk2"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::Fresnel::~Fresnel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::radiation::Fresnel::rho
(
const scalar incidentAngle
) const
{
// absorbing madium
scalar n1 = sqr(nk1_[0]);
//scalar k1 = sqr(nk1_[1]);
// dialectric
scalar n2 = sqr(nk2_[0]);
scalar k2 = sqr(nk2_[1]);
scalar sinTheta1 = sin(incidentAngle);
scalar sqrP =
0.5*
(
sqrt
(
sqr(n2-k2-n1*sqr(sinTheta1)) + 4*n2*k2
)
+ (n2-k2-n1*sqr(sinTheta1))
);
scalar sqrQ =
0.5*
(
sqrt
(
sqr(n2-k2-n1*sqr(sinTheta1)) + 4*n2*k2
)
- (n2-k2-n1*sqr(sinTheta1))
);
scalar cosTheta1 = cos(incidentAngle);
scalar tanTheta1 = tan(incidentAngle);
scalar rhoP =
(
(sqr(sqrt(n1)*cosTheta1 - sqrt(sqrP)) + sqrQ)
/
(sqr(sqrt(n1)*cosTheta1 + sqrt(sqrP)) + sqrQ)
);
scalar rhoN =
(
(sqr(sqrt(sqrP) - sqrt(n1)*sinTheta1*tanTheta1) + sqrQ)
/
(sqr(sqrt(sqrP) + sqrt(n1)*sinTheta1*tanTheta1) + sqrQ)
)*rhoP;
return (rhoP + rhoN)/2;
}
Foam::vector Foam::radiation::Fresnel::R
(
const vector& i,
const vector& n
) const
{
return i + 2.0*(-i & n) * n;
}
// ************************************************************************* //

View File

@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::radiation::Fresnel
Description
Genral Fresnel reflection model bewtween a dialectric and an absorbing
medium.
Radiative heat transfer. Micheal Modest. 3dr Edition. Chapter 2.5
SourceFiles
scatterModel.C
\*---------------------------------------------------------------------------*/
#ifndef Fresnel_H
#define Fresnel_H
#include "reflectionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class Fresnel Declaration
\*---------------------------------------------------------------------------*/
class Fresnel
:
public reflectionModel
{
// Private data
//- Coefficients dictionary
dictionary coeffsDict_;
//- Complex index of refraction for medium 1
Pair<scalar> nk1_;
//- Complex index of refraction for medium 2
Pair<scalar> nk2_;
public:
//- Runtime type information
TypeName("Fresnel");
// Constructors
//- Construct from components
Fresnel(const dictionary& dict, const fvMesh& mesh);
//- Destructor
virtual ~Fresnel();
// Member Functions
//- Return reflected direction
virtual vector R(const vector& incident, const vector& n) const;
//- Return reflectivity from medium1 to medium2 and a incident angle.
// nk1 = (n1 - i k1) from medium 1.
virtual scalar rho
(
const scalar incidentAngle
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "FresnelLaser.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(FresnelLaser, 0);
addToRunTimeSelectionTable
(
reflectionModel,
FresnelLaser,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::FresnelLaser::FresnelLaser
(
const dictionary& dict,
const fvMesh& mesh
)
:
reflectionModel(dict, mesh),
coeffsDict_(dict.subDict(typeName + "Coeffs")),
epsilon_(readScalar(coeffsDict_.lookup("epsilon")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::FresnelLaser::~FresnelLaser()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::radiation::FresnelLaser::rho
(
const scalar cosTheta
) const
{
//scalar cosTheta = cos(incidentAngle);
scalar rho =
0.5
* (
(1 + sqr(1 - epsilon_*cosTheta))/(1 + sqr(1 + epsilon_*cosTheta))
+
(sqr(epsilon_) - 2*epsilon_*cosTheta + 2*sqr(cosTheta))
/
(sqr(epsilon_) + 2*epsilon_*cosTheta + 2*sqr(cosTheta))
);
return rho;
}
Foam::vector Foam::radiation::FresnelLaser::R
(
const vector& i,
const vector& n
) const
{
return i + 2.0*(-i & n) * n;
}
// ************************************************************************* //

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::radiation::FresnelLaser
Description
Modified Fresnel FresnelLaser reflection model.
Implementation of real-time multiple reflection and Fresnel absorption
of FresnelLaser beam in keyhole.
J. Phys. D: Appl. Phys. 39 (2006) 5372-5378
SourceFiles
FresnelLaser.C
\*---------------------------------------------------------------------------*/
#ifndef FresnelLaser_H
#define FresnelLaser_H
#include "reflectionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class FresnelLaser Declaration
\*---------------------------------------------------------------------------*/
class FresnelLaser
:
public reflectionModel
{
// Private data
//- Coefficients dictionary
dictionary coeffsDict_;
//- Model constant
scalar epsilon_;
public:
//- Runtime type information
TypeName("FresnelLaser");
// Constructors
//- Construct from components
FresnelLaser(const dictionary& dict, const fvMesh& mesh);
//- Destructor
virtual ~FresnelLaser();
// Member Functions
//- Return reflected direction
virtual vector R(const vector& incident, const vector& n) const;
//- Return reflectivity from medium1 to medium2 and a incident angle.
// nk1 = (n1 - i k1) from medium 1.
virtual scalar rho
(
const scalar incidentAngle
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "noReflection.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(noReflection, 0);
addToRunTimeSelectionTable(reflectionModel, noReflection, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::noReflection::noReflection
(
const dictionary& dict,
const fvMesh& mesh
)
:
reflectionModel(dict, mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::noReflection::~noReflection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::radiation::noReflection::rho
(
const scalar incidentAngle
) const
{
return 0.0;
}
Foam::vector Foam::radiation::noReflection::R
(
const vector& incident,
const vector& n
) const
{
return (vector::zero);
}
// ************************************************************************* //

View File

@ -0,0 +1,95 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::radiation::noReflection
Description
Dummy scatter model for 'none'
SourceFiles
scatterModel.C
\*---------------------------------------------------------------------------*/
#ifndef radiationConstantScatter_H
#define radiationConstantScatter_H
#include "reflectionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class noReflection Declaration
\*---------------------------------------------------------------------------*/
class noReflection
:
public reflectionModel
{
public:
//- Runtime type information
TypeName("none");
// Constructors
//- Construct from components
noReflection(const dictionary& dict, const fvMesh& mesh);
//- Destructor
virtual ~noReflection();
// Member Functions
//- Return reflectivity from medium1 to medium2 and a incident angle.
virtual scalar rho
(
const scalar incidentAngle
) const;
//- Return reflected direction
virtual vector R(const vector& incident, const vector& n) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "error.H"
#include "reflectionModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(reflectionModel, 0);
defineRunTimeSelectionTable(reflectionModel, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::reflectionModel::reflectionModel
(
const dictionary&,
const fvMesh& mesh
)
:
mesh_(mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::radiation::reflectionModel::~reflectionModel()
{}
// ************************************************************************* //

View File

@ -0,0 +1,123 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::radiation::reflectionModel
Description
Base class for radiation scattering
\*---------------------------------------------------------------------------*/
#ifndef reflectionModel_H
#define reflectionModel_H
#include "IOdictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "volFields.H"
#include "Pair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class reflectionModel Declaration
\*---------------------------------------------------------------------------*/
class reflectionModel
{
protected:
// Protected data
//- Reference to the fvMesh
const fvMesh& mesh_;
public:
//- Runtime type information
TypeName("reflectionModel");
// Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
reflectionModel,
dictionary,
(
const dictionary& dict,
const fvMesh& mesh
),
(dict, mesh)
);
// Constructors
//- Construct from components
reflectionModel(const dictionary& dict, const fvMesh& mesh);
// Selector
static autoPtr<reflectionModel> New
(
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~reflectionModel();
// Member Functions
//- Return reflected direction
virtual vector R(const vector& incident, const vector& n) const = 0;
//- Return reflectivity from medium1 to medium2 and a incident angle.
virtual scalar rho
(
const scalar incidentAngle
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "error.H"
#include "reflectionModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::radiation::reflectionModel> Foam::radiation::
reflectionModel::
New
(
const dictionary& dict,
const fvMesh& mesh
)
{
const word modelType(dict.lookup("reflectionModel"));
Info<< "Selecting reflectionModel " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"reflectionModel::New(const dictionary&, const fvMesh&)"
) << "Unknown reflectionModel type "
<< modelType << nl << nl
<< "Valid reflectionModel types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<reflectionModel>(cstrIter()(dict, mesh));
}
// ************************************************************************* //

View File

@ -0,0 +1,404 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "InterfaceCompositionModel.H"
#include "phaseModel.H"
#include "phasePair.H"
#include "pureMixture.H"
#include "multiComponentMixture.H"
#include "rhoThermo.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
template<class ThermoType>
const typename Foam::multiComponentMixture<ThermoType>::thermoType&
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::getLocalThermo
(
const word& speciesName,
const multiComponentMixture<ThermoType>& globalThermo
) const
{
return
globalThermo.getLocalThermo
(
globalThermo.species()
[
speciesName
]
);
}
template<class Thermo, class OtherThermo>
template<class ThermoType>
const typename Foam::pureMixture<ThermoType>::thermoType&
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::getLocalThermo
(
const word& speciesName,
const pureMixture<ThermoType>& globalThermo
) const
{
return globalThermo.cellMixture(0);
}
template<class Thermo, class OtherThermo>
template<class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::getSpecieMassFraction
(
const word& speciesName,
const multiComponentMixture<ThermoType>& mixture
) const
{
const fvMesh& mesh = thermo_.p().mesh();
tmp<volScalarField> tY
(
new volScalarField
(
IOobject
(
"tY",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimless, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& Ys = tY.ref();
Ys = mixture.Y(speciesName);
return tY;
}
template<class Thermo, class OtherThermo>
template<class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::getSpecieMassFraction
(
const word& speciesName,
const pureMixture<ThermoType>& mixture
) const
{
const fvMesh& mesh = thermo_.p().mesh();
tmp<volScalarField> tY
(
new volScalarField
(
IOobject
(
"tY",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimless, 1),
zeroGradientFvPatchScalarField::typeName
)
);
return tY;
}
template<class Thermo, class OtherThermo>
template<class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::MwMixture
(
const pureMixture<ThermoType>& mixture
) const
{
const fvMesh& mesh = thermo_.p().mesh();
tmp<volScalarField> tM
(
new volScalarField
(
IOobject
(
"tM",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar
(
"Mw",
dimMass/dimMoles,
1e-3*mixture.cellMixture(0).W()
),
zeroGradientFvPatchScalarField::typeName
)
);
return tM;
}
template<class Thermo, class OtherThermo>
template<class ThermoType>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::MwMixture
(
const multiComponentMixture<ThermoType>& mixture
) const
{
return refCast<const basicSpecieMixture>(mixture).W();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::InterfaceCompositionModel
(
const dictionary& dict,
const phasePair& pair
)
:
interfaceCompositionModel(dict, pair),
thermo_
(
pair.phase1().mesh().lookupObject<Thermo>
(
IOobject::groupName
(
basicThermo::dictName,
pair.dispersed().name()
)
)
),
otherThermo_
(
pair.phase2().mesh().lookupObject<OtherThermo>
(
IOobject::groupName
(
basicThermo::dictName,
pair.continuous().name()
)
)
),
Le_("Le", dimless, dict.lookupOrDefault<scalar>("Le", 1.0))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::
~InterfaceCompositionModel()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::D
(
const word& speciesName
) const
{
const typename Thermo::thermoType& localThermo =
getLocalThermo
(
speciesName,
thermo_
);
const volScalarField& p(thermo_.p());
const volScalarField& T(thermo_.T());
tmp<volScalarField> tmpD
(
new volScalarField
(
IOobject
(
IOobject::groupName("D", pair_.name()),
p.time().timeName(),
p.mesh()
),
p.mesh(),
dimensionedScalar("zero", dimArea/dimTime, 0)
)
);
volScalarField& D = tmpD.ref();
forAll(p, cellI)
{
D[cellI] =
localThermo.alphah(p[cellI], T[cellI])
/localThermo.rho(p[cellI], T[cellI]);
}
D /= Le_;
D.correctBoundaryConditions();
return tmpD;
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::L
(
const word& speciesName,
const volScalarField& Tf
) const
{
const typename Thermo::thermoType& localThermo =
getLocalThermo
(
speciesName,
thermo_
);
const typename OtherThermo::thermoType& otherLocalThermo =
getLocalThermo
(
speciesName,
otherThermo_
);
const volScalarField& p(thermo_.p());
tmp<volScalarField> tmpL
(
new volScalarField
(
IOobject
(
IOobject::groupName("L", pair_.name()),
p.time().timeName(),
p.mesh()
),
p.mesh(),
dimensionedScalar("zero", dimEnergy/dimMass, 0),
zeroGradientFvPatchScalarField::typeName
)
);
volScalarField& L = tmpL.ref();
// localThermo (dispersed)(from)
// otherLocalThermo (continuous)(to)
// to - from
forAll(p, cellI)
{
L[cellI] = localThermo.Hc() - otherLocalThermo.Hc();
}
L.correctBoundaryConditions();
return tmpL;
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::HcSource
(
const word& speciesName
) const
{
const typename Thermo::thermoType& localThermo =
getLocalThermo
(
speciesName,
thermo_
);
const volScalarField& p(thermo_.p());
tmp<volScalarField> tmpL
(
new volScalarField
(
IOobject
(
IOobject::groupName("L", pair_.name()),
p.time().timeName(),
p.mesh()
),
p.mesh(),
dimensionedScalar("zero", dimEnergy/dimMass, 0)
)
);
volScalarField& Hc = tmpL.ref();
forAll(p, cellI)
{
Hc[cellI] = localThermo.Hc();
}
return tmpL;
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::dY
(
const word& speciesName,
const volScalarField& Tf
) const
{
NotImplemented;
return tmp<volScalarField>();
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::InterfaceCompositionModel<Thermo, OtherThermo>::Yf
(
const word& speciesName,
const volScalarField& Tf
) const
{
NotImplemented;
return tmp<volScalarField>();
}
// ************************************************************************* //

View File

@ -0,0 +1,291 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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/>.
Class
Foam::InterfaceCompositionModel
Description
Base class for interface composition models, templated on the two
thermodynamic models either side of the interface.
SourceFiles
InterfaceCompositionModel.C
\*---------------------------------------------------------------------------*/
#ifndef InterfaceCompositionModel_H
#define InterfaceCompositionModel_H
#include "interfaceCompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class phaseModel;
class phasePair;
template <class ThermoType> class pureMixture;
template <class ThermoType> class multiComponentMixture;
/*---------------------------------------------------------------------------*\
Class InterfaceCompositionModel Declaration
\*---------------------------------------------------------------------------*/
template<class Thermo, class OtherThermo>
class InterfaceCompositionModel
:
public interfaceCompositionModel
{
protected:
// Private data
//- Thermo (dispersed)(from)
const Thermo& thermo_;
//- Other Thermo (continuous)(to)
const OtherThermo& otherThermo_;
//- Lewis number
const dimensionedScalar Le_;
// Private member functions
//- Get a reference to the local thermo for a pure mixture
template<class ThermoType>
const typename pureMixture<ThermoType>::thermoType&
getLocalThermo
(
const word& speciesName,
const pureMixture<ThermoType>& globalThermo
) const;
//- Get a reference to the local thermo for a multi component mixture
template<class ThermoType>
const typename multiComponentMixture<ThermoType>::thermoType&
getLocalThermo
(
const word& speciesName,
const multiComponentMixture<ThermoType>& globalThermo
) const;
//- Return mass fraction for a pureMixture equal to one
template<class ThermoType>
tmp<volScalarField> getSpecieMassFraction
(
const word& speciesName,
const pureMixture<ThermoType>& thermo
) const;
//- Return mass fraction for speciesName
template<class ThermoType>
tmp<volScalarField> getSpecieMassFraction
(
const word& speciesName,
const multiComponentMixture<ThermoType>& thermo
) const;
//- Return moleculas weight of the mixture for pureMixture [Kg/mol]
template<class ThermoType>
tmp<volScalarField> MwMixture
(
const pureMixture<ThermoType>& thermo
) const;
//- Return moleculas weight of the mixture for multiComponentMixture
// [Kg/mol]
template<class ThermoType>
tmp<volScalarField> MwMixture
(
const multiComponentMixture<ThermoType>&
) const;
public:
// Constructors
//- Construct from components
InterfaceCompositionModel
(
const dictionary& dict,
const phasePair& pair
);
//- Destructor
~InterfaceCompositionModel();
// Member Functions
//- Mass fraction difference between the interface and the field
virtual tmp<volScalarField> dY
(
const word& speciesName,
const volScalarField& Tf
) const;
//- Reference mass fraction for specied based models
virtual tmp<volScalarField> Yf
(
const word& speciesName,
const volScalarField& Tf
) const;
//- Mass diffusivity of the local thermo
virtual tmp<volScalarField> D
(
const word& speciesName
) const;
//- Latent heat (to - from)(thermo - otherThermo)
virtual tmp<volScalarField> L
(
const word& speciesName,
const volScalarField& Tf
) const;
//- Heat of formation (Hc) from source phase (thermo)
virtual tmp<volScalarField> HcSource
(
const word& speciesName
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Instantiation for multi-component (dispersed) to single-component (continuous)
#define makeInterfaceDispSpecieMixtureType(Type, Thermo, Comp, Mix, Phys, OtherThermo, OtherComp, OtherMix, OtherPhys)\
\
typedef Thermo<Comp, SpecieMixture<Mix<Phys> > > \
Type##Thermo##Comp##Mix##Phys; \
\
typedef OtherThermo<OtherComp, OtherMix<OtherPhys> > \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys; \
\
\
addInterfaceCompositionToRunTimeSelectionTable \
( \
Type, \
Type##Thermo##Comp##Mix##Phys, \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys \
)
// Instantiation for single-component (dispersed) to multi-component (continuous)
#define makeInterfaceContSpecieMixtureType(Type, Thermo, Comp, Mix, Phys, OtherThermo, OtherComp, OtherMix, OtherPhys)\
\
typedef Thermo<Comp, Mix<Phys> > \
Type##Thermo##Comp##Mix##Phys; \
\
typedef OtherThermo<OtherComp, SpecieMixture<OtherMix<OtherPhys> > > \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys; \
\
\
addInterfaceCompositionToRunTimeSelectionTable \
( \
Type, \
Type##Thermo##Comp##Mix##Phys, \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys \
)
// Instantiation for single-component-single-component pairs
#define makeInterfacePureType(Type, Thermo, Comp, Mix, Phys, OtherThermo, OtherComp, OtherMix, OtherPhys)\
\
typedef Thermo<Comp, Mix<Phys> > \
Type##Thermo##Comp##Mix##Phys; \
\
typedef OtherThermo<OtherComp, OtherMix<OtherPhys> > \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys; \
\
\
addInterfaceCompositionToRunTimeSelectionTable \
( \
Type, \
Type##Thermo##Comp##Mix##Phys, \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys \
)
// Instantiation for multi-component-multi-component pairs
#define makeSpecieInterfaceSpecieMixtures(Type, Thermo, Comp, Mix, Phys, OtherThermo, OtherComp, OtherMix, OtherPhys)\
\
typedef Thermo<Comp, SpecieMixture<Mix<Phys> > > \
Type##Thermo##Comp##Mix##Phys; \
\
typedef OtherThermo<OtherComp, SpecieMixture<OtherMix<OtherPhys> > > \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys; \
\
addInterfaceCompositionToRunTimeSelectionTable \
( \
Type, \
Type##Thermo##Comp##Mix##Phys, \
Type##Other##OtherThermo##OtherComp##OtherMix##OtherPhys \
)
// Addition to the run-time selection table
#define addInterfaceCompositionToRunTimeSelectionTable(Type, Thermo, OtherThermo)\
\
typedef Type<Thermo, OtherThermo> \
Type##Thermo##OtherThermo; \
\
defineTemplateTypeNameAndDebugWithName \
( \
Type##Thermo##OtherThermo, \
( \
word(Type##Thermo##OtherThermo::typeName_()) + "<" \
+ word(Thermo::typeName) + "," \
+ word(OtherThermo::typeName) + ">" \
).c_str(), \
0 \
); \
\
addToRunTimeSelectionTable \
( \
interfaceCompositionModel, \
Type##Thermo##OtherThermo, \
dictionary \
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "InterfaceCompositionModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,332 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "thermoPhysicsTypes.H"
#include "rhoConst.H"
#include "perfectFluid.H"
#include "Boussinesq.H"
#include "pureMixture.H"
#include "multiComponentMixture.H"
#include "reactingMixture.H"
#include "SpecieMixture.H"
#include "rhoThermo.H"
#include "rhoReactionThermo.H"
#include "heRhoThermo.H"
#include "solidThermo.H"
#include "heSolidThermo.H"
#include "solidThermoPhysicsTypes.H"
#include "kineticGasEvaporation.H"
#include "constantMelting.H"
#include "constantSolidification.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef
constTransport
<
species::thermo
<
hConstThermo
<
rhoConst<specie>
>,
sensibleEnthalpy
>
> constFluidHThermoPhysics;
typedef
constTransport
<
species::thermo
<
hConstThermo
<
Boussinesq<specie>
>,
sensibleEnthalpy
>
> BoussinesqFluidEThermoPhysics;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
using namespace meltingEvaporationModels;
//NOTE: First thermo (dispersed) and second otherThermo (continous)
// in the phaseProperties: (dispersed to continous)
// kineticGasEvaporation model definitions
/*
// multi-component dispersed phase and a pure continous phase
makeInterfaceDispSpecieMixtureType
(
kineticGasEvaporation,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
*/
// pure dispersed phase to a multi-component continous phase
makeInterfaceContSpecieMixtureType
(
kineticGasEvaporation,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics
);
// pure dispersed phase and pure continous phase with incompressible gas
makeInterfacePureType
(
kineticGasEvaporation,
heRhoThermo,
rhoThermo,
pureMixture,
constIncompressibleGasHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
// pure dispersed phase and pure continous phase with rhoConst gas
makeInterfacePureType
(
kineticGasEvaporation,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
// constantMelting model definitions
// pure dispersed phase and a pure continous phase
makeInterfacePureType
(
constantMelting,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
makeInterfacePureType
(
constantMelting,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
BoussinesqFluidEThermoPhysics
);
makeInterfacePureType
(
constantMelting,
heSolidThermo,
solidThermo,
pureMixture,
hConstSolidThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
BoussinesqFluidEThermoPhysics
);
makeInterfacePureType
(
constantMelting,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constIncompressibleGasHThermoPhysics
);
makeInterfaceContSpecieMixtureType
(
constantMelting,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics
);
/*
makeInterfaceDispSpecieMixtureType
(
constantMelting,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
*/
// constantSolidification model definitions
// pure dispersed phase and a pure continous phase
makeInterfacePureType
(
constantSolidification,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
makeInterfacePureType
(
constantSolidification,
heRhoThermo,
rhoThermo,
pureMixture,
BoussinesqFluidEThermoPhysics,
heSolidThermo,
solidThermo,
pureMixture,
hConstSolidThermoPhysics
);
/*
// saturatedEvaporation model definitions
// multi-component dispersed phase and a pure continous phase
makeInterfaceDispSpecieMixtureType
(
saturatedEvaporation,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics
);
// pure dispersed phase and a multi-component continous phase
makeInterfaceContSpecieMixtureType
(
saturatedEvaporation,
heRhoThermo,
rhoThermo,
pureMixture,
constFluidHThermoPhysics,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics
);
// multi-component dispersed phase and a multi-componen continous phase
makeSpecieInterfaceSpecieMixtures
(
saturatedEvaporation,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics,
heRhoThermo,
rhoReactionThermo,
multiComponentMixture,
constIncompressibleGasHThermoPhysics
);
// pure dispersed phase and pure continous phase
makeInterfacePureType
(
saturatedEvaporation,
heRhoThermo,
rhoThermo,
pureMixture,
constIncompressibleGasHThermoPhysics,
heRhoThermo,
rhoThermo,
pureMixture,
constIncompressibleGasHThermoPhysics
);
*/
}
// ************************************************************************* //

View File

@ -0,0 +1,10 @@
interfaceCompositionModel/interfaceCompositionModel.C
interfaceCompositionModel/newInterfaceCompositionModel.C
InterfaceCompositionModel/InterfaceCompositionModels.C
saturationPressureModels/saturationPressureModel/saturationPressureModel.C
saturationPressureModels/saturationPressureModel/newSaturationPressureModel.C
saturationPressureModels/ClausiusClapeyron/ClausiusClapeyron.C
LIB = $(FOAM_LIBBIN)/libmeltingEvaporationModels

View File

@ -0,0 +1,15 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I../phasesSystem/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lsolidThermo \
-lsolidSpecie

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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 "constantMelting.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::meltingEvaporationModels::constantMelting<Thermo, OtherThermo>::
constantMelting
(
const dictionary& dict,
const phasePair& pair
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", inv(dimTime)*inv(dimTemperature), dict.lookup("C")),
Tactivate_("Tactivate", dimTemperature, dict.lookup("Tactivate"))
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::constantMelting<Thermo, OtherThermo>
::Kexp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
return
(
C_
* limitedDispersed
* this->pair().dispersed().rho()
* (field.oldTime() - Tactivate_)
* pos(field.oldTime() - Tactivate_)
);
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::constantMelting<Thermo, OtherThermo>
::Kimp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
return
(
C_
* limitedDispersed
* this->pair().dispersed().rho()
* pos(field.oldTime() - Tactivate_)
);
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
const Foam::dimensionedScalar&
Foam::meltingEvaporationModels::constantMelting<Thermo, OtherThermo>
::Tactivate() const
{
return Tactivate_;
}
template<class Thermo, class OtherThermo>
Foam::label
Foam::meltingEvaporationModels::constantMelting<Thermo, OtherThermo>
::dSdVariable()
{
return label(1);
}
// ************************************************************************* //

View File

@ -0,0 +1,133 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd
\\/ 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/>.
Class
Foam::phaseChangeTwoPhaseMixtures::constantMelting
Description
General mass transfer model based on temperature. It follows:
Ce*alpha*rho*(fieldValue - Tactivate)
or
Ci*alpha*rho*
SourceFiles
constantMelting.C
\*---------------------------------------------------------------------------*/
#ifndef constantMelting_H
#define constantMelting_H
#include "InterfaceCompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
namespace Foam
{
namespace meltingEvaporationModels
{
/*---------------------------------------------------------------------------*\
Class constantMelting
\*---------------------------------------------------------------------------*/
template<class Thermo, class OtherThermo>
class constantMelting
:
public InterfaceCompositionModel<Thermo, OtherThermo>
{
// Private data
//- Condensation coefficient [1/s/K]
dimensionedScalar C_;
//- Phase transition temperature
const dimensionedScalar Tactivate_;
public:
//- Runtime type information
TypeName("constantMelting");
// Constructors
//- Construct from components
constantMelting
(
const dictionary& dict,
const phasePair& pair
);
//- Destructor
virtual ~constantMelting()
{}
// Member Functions
//- Explicit mass transfer coefficient
virtual tmp<volScalarField> Kexp
(
label variable,
const volScalarField& field
) const;
//- Semi implicit species mass transfer coefficient
virtual tmp<volScalarField> Kimp
(
label variable,
const volScalarField& field
) const;
//- Return T transition between phases
virtual const dimensionedScalar& Tactivate() const;
//- Derivate sign of the source term:
// d(Sk-i)/d(variable) > 0 or d(Si-k)/d(variable) < 0
virtual label dSdVariable();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace meltingEvaporationModel
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "constantMelting.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "constantSolidification.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::meltingEvaporationModels::constantSolidification<Thermo, OtherThermo>
::constantSolidification
(
const dictionary& dict,
const phasePair& pair
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", inv(dimTime)*inv(dimTemperature), dict.lookup("C")),
Tactivate_("Tactivate", dimTemperature, dict.lookup("Tactivate"))
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::constantSolidification<Thermo, OtherThermo>
::Kexp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
return
(
C_
* limitedDispersed
* this->pair().dispersed().rho()
* (Tactivate_ - field.oldTime())
* pos(Tactivate_ - field.oldTime())
);
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::constantSolidification<Thermo, OtherThermo>
::Kimp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
return
(
C_
*limitedDispersed
*this->pair().dispersed().rho()
*pos(Tactivate_ - field.oldTime())
);
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
const Foam::dimensionedScalar&
Foam::meltingEvaporationModels::constantSolidification<Thermo, OtherThermo>
::Tactivate() const
{
return Tactivate_;
}
template<class Thermo, class OtherThermo>
Foam::label
Foam::meltingEvaporationModels::constantSolidification<Thermo, OtherThermo>
::dSdVariable()
{
return label(-1);
}
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phaseChangeTwoPhaseMixtures::constantSolidification
Description
Solidification model. Simple model driven by temperature as:
mSol = C*rho*alpha*(T - Tsolification)
SourceFiles
constantSolidification.C
\*---------------------------------------------------------------------------*/
#ifndef constantSolidification_H
#define constantSolidification_H
#include "InterfaceCompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
namespace Foam
{
namespace meltingEvaporationModels
{
/*---------------------------------------------------------------------------*\
Class constantSolidification
\*---------------------------------------------------------------------------*/
template<class Thermo, class OtherThermo>
class constantSolidification
:
public InterfaceCompositionModel<Thermo, OtherThermo>
{
// Private data
//- Condensation coefficient [1/s/K]
dimensionedScalar C_;
//- Phase transition temperature
const dimensionedScalar Tactivate_;
public:
//- Runtime type information
TypeName("constantSolidification");
// Constructors
//- Construct from components
constantSolidification
(
const dictionary& dict,
const phasePair& pair
);
//- Destructor
virtual ~constantSolidification()
{}
// Member Functions
//- Explicit mass transfer coefficient
virtual tmp<volScalarField> Kexp
(
label variable,
const volScalarField& field
) const;
//- Semi implicit species mass transfer coefficient
virtual tmp<volScalarField> Kimp
(
label variable,
const volScalarField& field
) const;
//- Return T transition between phases
virtual const dimensionedScalar& Tactivate() const;
//- Derivate sign of the source term:
// d(Sk-i)/d(variable) > 0 or d(Si-k)/d(variable) < 0
virtual label dSdVariable();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace meltingEvaporationModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "constantSolidification.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "interfaceCompositionModel.H"
#include "phaseModel.H"
#include "phasePair.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interfaceCompositionModel, 0);
defineRunTimeSelectionTable(interfaceCompositionModel, dictionary);
}
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::interfaceCompositionModel::modelVariable,
3
>::names[] =
{
"temperature",
"pressure",
"massFraction"
};
} // End namespace Foam
const Foam::NamedEnum
<
Foam::interfaceCompositionModel::modelVariable,
3
> Foam::interfaceCompositionModel::modelVariableNames;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::interfaceCompositionModel::interfaceCompositionModel
(
const dictionary& dict,
const phasePair& pair
)
:
modelVariable_(modelVariableNames.read(dict.lookup("variable"))),
semiImplicit_(readBool(dict.lookup("semiImplicit"))),
pair_(pair),
speciesNames_(dict.lookup("species")),
mesh_(pair_.dispersed().mesh())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::interfaceCompositionModel::~interfaceCompositionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::hashedWordList& Foam::interfaceCompositionModel::species() const
{
return speciesNames_;
}
const Foam::phasePair& Foam::interfaceCompositionModel::pair() const
{
return pair_;
}
bool Foam::interfaceCompositionModel::transports
(
word& speciesName
) const
{
if (this->speciesNames_.contains(speciesName))
{
return true;
}
return false;
}
const Foam::word Foam::interfaceCompositionModel::variable() const
{
return modelVariableNames[modelVariable_];
}
bool Foam::interfaceCompositionModel::semiImplicit() const
{
return semiImplicit_;
}
Foam::tmp<Foam::volScalarField> Foam::interfaceCompositionModel::KexpEnergy
(
label modelVariable,
const volScalarField& field
)
const
{
NotImplemented;
return tmp<volScalarField>();
}
// ************************************************************************* //

View File

@ -0,0 +1,232 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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/>.
Class
Foam::interfaceCompositionModel
Description
Generic base class for interface composition models. These models describe
the composition in phase 1 of the supplied pair at the interface with phase
2.
SourceFiles
interfaceCompositionModel.C
\*---------------------------------------------------------------------------*/
#ifndef interfaceCompositionModel_H
#define interfaceCompositionModel_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "volFields.H"
#include "dictionary.H"
#include "hashedWordList.H"
#include "runTimeSelectionTables.H"
namespace Foam
{
class phaseModel;
class phasePair;
/*---------------------------------------------------------------------------*\
Class interfaceCompositionModel Declaration
\*---------------------------------------------------------------------------*/
class interfaceCompositionModel
{
public:
// Public type
//- Enumeration for variable based mass transfer models
enum modelVariable
{
T, /* temperature based */
P, /* pressure based */
Y /* mass fraction based */
};
static const NamedEnum<modelVariable, 3> modelVariableNames;
//- Enumeration for model variables
modelVariable modelVariable_;
//- Semi-Implicit or Explicit model
bool semiImplicit_;
protected:
// Protected data
//- Phase pair
const phasePair& pair_;
//- Names of the transferring species
const hashedWordList speciesNames_;
//- Reference to mesh
const fvMesh& mesh_;
public:
//- Runtime type information
TypeName("interfaceCompositionModel");
// Declare runtime construction
declareRunTimeSelectionTable
(
autoPtr,
interfaceCompositionModel,
dictionary,
(
const dictionary& dict,
const phasePair& pair
),
(dict, pair)
);
// Constructors
//- Construct from a dictionary and a phase pair
interfaceCompositionModel
(
const dictionary& dict,
const phasePair& pair
);
//- Destructor
virtual ~interfaceCompositionModel();
// Selectors
static autoPtr<interfaceCompositionModel> New
(
const dictionary& dict,
const phasePair& pair
);
// Member Functions
//- Return the transferring species names
const hashedWordList& species() const;
//- Return pair
const phasePair& pair() const;
//- Returns whether the species is transported by the model and
// provides the name of the diffused species
bool transports(word& speciesName) const;
//- Interface mass fraction
virtual tmp<volScalarField> Yf
(
const word& speciesName,
const volScalarField& Tf
) const = 0;
//- Mass fraction difference between the interface and the field
virtual tmp<volScalarField> dY
(
const word& speciesName,
const volScalarField& Tf
) const = 0;
//- Mass diffusivity
virtual tmp<volScalarField> D
(
const word& speciesName
) const = 0;
//- Latent heat (delta Hc)
virtual tmp<volScalarField> L
(
const word& speciesName,
const volScalarField& Tf
) const = 0;
//- Heat of formation (Hc) from source phase
virtual tmp<volScalarField> HcSource
(
const word& speciesName
) const = 0;
//- Explicit mass transfer coefficient
virtual tmp<volScalarField> Kexp
(
label modelVariable,
const volScalarField& field
) const = 0;
//- Implicit mass transfer coefficient of the shape
// Kimp*(variable - refValue)
virtual tmp<volScalarField> Kimp
(
label modelVariable,
const volScalarField& field
) const = 0;
//- Explicit mass transfer for energy
virtual tmp<volScalarField> KexpEnergy
(
label modelVariable,
const volScalarField& field
) const;
//- Reference value
virtual const dimensionedScalar& Tactivate() const = 0;
//- Returns the variable on which the model is based
const word variable() const;
//- Returns type of model. false is fully Explicit
// true is treated semiImplicit as :
// Sk-i = Kimp()(variable - Tactivate) for positive k to i
// Si-k = Kimp()(Tactivate - variable) for positive i to k
bool semiImplicit() const;
//- Derivate sign of the source term:
// d(Sk-i)/d(variable) > 0 or d(Si-k)/d(variable) < 0
virtual label dSdVariable() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,69 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 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 "interfaceCompositionModel.H"
#include "phasePair.H"
#include "rhoThermo.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::interfaceCompositionModel>
Foam::interfaceCompositionModel::New
(
const dictionary& dict,
const phasePair& pair
)
{
word interfaceCompositionModelType
(
word(dict.lookup("type"))
+ "<"
+ pair.phase1().thermo().type()
+ ","
+ pair.phase2().thermo().type()
+ ">"
);
Info<< "Selecting interfaceCompositionModel for "
<< pair << ": " << interfaceCompositionModelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(interfaceCompositionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown interfaceCompositionModelType type "
<< interfaceCompositionModelType << endl << endl
<< "Valid interfaceCompositionModel types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(dict, pair);
}
// ************************************************************************* //

View File

@ -0,0 +1,419 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "kineticGasEvaporation.H"
#include "constants.H"
#include "fvcGrad.H"
#include "fvcDiv.H"
#include "surfaceInterpolate.H"
#include "fvcReconstruct.H"
#include "fvm.H"
#include "zeroGradientFvPatchFields.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
::kineticGasEvaporation
(
const dictionary& dict,
const phasePair& pair
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", dimless, dict.lookup("C")),
Tactivate_
(
"Tactivate",
dimTemperature,
dict.lookup("Tactivate")
),
Mv_
(
"Mv",
dimMass/dimMoles,
dict.lookupOrDefault<scalar>("Mv", -1)
),
saturationPressureModel_
(
saturationPressureModel::New
(
dict.subDict("saturationPressure")
)
),
phi0_
(
IOobject
(
"phi0",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
this->mesh_,
dimensionedScalar("zero", dimMass/dimTime/dimVolume, 0),
zeroGradientFvPatchScalarField::typeName
),
sPhi_
(
IOobject
(
"sPhi",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
this->mesh_,
dimensionedScalar("zero", dimMass/dimTime/dimVolume, 0),
zeroGradientFvPatchScalarField::typeName
),
D_
(
"D",
dimArea/dimTime,
dict.lookupOrDefault<scalar>("D", 1)
)
{
word speciesName = this->species()[0];
// Get the continuous thermo
const typename OtherThermo::thermoType& localThermo =
this->getLocalThermo
(
speciesName,
this->otherThermo_
);
Mv_.value() = localThermo.W();
if (Mv_.value() == -1)
{
FatalErrorIn
(
"meltingEvaporationModels::"
"kineticGasEvaporation<Thermo, OtherThermo>::"
"kineticGasEvaporation"
"("
"const dictionary& dict,"
"const phasePair& pair"
")"
)
<< " Please provide the molar weight (Mv) of vapour [g/mol] "
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
::Kexp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
volScalarField limitedContinous
(
min(max(this->pair().continuous(), scalar(0)), scalar(1))
);
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
const fvMesh& mesh = this->mesh_;
const volScalarField& T = mesh.lookupObject<volScalarField>("T");
//const volScalarField& p = mesh.lookupObject<volScalarField>("p");
const dimensionedScalar HerztKnudsConst
(
sqrt
(
Mv_
/2.0
/constant::physicoChemical::R
/mathematical::pi
/pow3(Tactivate_)
)
);
/*
volScalarField pSat
(
"pSat",
saturationPressureModel_->pSat(T)
);
*/
/*
volScalarField rhoMean
(
this->pair().continuous().rho()*this->pair().dispersed().rho()
/ (this->pair().dispersed().rho() - this->pair().continuous().rho())
);
*/
word species(this->species()[0]);
tmp<volScalarField> L = mag(this->L(species, field));
DebugVar(Mv_);
//dimensionedScalar psat("psat", dimPressure, 1e5);
//scalarField maxAreaDen(sqrt(3.0)*pow(mesh.V(), -1.0/3.0));
//scalarField avergageDelta(pow(mesh.V(), 1.0/3.0));
/*
volScalarField areaDensity
(
IOobject
(
"areaDensity",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimArea/dimVolume, 0.0),
zeroGradientFvPatchScalarField::typeName
);
*/
volScalarField areaDensity
(
"areaDensity",
mag(fvc::grad(limitedDispersed))
);
/*
volScalarField tempInterFace
(
"tempInterFace",
pos(0.55 - limitedDispersed) * pos(limitedDispersed - 0.45)
* pos(limitedContinous - 0.45) * pos(0.55 - limitedContinous)
* T
);
*/
dimensionedScalar dMgc = max(areaDensity);
volScalarField Tave
(
"Tave", T*pos(areaDensity - 0.1*dMgc)
);
const volScalarField massFluxEvap
(
"massFluxEvap",
2*C_/(2 - C_)
* HerztKnudsConst
* L()
* this->pair().continuous().rho()
* max
(
(Tave - Tactivate_),
dimensionedScalar("T0", dimTemperature, 0.0)
)
);
//scalar alphaC(0.9);
//scalar alphaCMax(0.9);
//.weightedAverage(mesh.V());
/*
volScalarField nearInterFace
(
"nearInterFace",
pos(areaDensity - 0.1*dMgc)
* pos(alphaC - limitedDispersed)
* pos(limitedDispersed - (1 - alphaC))
* pos(limitedContinous - (1 - alphaC))
* pos(alphaC - limitedContinous)
);
volScalarField farDispersedInterFace
(
pos(limitedDispersed - alphaC)
);
volScalarField farContinousInterFace
(
pos(limitedContinous - alphaC)
);
volScalarField farInterFace
(
"farInterFace", farDispersedInterFace + farContinousInterFace
);
*/
dimensionedScalar mIntDotPhi0
(
"mIntDotPhi0",
gSum((pos(areaDensity - 0.1*dMgc)*areaDensity*mesh.V())())
/gSum
(
(pos(areaDensity - 0.1*dMgc)*limitedDispersed*areaDensity*mesh.V())()
)
);
DebugVar(mIntDotPhi0);
// Local density rate (kg/m3/s)
phi0_ = massFluxEvap*areaDensity; //mIntDotPhi0*limitedDispersed
dimensionedScalar mIntDot("mIntDot", gSum((phi0_*mesh.V())()));
DebugVar(mIntDot);
volScalarField sPhi("sPhi", phi0_);
phi0_ = 0.0*phi0_;
fvScalarMatrix sPhiEq
(
fvm::ddt(sPhi)
- fvm::laplacian(D_, sPhi)
);
sPhiEq.relax();
sPhiEq.solve();
// Liquid normalization
const dimensionedScalar Nl
(
gSum((sPhi*mesh.V())())
/(
gSum
(
(sPhi*mesh.V()*limitedDispersed)()
)
+ dimensionedScalar("SMALL", dimless, VSMALL)
)
);
// Vapour normalization
const dimensionedScalar Nv
(
gSum((sPhi*mesh.V())())
/(
gSum
(
(sPhi*mesh.V()*limitedContinous)()
)
+ dimensionedScalar("SMALL", dimless, VSMALL)
)
);
// Spread density source
sPhi_ =
0.5*
(
limitedContinous*Nv*sPhi
+ limitedDispersed*Nl*sPhi
);
dimensionedScalar msPhiIntDot("msPhiIntDot", gSum((sPhi_*mesh.V())()));
DebugVar(msPhiIntDot);
if (this->pair().dispersed().mesh().time().outputTime())
{
massFluxEvap.write();
areaDensity.write();
Tave.write();
}
return
(
0.5*
(
limitedContinous*Nv*sPhi
+ limitedDispersed*Nl*sPhi
)
);
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
::Kimp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
return tmp<volScalarField> ();
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
const Foam::dimensionedScalar&
Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
::Tactivate() const
{
return Tactivate_;
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
::KexpEnergy
(
label modelVariable,
const volScalarField& field
)
const
{
return dimensionedScalar("one", dimless, 1.0)*phi0_;
}
template<class Thermo, class OtherThermo>
Foam::label
Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
::dSdVariable()
{
return label(1);
}
// ************************************************************************* //

View File

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phaseChangeTwoPhaseMixtures::kineticGasEvaporation
Description
kineticGasEvaporation evaporation model.
SourceFiles
kineticGasEvaporation.C
\*---------------------------------------------------------------------------*/
#ifndef kineticGasEvaporation_H
#define kineticGasEvaporation_H
#include "InterfaceCompositionModel.H"
#include "saturationPressureModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
namespace Foam
{
class phasePair;
namespace meltingEvaporationModels
{
/*---------------------------------------------------------------------------*\
Class kineticGasEvaporation
\*---------------------------------------------------------------------------*/
template<class Thermo, class OtherThermo>
class kineticGasEvaporation
:
public InterfaceCompositionModel<Thermo, OtherThermo>
{
// Private data
//- Evaporation coefficient
dimensionedScalar C_;
//- Activation temperature
const dimensionedScalar Tactivate_;
//- Molar weight of the vapour in the continous phase
dimensionedScalar Mv_;
//- Pointer to saturation pressure model
autoPtr<saturationPressureModel> saturationPressureModel_;
//- Source
mutable volScalarField phi0_;
//- Spread source
mutable volScalarField sPhi_;
//- Diffusivity for source term
dimensionedScalar D_;
// Private Member Functions
//- Constant of propotionality between partial pressure and mass
// fraction
tmp<volScalarField> wRatio() const;
public:
//- Runtime type information
TypeName("kineticGasEvaporation");
// Constructors
//- Construct from components
kineticGasEvaporation
(
const dictionary& dict,
const phasePair& pair
);
//- Destructor
virtual ~kineticGasEvaporation()
{}
// Member Functions
//- Explicit mass transfer coefficient
virtual tmp<volScalarField> Kexp
(
label variable,
const volScalarField& field
) const;
//- Semi implicit species mass transfer coefficient
virtual tmp<volScalarField> Kimp
(
label variable,
const volScalarField& field
) const;
//- Return Tref
virtual const dimensionedScalar& Tactivate() const;
//- Explicit mass transfer for energy
virtual tmp<volScalarField> KexpEnergy
(
label modelVariable,
const volScalarField& field
) const;
//- Derivate sign of the source term:
// d(Sk-i)/d(variable) > 0 or d(Si-k)/d(variable) < 0
virtual label dSdVariable();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace meltingEvaporationModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "kineticGasEvaporation.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,259 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "saturatedEvaporation.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::meltingEvaporationModels::saturatedEvaporation<Thermo, OtherThermo>::
saturatedEvaporation
(
const dictionary& dict,
const phasePair& pair
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", inv(dimTime), dict.lookup("C")),
Tactivate_("Tactivate", dimTemperature, dict.lookup("Tactivate")),
saturationPressureModel_
(
saturationPressureModel::New
(
dict.subDict("saturationPressure")
)
)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField> Foam::meltingEvaporationModels::
saturatedEvaporation<Thermo, OtherThermo>::Yf
(
const word& speciesName,
const volScalarField& Tf
) const
{
const fvMesh& mesh = this->pair().dispersed().mesh();
tmp<volScalarField> twRatio
(
new volScalarField
(
IOobject
(
"wRatio",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("wRatio", dimless, 1)
)
);
volScalarField& wRatio = twRatio();
// Get the continuous thermo
const typename OtherThermo::thermoType& continuousThermo =
this->getLocalThermo
(
speciesName,
this->otherThermo_
);
// // Get the dispersed thermo
// const typename Thermo::thermoType& dispersedThermo =
// this->getLocalThermo
// (
// speciesName,
// this->thermo_
// );
// If dispersed phase (liquid) is multicomponent
{
wRatio =
this->MwMixture(this->thermo_)
* this->getSpecieMassFraction(speciesName, this->thermo_)
/ this->MwMixture(this->thermo_);
}
// If continuous phase (vapour) is multicomponent
{
wRatio *=
continuousThermo.W()
/ this->MwMixture(this->otherThermo_);
}
const volScalarField& p = this->pair().dispersed().thermo().p();
volScalarField Yf
(
"Yf",
wRatio*saturationPressureModel_->pSat(Tf)/p
);
volScalarField pSat
(
"pSat",
saturationPressureModel_->pSat(Tf)
);
if (this->pair().dispersed().mesh().time().outputTime())
{
Yf.write();
pSat.write();
}
return wRatio*saturationPressureModel_->pSat(Tf)/p;
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::saturatedEvaporation<Thermo, OtherThermo>
::Kexp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
volScalarField limitedContinous
(
min(max(this->pair().continuous(), scalar(0)), scalar(1))
);
volScalarField nearInterFace
(
"nearInterFace",
pos(limitedDispersed - 0.1)*pos(0.9 - limitedDispersed)
*pos(limitedContinous - 0.1)*pos(0.9 - limitedContinous)
);
return
(
C_
*nearInterFace
*limitedDispersed
*pos(field.oldTime() - Tactivate_)
*this->pair().dispersed().rho()
);
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
Foam::tmp<Foam::volScalarField>
Foam::meltingEvaporationModels::saturatedEvaporation<Thermo, OtherThermo>
::Kimp(label variable, const volScalarField& field) const
{
if (this->modelVariable_ == variable)
{
/*
volScalarField limitedDispersed
(
min(max(this->pair().dispersed(), scalar(0)), scalar(1))
);
volScalarField limitedContinous
(
min(max(this->pair().continuous(), scalar(0)), scalar(1))
);
volScalarField nearInterFace
(
"nearInterFace",
pos(limitedDispersed - 0.1)*pos(0.9 - limitedDispersed)
*pos(limitedContinous - 0.1)*pos(0.9 - limitedContinous)
);
scalarField maxAreaDen(sqrt(3.0)*pow(mesh.V(), -1.0/3.0));
volScalarField areaDensity
(
IOobject
(
"areaDensity",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", dimArea/dimVolume, 0.0),
zeroGradientFvPatchScalarField::typeName
);
forAll (limitedDispersed, i)
{
if (limitedDispersed[i] < 0.5)
{
areaDensity[i] = 2.0*limitedDispersed[i]*maxAreaDen[i];
}
else
{
areaDensity[i] = 2.0*(1.0 - limitedDispersed[i])*maxAreaDen[i];
}
}
areaDensity.correctBoundaryConditions();
return
(
C_
*nearInterFace
*limitedDispersed
*areaDensity
*pos(field.oldTime() - Tactivate_)
);
*/
return tmp<volScalarField> ();
}
else
{
return tmp<volScalarField> ();
}
}
template<class Thermo, class OtherThermo>
const Foam::dimensionedScalar&
Foam::meltingEvaporationModels::saturatedEvaporation<Thermo, OtherThermo>
::Tactivate() const
{
return Tactivate_;
}
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phaseChangeTwoPhaseMixtures::saturatedEvaporation
Description
Evaporation model based on the Saturated species concentration at the
interface.
mEvap = C*rho*D*(Ysat - Yi)
SourceFiles
saturatedEvaporation.C
\*---------------------------------------------------------------------------*/
#ifndef saturatedEvaporation_H
#define saturatedEvaporation_H
#include "saturationPressureModel.H"
#include "InterfaceCompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
namespace Foam
{
namespace meltingEvaporationModels
{
/*---------------------------------------------------------------------------*\
Class saturatedEvaporation
\*---------------------------------------------------------------------------*/
template<class Thermo, class OtherThermo>
class saturatedEvaporation
:
public InterfaceCompositionModel<Thermo, OtherThermo>
{
// Private data
//- Model coefficient
dimensionedScalar C_;
//- Vaporization minimum temperature
const dimensionedScalar Tactivate_;
//- Saturated species name in both phases
word saturatedName_;
//- Saturated species index in continous phase (receiving mass)
label continuousSaturatedIndex_;
//- Saturated species index in dispersed phase (giving mass)
label dispersedSaturatedIndex_;
//- Saturation pressure model
autoPtr<saturationPressureModel> saturationPressureModel_;
// Private Member Functions
//- Constant of propotionality between partial pressure and mass
// fraction
tmp<volScalarField> wRatio() const;
public:
//- Runtime type information
TypeName("saturatedEvaporation");
// Constructors
//- Construct from components
saturatedEvaporation(const dictionary& dict, const phasePair& pair);
//- Destructor
virtual ~saturatedEvaporation()
{}
// Member Functions
//- Explicit mass transfer coefficient
virtual tmp<volScalarField> Kexp
(
label variable,
const volScalarField& field
) const;
//- Semi implicit species mass transfer coefficient
virtual tmp<volScalarField> Kimp
(
label variable,
const volScalarField& field
) const;
//- Interface mass fraction
virtual tmp<volScalarField> Yf
(
const word& speciesName,
const volScalarField& Tf
) const;
//- Return T transition between phases
virtual const dimensionedScalar& Tactivate() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace meltingEvaporationModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "saturatedEvaporation.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "ClausiusClapeyron.H"
#include "addToRunTimeSelectionTable.H"
#include "physicoChemicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace saturationPressureModels
{
defineTypeNameAndDebug(ClausiusClapeyron, 0);
addToRunTimeSelectionTable
(
saturationPressureModel,
ClausiusClapeyron,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::saturationPressureModels::ClausiusClapeyron::ClausiusClapeyron
(
const dictionary& dict
)
:
saturationPressureModel(),
p0_("p0", dimPressure, dict.lookup("p0")),
Tb_("Tb", dimTemperature, dict.lookup("Tb")),
dHvm_
(
"dHvm",
dimMass*sqr(dimLength)/sqr(dimTime)/dimMoles ,
dict.lookup("dHvm")
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::saturationPressureModels::ClausiusClapeyron::~ClausiusClapeyron()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::saturationPressureModels::ClausiusClapeyron::pSat
(
const volScalarField& T
) const
{
volScalarField invTc(1.0/Tb_ - 1.0/T);
return (p0_*exp(dHvm_*invTc/constant::physicoChemical::R));
}
Foam::tmp<Foam::volScalarField>
Foam::saturationPressureModels::ClausiusClapeyron::pSatPrime
(
const volScalarField& T
) const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"pSatPrime",
T.mesh().time().timeName(),
T.mesh()
),
T.mesh(),
dimensionedScalar("0", dimless, 0)
)
);
}
Foam::tmp<Foam::volScalarField>
Foam::saturationPressureModels::ClausiusClapeyron::lnPSat
(
const volScalarField& T
) const
{
volScalarField invTc(1.0/Tb_ - 1.0/T);
return
log(p0_.value()) + dHvm_*invTc/constant::physicoChemical::R.value();
}
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::saturationPressureModels::ClausiusClapeyron
Description
ClausiusClapeyron equation for the vapour pressure of steam.
SourceFiles
ClausiusClapeyron.C
\*---------------------------------------------------------------------------*/
#ifndef ClausiusClapeyron_H
#define ClausiusClapeyron_H
#include "saturationPressureModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace saturationPressureModels
{
/*---------------------------------------------------------------------------*\
Class ClausiusClapeyron Declaration
\*---------------------------------------------------------------------------*/
class ClausiusClapeyron
:
public saturationPressureModel
{
private:
//- Vapour pressure at temperature Tb
dimensionedScalar p0_;
//- Temperature reference
dimensionedScalar Tb_;
//- Change of molar enthaply of the vapour
dimensionedScalar dHvm_;
public:
//- Runtime type information
TypeName("ClausiusClapeyron");
// Constructors
//- Construct from a dictionary
ClausiusClapeyron(const dictionary& dict);
//- Destructor
virtual ~ClausiusClapeyron();
// Member Functions
//- Saturation pressure
virtual tmp<volScalarField> pSat(const volScalarField& T) const;
//- Saturation pressure derivetive w.r.t. temperature
virtual tmp<volScalarField> pSatPrime(const volScalarField& T) const;
//- Natural log of the saturation pressure
virtual tmp<volScalarField> lnPSat(const volScalarField& T) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace saturationPressureModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "saturationPressureModel.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::saturationPressureModel> Foam::saturationPressureModel::New
(
const dictionary& dict
)
{
word saturationPressureModelType(dict.lookup("type"));
Info<< "Selecting saturationPressureModel: "
<< saturationPressureModelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(saturationPressureModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn("saturationPressureModel::New")
<< "Unknown saturationPressureModelType type "
<< saturationPressureModelType << endl << endl
<< "Valid saturationPressureModel types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(dict);
}
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "saturationPressureModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(saturationPressureModel, 0);
defineRunTimeSelectionTable(saturationPressureModel, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::saturationPressureModel::saturationPressureModel()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::saturationPressureModel::~saturationPressureModel()
{}
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::saturationPressureModel
Description
SourceFiles
saturationPressureModel.C
newSaturationPressureModel.C
\*---------------------------------------------------------------------------*/
#ifndef saturationPressureModel_H
#define saturationPressureModel_H
#include "volFields.H"
#include "dictionary.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class saturationPressureModel Declaration
\*---------------------------------------------------------------------------*/
class saturationPressureModel
{
// Private Member Functions
//- Disallow default bitwise copy construct
saturationPressureModel(const saturationPressureModel&);
//- Disallow default bitwise assignment
void operator=(const saturationPressureModel&);
public:
//- Runtime type information
TypeName("saturationPressureModel");
//- Declare runtime construction
declareRunTimeSelectionTable
(
autoPtr,
saturationPressureModel,
dictionary,
(
const dictionary& dict
),
(dict)
);
// Constructors
//- Construct null
saturationPressureModel();
// Selectors
//- Select null constructed
static autoPtr<saturationPressureModel> New(const dictionary& dict);
//- Destructor
virtual ~saturationPressureModel();
// Member Functions
//- Saturation pressure
virtual tmp<volScalarField> pSat
(
const volScalarField& T
) const = 0;
//- Saturation pressure derivetive w.r.t. temperature
virtual tmp<volScalarField> pSatPrime
(
const volScalarField& T
) const = 0;
//- Natural log of the saturation pressure
virtual tmp<volScalarField> lnPSat
(
const volScalarField& T
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
{
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
volVectorField HbyA("HbyA", U);
HbyA = rAU*UEqn.H();
surfaceScalarField phiHbyA
(
"phiHbyA",
(fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi)
);
adjustPhi(phiHbyA, U, p_rgh);
surfaceScalarField phig
(
(
fluid.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the fixedFluxPressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqn
(
fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p_rgh)
);
forAllConstIter
(
phaseSystem::phasePairTable,
fluid.totalPhasePairs(),
iter
)
{
const phasePair& pair = iter()();
const phaseModel& phase1 = pair.phase1();
const phaseModel& phase2 = pair.phase2();
const phasePairKey key12
(
phase1.name(),
phase2.name(),
true
);
// Mass transfer from phase2 to phase1
tmp<volScalarField> tdmdt12(fluid.dmdt(key12));
const volScalarField& dmdt12 = tdmdt12();
const phasePairKey key21
(
phase2.name(),
phase1.name(),
true
);
// Mass transfer from phase1 to phase2
tmp<volScalarField> tdmdt21(fluid.dmdt(key21));
const volScalarField& dmdt21 = tdmdt21();
const volScalarField dmdtNet(dmdt21 - dmdt12);
p_rghEqn +=
dmdtNet*
(
- fluid.coeffs(phase1.name())
+ fluid.coeffs(phase2.name())
);
}
p_rghEqn.setReference(pRefCell, pRefValue);
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA + p_rghEqn.flux();
//phi = fluid.phiMixture();
p_rgh.relax();
U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf);
U.correctBoundaryConditions();
fvOptions.correct(U);
K = 0.5*magSqr(U);
}
}
p == p_rgh + rho*gh;
if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}
}

View File

@ -0,0 +1,23 @@
interfaceModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.C
interfaceModels/surfaceTensionModels/surfaceTensionModel/newSurfaceTensionModel.C
interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C
interfaceModels/porousModels/porousModel/porousModel.C
interfaceModels/porousModels/porousModel/newPorousModel.C
interfaceModels/porousModels/VollerPrakash/VollerPrakash.C
phasePair/phasePairKey/phasePairKey.C
phasePair/phasePair/phasePair.C
phasePair/orderedPhasePair/orderedPhasePair.C
phaseModel/phaseModel/phaseModel.C
phaseModel/phaseModel/newphaseModel.C
phaseModel/phaseModel/phaseModels.C
phaseSystem/phaseSystem.C
phaseSystem/multiphaseSystem/multiphaseSystem.C
phaseSystem/multiphaseSystem/newMultiphaseSystem.C
phaseSystem/multiphaseSystem/multiphaseSystems.C
LIB = $(FOAM_LIBBIN)/libIncompressibleMultiphaseSystems

View File

@ -0,0 +1,24 @@
EXE_INC = \
-I../meltingEvaporationModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fvOptions/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
\
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/combustionModels/lnInclude \
\
-I../interfacialModels/lnInclude \
LIB_LIBS = \
-lcombustionModels

View File

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::MeltingEvaporationPhaseSystem
Description
Holds mass transfer models
SourceFiles
MeltingEvaporationPhaseSystem.C
\*---------------------------------------------------------------------------*/
#ifndef MeltingEvaporationPhaseSystem_H
#define MeltingEvaporationPhaseSystem_H
#include "phaseSystem.H"
#include "HashPtrTable.H"
#include "interfaceCompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class MeltingEvaporationPhaseSystem Declaration
\*---------------------------------------------------------------------------*/
template<class BasePhaseSystem>
class MeltingEvaporationPhaseSystem
:
public BasePhaseSystem
{
protected:
// Protected typedefs
typedef
HashTable
<
autoPtr<interfaceCompositionModel>,
phasePairKey,
phasePairKey::hash
>
meltingEvaporationModelTable;
typedef
HashPtrTable
<
volScalarField,
Pair<word>,
FixedList<word, 2>::Hash<>
>
dmdtYiTable;
typedef
HashTable
<
dmdtYiTable,
phasePairKey,
phasePairKey::hash
>
dmdtPhaseVarYiTable;
typedef
HashPtrTable
<
volScalarField,
phasePairKey,
phasePairKey::hash
>
dmdtTable;
// Protected data
//- Overall inter-phase mass transfer rates
dmdtTable dmdt_;
//- Mass transfer models
meltingEvaporationModelTable meltingEvaporationModels_;
//- Variable based inter-phase mass transfer rates
dmdtPhaseVarYiTable dmdtYi_;
public:
// Constructors
//- Construct from fvMesh
MeltingEvaporationPhaseSystem(const fvMesh&);
//- Destructor
virtual ~MeltingEvaporationPhaseSystem();
// Member Functions
// Total mass transfer per variable
//- Return total interfacial mass flow rate
virtual tmp<volScalarField> dmdt(const phasePairKey& key) const;
//- Return species interfacial source mass rate per species
// driven by pressure or temperature
virtual tmp<volScalarField> dmdtYi
(
const word& phaseSpeciesName
) const;
//- Return total interfacial mass driven by modelVariable
tmp<volScalarField> dmdtYi
(
const phasePairKey& key,
word modelVar,
word specieName
) const;
//- Return non-const reference total interfacial mass driven
// by modelVariable
volScalarField& dmdtYi
(
const phasePairKey& key,
word modelVar,
word specieName
);
// Explicit and Implicit mass transfer matrices
//- Return the heat transfer matrix
virtual tmp<fvScalarMatrix> heatTransfer
(
const volScalarField& T
);
//- Return semi-implicit mass transfer matrix for
// multicomponent phases based on mass fractions
virtual autoPtr<phaseSystem::massTransferTable> massTransfer
(
const volScalarField& T
);
//- Return phase inverse density
virtual tmp<volScalarField> coeffs(const word& key) const;
//- Correct the phase properties other than the thermo and turbulence
virtual void correct();
//- Read base phaseProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "MeltingEvaporationPhaseSystem.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "VollerPrakash.H"
#include "phasePair.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace porousModels
{
defineTypeNameAndDebug(VollerPrakash, 0);
addToRunTimeSelectionTable
(
porousModel,
VollerPrakash,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::porousModels::VollerPrakash::VollerPrakash
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
)
:
porousModel(dict, pair, registerObject),
Cu_(readScalar(dict.lookup("Cu"))),
solidPhase_(dict.lookup("solidPhase"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::porousModels::VollerPrakash::
~ VollerPrakash()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::porousModels::VollerPrakash::S() const
{
const fvMesh& mesh = this->pair_.phase1().mesh();
const volScalarField& solidAlpha =
mesh.lookupObject<volScalarField>(solidPhase_);
return Cu_*sqr(solidAlpha)/(pow3(1.0 - solidAlpha) + 1e-3);
}
// ************************************************************************* //

View File

@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::VollerPrakash
Description
Constant value surface tension model.
SourceFiles
VollerPrakash.C
\*---------------------------------------------------------------------------*/
#ifndef VollerPrakash_H
#define VollerPrakash_H
#include "porousModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace porousModels
{
/*---------------------------------------------------------------------------*\
Class VollerPrakash Declaration
\*---------------------------------------------------------------------------*/
class VollerPrakash
:
public porousModel
{
// Private data
//- Constant surface tension value
const scalar Cu_;
//- Solid phase name
word solidPhase_;
public:
//- Runtime type information
TypeName("VollerPrakash");
// Constructors
//- Construct from a dictionary and a phase pair
VollerPrakash
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
);
//- Destructor
virtual ~VollerPrakash();
// Member Functions
//- Aspect ratio
virtual tmp<volScalarField> S() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace porousModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "porousModel.H"
#include "phasePair.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::porousModel >
Foam::porousModel::New
(
const dictionary& dict,
const phasePair& pair
)
{
word porousModelType(dict.lookup("type"));
Info<< "Selecting porousModel for "
<< pair << ": " << porousModelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(porousModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn("porousModel::New")
<< "Unknown porousModelType type "
<< porousModelType << endl << endl
<< "Valid porousModel types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(dict, pair, true);
}
// ************************************************************************* //

View File

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "porousModel.H"
#include "phasePair.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(porousModel, 0);
defineRunTimeSelectionTable(porousModel, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::porousModel::porousModel
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
)
:
regIOobject
(
IOobject
(
IOobject::groupName(typeName, pair.name()),
pair.phase1().mesh().time().timeName(),
pair.phase1().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
registerObject
)
),
pair_(pair)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::porousModel::~porousModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::porousModel::writeData(Ostream& os) const
{
return os.good();
}
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::porousModel
Description
SourceFiles
porousModel.C
\*---------------------------------------------------------------------------*/
#ifndef porousModel_H
#define porousModel_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "volFields.H"
#include "dictionary.H"
#include "runTimeSelectionTables.H"
namespace Foam
{
class phasePair;
/*---------------------------------------------------------------------------*\
Class porousModel Declaration
\*---------------------------------------------------------------------------*/
class porousModel
:
public regIOobject
{
protected:
// Protected data
//- Phase pair
const phasePair& pair_;
public:
//- Runtime type information
TypeName("porousModel");
// Declare runtime construction
declareRunTimeSelectionTable
(
autoPtr,
porousModel,
dictionary,
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
),
(dict, pair, registerObject)
);
// Constructors
//- Construct from a dictionary and a phase pair
porousModel
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
);
//- Destructor
virtual ~porousModel();
// Selectors
static autoPtr<porousModel> New
(
const dictionary& dict,
const phasePair& pair
);
// Member Functions
//- Momemtum source
virtual tmp<volScalarField> S() const = 0;
//- Dummy write for regIOobject
bool writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,94 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "constantSurfaceTensionCoefficient.H"
#include "phasePair.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceTensionModels
{
defineTypeNameAndDebug(constantSurfaceTensionCoefficient, 0);
addToRunTimeSelectionTable
(
surfaceTensionModel,
constantSurfaceTensionCoefficient,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceTensionModels::constantSurfaceTensionCoefficient::
constantSurfaceTensionCoefficient
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
)
:
surfaceTensionModel(dict, pair, registerObject),
sigma_("sigma", dimensionSet(1, 0, -2, 0, 0), dict.lookup("sigma"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceTensionModels::constantSurfaceTensionCoefficient::
~constantSurfaceTensionCoefficient()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::surfaceTensionModels::constantSurfaceTensionCoefficient::sigma() const
{
const fvMesh& mesh(this->pair_.phase1().mesh());
return
tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"zero",
mesh.time().timeName(),
mesh
),
mesh,
sigma_
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::constantSurfaceTensionCoefficient
Description
Constant value surface tension model.
SourceFiles
constantSurfaceTensionCoefficient.C
\*---------------------------------------------------------------------------*/
#ifndef constantSurfaceTensionCoefficient_H
#define constantSurfaceTensionCoefficient_H
#include "surfaceTensionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceTensionModels
{
/*---------------------------------------------------------------------------*\
Class constantSurfaceTensionCoefficient Declaration
\*---------------------------------------------------------------------------*/
class constantSurfaceTensionCoefficient
:
public surfaceTensionModel
{
// Private data
//- Constant surface tension value
const dimensionedScalar sigma_;
public:
//- Runtime type information
TypeName("constant");
// Constructors
//- Construct from a dictionary and a phase pair
constantSurfaceTensionCoefficient
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
);
//- Destructor
virtual ~constantSurfaceTensionCoefficient();
// Member Functions
//- Aspect ratio
virtual tmp<volScalarField> sigma() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceTensionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "surfaceTensionModel.H"
#include "phasePair.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceTensionModel >
Foam::surfaceTensionModel::New
(
const dictionary& dict,
const phasePair& pair
)
{
word surfaceTensionModelType(dict.lookup("type"));
Info<< "Selecting surfaceTensionModel for "
<< pair << ": " << surfaceTensionModelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(surfaceTensionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn("surfaceTensionModel::New")
<< "Unknown surfaceTensionModelType type "
<< surfaceTensionModelType << endl << endl
<< "Valid surfaceTensionModel types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(dict, pair, true);
}
// ************************************************************************* //

View File

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "surfaceTensionModel.H"
#include "phasePair.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfaceTensionModel, 0);
defineRunTimeSelectionTable(surfaceTensionModel, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceTensionModel::surfaceTensionModel
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
)
:
regIOobject
(
IOobject
(
IOobject::groupName(typeName, pair.name()),
pair.phase1().mesh().time().timeName(),
pair.phase1().mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
registerObject
)
),
pair_(pair)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceTensionModel::~surfaceTensionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::surfaceTensionModel::writeData(Ostream& os) const
{
return os.good();
}
// ************************************************************************* //

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::surfaceTensionModel
Description
SourceFiles
surfaceTensionModel.C
newAspectRatioModel.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceTensionModel_H
#define surfaceTensionModel_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "volFields.H"
#include "dictionary.H"
#include "runTimeSelectionTables.H"
namespace Foam
{
class phasePair;
/*---------------------------------------------------------------------------*\
Class surfaceTensionModel Declaration
\*---------------------------------------------------------------------------*/
class surfaceTensionModel
:
public regIOobject
{
protected:
// Protected data
//- Phase pair
const phasePair& pair_;
public:
//- Runtime type information
TypeName("surfaceTensionModel");
// Declare runtime construction
declareRunTimeSelectionTable
(
autoPtr,
surfaceTensionModel,
dictionary,
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
),
(dict, pair, registerObject)
);
// Constructors
//- Construct from a dictionary and a phase pair
surfaceTensionModel
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
);
//- Destructor
virtual ~surfaceTensionModel();
// Selectors
static autoPtr<surfaceTensionModel> New
(
const dictionary& dict,
const phasePair& pair
);
// Member Functions
//- Aspect ratio
virtual tmp<volScalarField> sigma() const = 0;
//- Dummy write for regIOobject
bool writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,215 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "MovingPhaseModel.H"
#include "phaseSystem.H"
#include "fixedValueFvPatchFields.H"
#include "slipFvPatchFields.H"
#include "partialSlipFvPatchFields.H"
#include "fvmDdt.H"
#include "fvmDiv.H"
#include "fvmSup.H"
#include "fvcDdt.H"
#include "fvcDiv.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class BasePhaseModel>
Foam::tmp<Foam::surfaceScalarField>
Foam::MovingPhaseModel<BasePhaseModel>::generatePhi
(
const word& phiName,
const volVectorField& U
) const
{
IOobject phiHeader
(
phiName,
U.mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ
);
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;
return
tmp<surfaceScalarField>
(
new surfaceScalarField
(
IOobject
(
phiName,
U.mesh().time().timeName(),
U.mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
U.mesh()
)
);
}
else
{
Info<< "Calculating face flux field " << phiName << endl;
wordList phiTypes
(
U.boundaryField().size(),
calculatedFvPatchScalarField::typeName
);
forAll(U.boundaryField(), i)
{
if
(
isA<fixedValueFvPatchVectorField>(U.boundaryField()[i])
|| isA<slipFvPatchVectorField>(U.boundaryField()[i])
|| isA<partialSlipFvPatchVectorField>(U.boundaryField()[i])
)
{
phiTypes[i] = fixedValueFvPatchScalarField::typeName;
}
}
return tmp<surfaceScalarField>
(
new surfaceScalarField
(
IOobject
(
phiName,
U.mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
fvc::interpolate(U) & U.mesh().Sf(),
phiTypes
)
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasePhaseModel>
Foam::MovingPhaseModel<BasePhaseModel>::MovingPhaseModel
(
const phaseSystem& fluid,
const word& phaseName
)
:
BasePhaseModel(fluid, phaseName),
U_(fluid.mesh().lookupObject<volVectorField>("U")),
phi_(fluid.mesh().lookupObject<surfaceScalarField>("phi")),
/*
(
generatePhi
(
IOobject::groupName("phi", phaseModel::name()),
U_
)
),
*/
alphaPhi_
(
IOobject
(
IOobject::groupName("alphaPhi", phaseModel::name()),
fluid.mesh().time().timeName(),
fluid.mesh()
),
fluid.mesh(),
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class BasePhaseModel>
Foam::MovingPhaseModel<BasePhaseModel>::~MovingPhaseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasePhaseModel>
void Foam::MovingPhaseModel<BasePhaseModel>::correct()
{
BasePhaseModel::correct();
}
template<class BasePhaseModel>
Foam::tmp<Foam::surfaceScalarField>
Foam::MovingPhaseModel<BasePhaseModel>::phi() const
{
return tmp<surfaceScalarField>(phi_);
}
template<class BasePhaseModel>
const Foam::surfaceScalarField&
Foam::MovingPhaseModel<BasePhaseModel>::phi()
{
return phi_;
}
template<class BasePhaseModel>
Foam::tmp<Foam::surfaceScalarField>
Foam::MovingPhaseModel<BasePhaseModel>::alphaPhi() const
{
return tmp<surfaceScalarField>(alphaPhi_);
}
template<class BasePhaseModel>
Foam::surfaceScalarField&
Foam::MovingPhaseModel<BasePhaseModel>::alphaPhi()
{
return alphaPhi_;
}
template<class BasePhaseModel>
Foam::tmp<Foam::volVectorField>
Foam::MovingPhaseModel<BasePhaseModel>::U() const
{
return tmp<volVectorField>(U_);
}
// ************************************************************************* //

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::MovingPhaseModel
Description
Class which represents a moving fluid phase. Holds the velocity, fluxes and
turbulence model. Provides access to the turbulent quantities.
Possible future extensions include separating the turbulent fuctionality
into another layer.
SourceFiles
MovingPhaseModel.C
\*---------------------------------------------------------------------------*/
#ifndef MovingPhaseModel_H
#define MovingPhaseModel_H
#include "phaseModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class phaseModel Declaration
\*---------------------------------------------------------------------------*/
template<class BasePhaseModel>
class MovingPhaseModel
:
public BasePhaseModel
{
// Private data
//- Reference to U
const volVectorField& U_;
//- Reference to phi
const surfaceScalarField& phi_;
//- Volumetric flux
surfaceScalarField alphaPhi_;
// Private static member functions
//- Generate the flux field
tmp<surfaceScalarField> generatePhi
(
const word& phiName,
const volVectorField& U
) const;
public:
// Constructors
MovingPhaseModel
(
const phaseSystem& fluid,
const word& phaseName
);
//- Destructor
virtual ~MovingPhaseModel();
// Member Functions
//- Correct the phase properties other than the thermo and turbulence
virtual void correct();
// Momentum
//- Constant access the volumetric flux
virtual tmp<surfaceScalarField> phi() const;
//- Access the volumetric flux
virtual const surfaceScalarField& phi();
//- Constant access the volumetric flux of the phase
virtual tmp<surfaceScalarField> alphaPhi() const;
//- Access the volumetric flux of the phase
virtual surfaceScalarField& alphaPhi();
//- Access const reference to U
virtual tmp<volVectorField> U() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "MovingPhaseModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,272 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "MultiComponentPhaseModel.H"
#include "phaseSystem.H"
#include "fvmDdt.H"
#include "fvmDiv.H"
#include "fvmSup.H"
#include "fvmLaplacian.H"
#include "fvcDdt.H"
#include "fvcDiv.H"
#include "fvMatrix.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::
MultiComponentPhaseModel
(
const phaseSystem& fluid,
const word& phaseName
)
:
BasePhaseModel(fluid, phaseName),
residualAlpha_
(
"residualAlpha",
dimless,
fluid.mesh().solverDict("Yi").lookup("residualAlpha")
),
species_(),
inertIndex_(-1)
{
thermoPtr_.set
(
phaseThermo::New
(
fluid.mesh(),
phaseName,
basicThermo::phasePropertyName(basicThermo::dictName, phaseName)
).ptr()
);
if (thermoPtr_->composition().species().size() == 0)
{
FatalErrorInFunction
<< " The selected thermo is pure. Use a multicomponent thermo."
<< exit(FatalError);
}
species_ = thermoPtr_->composition().species();
if (thermoPtr_().found("inertSpecie"))
{
inertIndex_ =
species_
[
thermoPtr_().lookup("inertSpecie")
];
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::
~MultiComponentPhaseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
const phaseThermo&
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::thermo() const
{
return thermoPtr_();
}
template<class BasePhaseModel, class phaseThermo>
phaseThermo&
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::thermo()
{
return thermoPtr_();
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::fvScalarMatrix>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::YiEqn
(
volScalarField& Yi
)
{
if
(
(inertIndex_ != -1)
&& (
Yi.name()
==
IOobject::groupName
(
thermoPtr_->composition().species()[inertIndex_],
this->name()
)
)
)
{
return tmp<fvScalarMatrix>();
}
const volScalarField& alpha = *this;
const surfaceScalarField& alphaPhi = this->alphaPhi();
// surfaceScalarField alphaRhoPhi
// (
// fvc::interpolate(alpha)*this->fluid().phi()
// );
return
tmp<fvScalarMatrix>
(
fvm::ddt(alpha, Yi)
+ fvm::div(alphaPhi, Yi, "div(" + alphaPhi.name() + ",Yi)")
// - fvm::Sp(fvc::div(alphaPhi), Yi)
==
fvc::ddt(residualAlpha_, Yi)
- fvm::ddt(residualAlpha_, Yi)
);
}
template<class BasePhaseModel, class phaseThermo>
const Foam::PtrList<Foam::volScalarField>&
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::Y() const
{
return thermoPtr_->composition().Y();
}
template<class BasePhaseModel, class phaseThermo>
Foam::PtrList<Foam::volScalarField>&
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::Y()
{
return thermoPtr_->composition().Y();
}
template<class BasePhaseModel, class phaseThermo>
Foam::dimensionedScalar
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::hf
(
label index
) const
{
return dimensionedScalar
(
"Hc",
sqr(dimLength)/sqr(dimTime),
thermoPtr_->composition().Hc(index)
);
}
/*
template<class BasePhaseModel, class phaseThermo>
void Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::
correctMassFractions()
{
volScalarField Yt
(
IOobject
(
IOobject::groupName("Yt", this->name()),
this->fluid().mesh().time().timeName(),
this->fluid().mesh()
),
this->fluid().mesh(),
dimensionedScalar("zero", dimless, 0)
);
PtrList<volScalarField>& Yi = thermoPtr_->composition().Y();
forAll(Yi, i)
{
if (i != inertIndex_)
{
Yt += Yi[i];
}
}
if (inertIndex_ != -1)
{
Yi[inertIndex_] = scalar(1) - Yt;
Yi[inertIndex_].max(0);
}
else
{
forAll(Yi, i)
{
Yi[i] /= Yt;
Yi[i].max(0);
}
}
}
*/
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::volScalarField>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::mu() const
{
return thermoPtr_->mu();
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::scalarField>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::mu
(
const label patchI
) const
{
return thermoPtr_->mu()().boundaryField()[patchI];
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::volScalarField>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::nu() const
{
return thermoPtr_->nu();
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::scalarField>
Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>::nu
(
const label patchI
) const
{
return thermoPtr_->nu(patchI);
}
// ************************************************************************* //

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::MultiComponentPhaseModel
Description
Class which represents a phase with multiple species. Returns the species'
mass fractions, and their governing equations.
SourceFiles
MultiComponentPhaseModel.C
\*---------------------------------------------------------------------------*/
#ifndef MultiComponentPhaseModel_H
#define MultiComponentPhaseModel_H
#include "phaseModel.H"
#include "hashedWordList.H"
#include "rhoReactionThermo.H"
#include "basicThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class phaseModel Declaration
\*---------------------------------------------------------------------------*/
template<class BasePhaseModel, class phaseThermo>
class MultiComponentPhaseModel
:
public BasePhaseModel
{
protected:
// Protected data
//- Residual phase fraction
dimensionedScalar residualAlpha_;
//- Species table
hashedWordList species_;
//- Inert species index
label inertIndex_;
//- Thermophysical model
autoPtr<phaseThermo> thermoPtr_;
public:
// Constructors
MultiComponentPhaseModel
(
const phaseSystem& fluid,
const word& phaseName
);
//- Destructor
virtual ~MultiComponentPhaseModel();
// Member Functions
// Access
//- Species table
const hashedWordList& species() const
{
return species_;
}
// Thermo
//- Access to thermo
virtual const phaseThermo& thermo() const;
//- Access non-const thermo
virtual phaseThermo& thermo();
//- Return the species fraction equation
virtual tmp<fvScalarMatrix> YiEqn(volScalarField& Yi);
//- Constant access the species mass fractions
virtual const PtrList<volScalarField>& Y() const;
//- Access the species mass fractions
virtual PtrList<volScalarField>& Y();
//- Return heat of formation for species
virtual dimensionedScalar hf(label index) const;
//- Correct the mass fractions
//void correctMassFractions();
// Transport
//- Return the laminar dynamic viscosity
virtual tmp<volScalarField> mu() const;
//- Return the laminar dynamic viscosity on a patch
virtual tmp<scalarField> mu(const label patchI) const;
//- Return the laminar kinematic viscosity
virtual tmp<volScalarField> nu() const;
//- Return the laminar kinematic viscosity on a patch
virtual tmp<scalarField> nu(const label patchI) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "MultiComponentPhaseModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "PurePhaseModel.H"
#include "phaseSystem.H"
#include "basicThermo.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::PurePhaseModel
(
const phaseSystem& fluid,
const word& phaseName
)
:
BasePhaseModel(fluid, phaseName)
{
thermoPtr_.set
(
phaseThermo::New
(
fluid.mesh(),
phaseName,
basicThermo::phasePropertyName(basicThermo::dictName, phaseName)
).ptr()
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::~PurePhaseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::fvScalarMatrix>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::YiEqn
(
volScalarField& Yi
)
{
notImplemented
(
"template<class BasePhaseModel> "
"Foam::tmp<Foam::fvScalarMatrix> "
"Foam::PurePhaseModel<BasePhaseModel>::YiEqn"
"(volScalarField& Yi) const"
);
return tmp<fvScalarMatrix>();
}
template<class BasePhaseModel, class phaseThermo>
const Foam::PtrList<Foam::volScalarField>&
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::Y() const
{
return Y_;
}
template<class BasePhaseModel, class phaseThermo>
Foam::PtrList<Foam::volScalarField>&
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::Y()
{
return Y_;
}
template<class BasePhaseModel, class phaseThermo>
const phaseThermo& Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::
thermo() const
{
return thermoPtr_();
}
template<class BasePhaseModel, class phaseThermo>
phaseThermo& Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::
thermo()
{
return thermoPtr_();
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::volScalarField>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::mu() const
{
return thermoPtr_->mu();
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::scalarField>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::mu
(
const label patchi
) const
{
return thermoPtr_->mu(patchi);
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::volScalarField>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::nu() const
{
return thermoPtr_->nu();
}
template<class BasePhaseModel, class phaseThermo>
Foam::tmp<Foam::scalarField>
Foam::PurePhaseModel<BasePhaseModel, phaseThermo>::nu
(
const label patchi
) const
{
return thermoPtr_->nu(patchi);
}
// ************************************************************************* //

View File

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::PurePhaseModel
Description
Class which represents pure phases, i.e. without any species. Returns an
empty list of mass fractions.
SourceFiles
PurePhaseModel.C
\*---------------------------------------------------------------------------*/
#ifndef PurePhaseModel_H
#define PurePhaseModel_H
#include "PtrList.H"
#include "volFields.H"
#include "fvMatricesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class phaseSystem;
/*---------------------------------------------------------------------------*\
Class PurePhaseModel Declaration
\*---------------------------------------------------------------------------*/
template<class BasePhaseModel, class phaseThermo>
class PurePhaseModel
:
public BasePhaseModel
{
protected:
// Protected data
//- Empty mass fraction field list
PtrList<volScalarField> Y_;
//- Empty thermophysical model Ptr
autoPtr<phaseThermo> thermoPtr_;
public:
// Constructors
PurePhaseModel
(
const phaseSystem& fluid,
const word& phaseName
);
//- Destructor
virtual ~PurePhaseModel();
// Member Functions
//- Return the species fraction equation
virtual tmp<fvScalarMatrix> YiEqn(volScalarField& Yi);
// Thermo
//- Return the species mass fractions
virtual const PtrList<volScalarField>& Y() const;
//- Access the species mass fractions
virtual PtrList<volScalarField>& Y();
//- Access to thermo
virtual const phaseThermo& thermo() const;
//- Access non-const thermo
virtual phaseThermo& thermo();
//- Return the laminar dynamic viscosity
virtual tmp<volScalarField> mu() const;
//- Access the laminar dynamic viscosity
virtual tmp<scalarField> mu(const label patchi) const;
//- Return the laminar kinematic viscosity
virtual tmp<volScalarField> nu() const;
//- Access the laminar kinematic viscosity
virtual tmp<scalarField> nu(const label patchi) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PurePhaseModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,176 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "StaticPhaseModel.H"
#include "phaseSystem.H"
#include "fixedValueFvPatchFields.H"
#include "slipFvPatchFields.H"
#include "partialSlipFvPatchFields.H"
#include "fvmDdt.H"
#include "fvmDiv.H"
#include "fvmSup.H"
#include "fvcDdt.H"
#include "fvcDiv.H"
#include "surfaceInterpolate.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasePhaseModel>
Foam::StaticPhaseModel<BasePhaseModel>::StaticPhaseModel
(
const phaseSystem& fluid,
const word& phaseName
)
:
BasePhaseModel(fluid, phaseName),
U_(fluid.mesh().lookupObject<volVectorField>("U")),
phi_
(
IOobject
(
IOobject::groupName("phi", phaseModel::name()),
fluid.mesh().time().timeName(),
fluid.mesh()
),
fluid.mesh(),
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
),
alphaPhi_
(
IOobject
(
IOobject::groupName("alphaPhi", phaseModel::name()),
fluid.mesh().time().timeName(),
fluid.mesh()
),
fluid.mesh(),
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class BasePhaseModel>
Foam::StaticPhaseModel<BasePhaseModel>::~StaticPhaseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasePhaseModel>
void Foam::StaticPhaseModel<BasePhaseModel>::correct()
{
BasePhaseModel::correct();
}
template<class BasePhaseModel>
Foam::tmp<Foam::surfaceScalarField>
Foam::StaticPhaseModel<BasePhaseModel>::phi() const
{
return tmp<surfaceScalarField>
(
new surfaceScalarField
(
IOobject
(
IOobject::groupName("phi", phaseModel::name()),
U_.mesh().time().timeName(),
U_.mesh()
),
U_.mesh(),
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
)
);
}
template<class BasePhaseModel>
const Foam::surfaceScalarField&
Foam::StaticPhaseModel<BasePhaseModel>::phi()
{
phi_ = dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0);
return phi_;
}
template<class BasePhaseModel>
Foam::tmp<Foam::surfaceScalarField>
Foam::StaticPhaseModel<BasePhaseModel>::alphaPhi() const
{
return tmp<surfaceScalarField>
(
new surfaceScalarField
(
IOobject
(
IOobject::groupName("alphaPhi", phaseModel::name()),
U_.mesh().time().timeName(),
U_.mesh()
),
U_.mesh(),
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
)
);
}
template<class BasePhaseModel>
Foam::surfaceScalarField&
Foam::StaticPhaseModel<BasePhaseModel>::alphaPhi()
{
alphaPhi_ = dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0);
return alphaPhi_;
}
template<class BasePhaseModel>
Foam::tmp<Foam::volVectorField>
Foam::StaticPhaseModel<BasePhaseModel>::U() const
{
return tmp<volVectorField>
(
new volVectorField
(
IOobject
(
IOobject::groupName("U", phaseModel::name()),
U_.mesh().time().timeName(),
U_.mesh()
),
U_.mesh(),
dimensionedVector("zero", dimVelocity, vector::zero)
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,122 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::StaticPhaseModel
Description
Class which represents a static fluid phase.
SourceFiles
StaticPhaseModel.C
\*---------------------------------------------------------------------------*/
#ifndef StaticPhaseModel_H
#define StaticPhaseModel_H
#include "phaseModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class phaseModel Declaration
\*---------------------------------------------------------------------------*/
template<class BasePhaseModel>
class StaticPhaseModel
:
public BasePhaseModel
{
// Private data
//- Reference to U
const volVectorField& U_;
//- Flux
surfaceScalarField phi_;
//- Volumetric flux
surfaceScalarField alphaPhi_;
public:
// Constructors
StaticPhaseModel
(
const phaseSystem& fluid,
const word& phaseName
);
//- Destructor
virtual ~StaticPhaseModel();
// Member Functions
//- Correct the phase properties other than the thermo and turbulence
virtual void correct();
// Momentum
//- Constant access the volumetric flux. Return zero field
virtual tmp<surfaceScalarField> phi() const;
//- Access the volumetric flux
virtual const surfaceScalarField& phi();
//- Constant access the volumetric flux of the phase. Return zero field
virtual tmp<surfaceScalarField> alphaPhi() const;
//- Access the volumetric flux of the phase
virtual surfaceScalarField& alphaPhi();
//- Access const reference to U
virtual tmp<volVectorField> U() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "StaticPhaseModel.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
\*---------------------------------------------------------------------------*/
#ifndef makePhaseTypes_H
#define makePhaseTypes_H
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makePhaseTypes(MomemtumType, CompType, Phase, Thermo, Name) \
\
namespace Foam \
{ \
typedef Foam::MomemtumType<Foam::CompType<Foam::Phase, Foam::Thermo> > \
Name; \
\
\
\
addNamedToRunTimeSelectionTable \
( \
phaseModel, \
Name, \
phaseSystem, \
Name \
); \
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "phaseModel.H"
#include "phaseSystem.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::New
(
const phaseSystem& fluid,
const word& phaseName
)
{
word phaseModelType(fluid.subDict(phaseName).lookup("type"));
Info<< "Selecting phaseModel for "
<< phaseName << ": " << phaseModelType << endl;
phaseSystemConstructorTable::iterator cstrIter =
phaseSystemConstructorTablePtr_->find(phaseModelType);
if (cstrIter == phaseSystemConstructorTablePtr_->end())
{
FatalErrorIn("phaseModel::New")
<< "Unknown phaseModelType type "
<< phaseModelType << endl << endl
<< "Valid phaseModel types are : " << endl
<< phaseSystemConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(fluid, phaseName);
}
// ************************************************************************* //

View File

@ -0,0 +1,300 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "phaseModel.H"
#include "phaseSystem.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(phaseModel, 0);
defineRunTimeSelectionTable(phaseModel, phaseSystem);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phaseModel::phaseModel
(
const phaseSystem& fluid,
const word& phaseName
)
:
volScalarField
(
IOobject
(
IOobject::groupName("alpha", phaseName),
fluid.mesh().time().timeName(),
fluid.mesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
fluid.mesh(),
dimensionedScalar("alpha", dimless, 0)
),
fluid_(fluid),
name_(phaseName),
alphaMax_(fluid.subDict(phaseName).lookupOrDefault("alphaMax", 1.0))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phaseModel::~phaseModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::phaseModel::name() const
{
return name_;
}
const Foam::phaseSystem& Foam::phaseModel::fluid() const
{
return fluid_;
}
Foam::scalar Foam::phaseModel::alphaMax() const
{
return alphaMax_;
}
void Foam::phaseModel::correct()
{
thermo().correct();
}
void Foam::phaseModel::correctTurbulence()
{
// do nothing
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::rho() const
{
return thermo().rho();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::rho(const label patchI) const
{
return thermo().rho(patchI);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::hc() const
{
return thermo().hc();
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::Cp() const
{
return thermo().Cp();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::Cp
(
const scalarField& p,
const scalarField& T,
const label patchI
) const
{
return (thermo().Cp(p, T, patchI));
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::Cv() const
{
return thermo().Cv();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::Cv
(
const scalarField& p,
const scalarField& T,
const label patchI
) const
{
return thermo().Cv(p, T, patchI);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::gamma() const
{
return thermo().gamma();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::gamma
(
const scalarField& p,
const scalarField& T,
const label patchI
) const
{
return thermo().gamma(p, T, patchI);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::Cpv() const
{
return thermo().Cpv();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::Cpv
(
const scalarField& p,
const scalarField& T,
const label patchI
) const
{
return thermo().Cpv(p, T, patchI);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::CpByCpv() const
{
return thermo().CpByCpv();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::CpByCpv
(
const scalarField& p,
const scalarField& T,
const label patchI
) const
{
return thermo().CpByCpv(p, T, patchI);
}
const Foam::volScalarField& Foam::phaseModel::alpha() const
{
return thermo().alpha();
}
const Foam::scalarField& Foam::phaseModel::alpha(const label patchI) const
{
return thermo().alpha(patchI);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::kappa() const
{
return thermo().kappa();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::kappa(const label patchI) const
{
return thermo().kappa(patchI);
}
Foam::tmp<Foam::volScalarField>Foam::phaseModel::kappaEff
(
const volScalarField& kappat
) const
{
tmp<volScalarField> kappaEff(kappa() + kappat);
kappaEff.ref().rename("kappaEff" + name_);
return kappaEff;
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::kappaEff
(
const scalarField& kappat,
const label patchI
) const
{
return (kappa(patchI) + kappat);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::alphaEff
(
const volScalarField& alphat
) const
{
return (thermo().alpha() + alphat);
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::alphaEff
(
const scalarField& alphat,
const label patchI
) const
{
return (thermo().alpha(patchI) + alphat);
}
/*
Foam::tmp<Foam::volScalarField> Foam::phaseModel::mu() const
{
return thermo().mu();
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::mu(const label patchi) const
{
return thermo().mu(patchi);
}
Foam::tmp<Foam::volScalarField> Foam::phaseModel::nu() const
{
return (thermo().mu()/thermo().rho());
}
Foam::tmp<Foam::scalarField> Foam::phaseModel::nu(const label patchi) const
{
return (thermo().mu(patchi)/thermo().rho(patchi));
}
*/
bool Foam::phaseModel::read()
{
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,338 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phaseModel
SourceFiles
phaseModel.C
newphaseModel.C
\*---------------------------------------------------------------------------*/
#ifndef phaseModel_H
#define phaseModel_H
#include "dictionary.H"
#include "dimensionedScalar.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "fvMatricesFwd.H"
#include "runTimeSelectionTables.H"
#include "rhoThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class phaseSystem;
/*---------------------------------------------------------------------------*\
Class phaseModel Declaration
\*---------------------------------------------------------------------------*/
class phaseModel
:
public volScalarField
{
// Private data
//- Reference to the phaseSystem to which this phase belongs
const phaseSystem& fluid_;
//- Name of phase
word name_;
//- Optional maximum phase-fraction (e.g. packing limit)
scalar alphaMax_;
public:
//- Runtime type information
ClassName("phaseModel");
// Declare runtime construction
declareRunTimeSelectionTable
(
autoPtr,
phaseModel,
phaseSystem,
(
const phaseSystem& fluid,
const word& phaseName
),
(fluid, phaseName)
);
// Constructors
phaseModel
(
const phaseSystem& fluid,
const word& phaseName
);
//- Destructor
virtual ~phaseModel();
// Selectors
static autoPtr<phaseModel> New
(
const phaseSystem& fluid,
const word& phaseName
);
// Member Functions
//- Return the name of this phase
const word& name() const;
//- Return the system to which this phase belongs
const phaseSystem& fluid() const;
//- Return the other phase in a two-phase system
const phaseModel& otherPhase() const;
//- Return the maximum phase-fraction (e.g. packing limit)
scalar alphaMax() const;
//- Correct the phase properties
virtual void correct();
//- Correct the turbulence
virtual void correctTurbulence();
//- Return the species fraction equation
virtual tmp<fvScalarMatrix> YiEqn(volScalarField& Yi) = 0;
//- Read phase properties dictionary
virtual bool read();
// Thermo
//- Access const to phase thermo
virtual const rhoThermo& thermo() const = 0;
//- Access to phase thermo
virtual rhoThermo& thermo() = 0;
//- Return the phase density
tmp<volScalarField> rho() const;
//- Return phase density on a patch
tmp<scalarField> rho(const label patchi) const;
//- Chemical enthalpy for phase [J/kg]
tmp<volScalarField> hc() const;
//- Return phase Cp
tmp<volScalarField> Cp() const;
//- Heat capacity of the phase at constant pressure for patch [J/kg/K]
tmp<scalarField> Cp
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Return Cv of the phase
tmp<volScalarField> Cv() const;
//- Heat capacity at constant volume for phase for a patch [J/kg/K]
tmp<scalarField> Cv
(
const scalarField& p,
const scalarField& T,
const label patchI
) const;
//- Gamma = Cp/Cv of phase[]
tmp<volScalarField> gamma() const;
//- Gamma = Cp/Cv for phase on patch []
tmp<scalarField> gamma
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant pressure/volume for phase [J/kg/K]
tmp<volScalarField> Cpv() const;
//- Heat capacity at constant pressure/volume for phase at patch [J/kg/K]
tmp<scalarField> Cpv
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Heat capacity ratio for phase []
tmp<volScalarField> CpByCpv() const;
//- Heat capacity ratio for phase at patch []
tmp<scalarField> CpByCpv
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
// Transport
//- Thermal diffusivity for enthalpy of mixture [kg/m/s]
const volScalarField& alpha() const;
//- Thermal diffusivity for enthalpy of mixture for patch [kg/m/s]
const scalarField& alpha
(
const label patchi
) const;
//- Thermal diffusivity for temperature of phase [J/m/s/K]
tmp<volScalarField> kappa() const;
//- Thermal diffusivity for temperature
// of phase for patch [J/m/s/K]
tmp<scalarField> kappa
(
const label patchi
) const;
//- Effective thermal diffusivity for temperature
// of phase [J/m/s/K]
tmp<volScalarField> kappaEff
(
const volScalarField&
) const;
//- Effective thermal diffusivity for temperature
// of phase for patch [J/m/s/K]
tmp<scalarField> kappaEff
(
const scalarField& alphat,
const label patchi
) const;
//- Effective thermal diffusivity of phase [kg/m/s]
tmp<volScalarField> alphaEff
(
const volScalarField& alphat
) const;
//- Effective thermal diffusivity of phase for patch [kg/m/s]
tmp<scalarField> alphaEff
(
const scalarField& alphat,
const label patchi
) const;
//- Return the mixture kinematic viscosity
virtual tmp<volScalarField> nu() const = 0;
//- Return the mixture kinematic viscosity on patchi
virtual tmp<scalarField> nu(const label patchi) const = 0;
//- Return the mixture dymanic viscosity
virtual tmp<volScalarField> mu() const = 0;
//- Return the mixture dymanic viscosity on patchi
virtual tmp<scalarField> mu(const label patchi) const = 0;
// Species information
//- Constant access the species mass fractions
virtual const PtrList<volScalarField>& Y() const = 0;
//- Access the species mass fractions
virtual PtrList<volScalarField>& Y() = 0;
// Momentum
//- Constant access the volumetric flux
virtual tmp<surfaceScalarField> phi() const = 0;
//- Access the volumetric flux
virtual const surfaceScalarField& phi() = 0;
//- Constant access the volumetric flux of the phase
virtual tmp<surfaceScalarField> alphaPhi() const = 0;
//- Access the volumetric flux of the phase
virtual surfaceScalarField& alphaPhi() = 0;
//- Access const reference to U
virtual tmp<volVectorField> U() const = 0;
// Turbulence
/*
//- Return the turbulent dynamic viscosity
virtual tmp<volScalarField> mut() const = 0;
//- Return the turbulent dynamic viscosity on a patch
virtual tmp<scalarField> mut(const label patchI) const = 0;
//- Return the turbulent kinematic viscosity
virtual tmp<volScalarField> nut() const = 0;
//- Return the turbulent kinematic viscosity on a patch
virtual tmp<scalarField> nut(const label patchI) const = 0;
//- Return the kinetic pressure derivative w.r.t. volume fraction
virtual tmp<volScalarField> pPrime() const = 0;
//- Return the turbulent kinetic energy
virtual tmp<volScalarField> k() const = 0;
*/
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "makePhaseTypes.H"
#include "PurePhaseModel.H"
#include "MultiComponentPhaseModel.H"
#include "MovingPhaseModel.H"
#include "StaticPhaseModel.H"
#include "rhoThermo.H"
#include "solidThermo.H"
#include "rhoReactionThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePhaseTypes
(
MovingPhaseModel,
PurePhaseModel,
phaseModel,
rhoThermo,
pureMovingPhaseModel // Name of the phase type
);
makePhaseTypes
(
StaticPhaseModel,
PurePhaseModel,
phaseModel,
rhoThermo,
pureStaticPhaseModel
);
makePhaseTypes
(
StaticPhaseModel,
PurePhaseModel,
phaseModel,
solidThermo,
pureStaticSolidPhaseModel
);
makePhaseTypes
(
MovingPhaseModel,
MultiComponentPhaseModel,
phaseModel,
rhoReactionThermo,
multiComponentMovingPhaseModel
);
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "orderedPhasePair.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::orderedPhasePair::orderedPhasePair
(
const phaseModel& dispersed,
const phaseModel& continuous
)
:
phasePair
(
dispersed,
continuous,
true
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::orderedPhasePair::~orderedPhasePair()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::phaseModel& Foam::orderedPhasePair::dispersed() const
{
return phase1();
}
const Foam::phaseModel& Foam::orderedPhasePair::continuous() const
{
return phase2();
}
Foam::word Foam::orderedPhasePair::name() const
{
word namec(second());
namec[0] = toupper(namec[0]);
return first() + "To" + namec;
}
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::orderedPhasePair
Description
SourceFiles
orderedPhasePair.C
\*---------------------------------------------------------------------------*/
#ifndef orderedPhasePair_H
#define orderedPhasePair_H
#include "phasePair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class aspectRatioModel;
/*---------------------------------------------------------------------------*\
Class orderedPhasePair Declaration
\*---------------------------------------------------------------------------*/
class orderedPhasePair
:
public phasePair
{
// Private member functions
//- Set the aspect ratio model, if there is one
void setAspectRatioModel(const dictTable aspectRatioTable);
public:
// Constructors
//- Construct from two phases and gravity
orderedPhasePair
(
const phaseModel& dispersed,
const phaseModel& continuous
);
//- Destructor
virtual ~orderedPhasePair();
// Member Functions
//- Dispersed phase
virtual const phaseModel& dispersed() const;
//- Continuous phase
virtual const phaseModel& continuous() const;
//- Pair name
virtual word name() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "phasePair.H"
#include "surfaceTensionModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phasePair::phasePair
(
const phaseModel& phase1,
const phaseModel& phase2,
const bool ordered
)
:
phasePairKey(phase1.name(), phase2.name(), ordered),
phase1_(phase1),
phase2_(phase2),
g_(phase1.mesh().lookupObject<uniformDimensionedVectorField>("g"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phasePair::~phasePair()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::phaseModel& Foam::phasePair::dispersed() const
{
FatalErrorIn("Foam::phasePair::dispersed() const")
<< "Requested dispersed phase from an unordered pair."
<< exit(FatalError);
return phase1_;
}
const Foam::phaseModel& Foam::phasePair::continuous() const
{
FatalErrorIn("Foam::phasePair::dispersed() const")
<< "Requested continuous phase from an unordered pair."
<< exit(FatalError);
return phase1_;
}
Foam::word Foam::phasePair::name() const
{
word name2(second());
name2[0] = toupper(name2[0]);
return first() + "And" + name2;
}
Foam::tmp<Foam::volScalarField> Foam::phasePair::rho() const
{
return phase1()*phase1().rho() + phase2()*phase2().rho();
}
Foam::tmp<Foam::volScalarField> Foam::phasePair::Pr() const
{
return
continuous().nu()
*continuous().Cp()
*continuous().rho()
/continuous().kappa();
}
Foam::tmp<Foam::volScalarField> Foam::phasePair::sigma() const
{
return
phase1().mesh().lookupObject<surfaceTensionModel>
(
IOobject::groupName
(
surfaceTensionModel::typeName,
phasePair::name()
)
).sigma();
}
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phasePair
Description
SourceFiles
phasePair.C
\*---------------------------------------------------------------------------*/
#ifndef phasePair_H
#define phasePair_H
#include "phaseModel.H"
#include "phasePairKey.H"
#include "uniformDimensionedFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class phasePair Declaration
\*---------------------------------------------------------------------------*/
class phasePair
:
public phasePairKey
{
public:
// Hash table types
//- Dictionary hash table
typedef HashTable<dictionary, phasePairKey, phasePairKey::hash>
dictTable;
//- Scalar hash table
typedef HashTable<scalar, phasePairKey, phasePairKey::hash>
scalarTable;
private:
// Private data
//- Phase 1
const phaseModel& phase1_;
//- Phase 2
const phaseModel& phase2_;
//- Gravitational acceleration
const uniformDimensionedVectorField& g_;
public:
// Constructors
//- Construct from two phases and gravity
phasePair
(
const phaseModel& phase1,
const phaseModel& phase2,
const bool ordered = false
);
//- Destructor
virtual ~phasePair();
// Member Functions
//- Dispersed phase
virtual const phaseModel& dispersed() const;
//- Continuous phase
virtual const phaseModel& continuous() const;
//- Pair name
virtual word name() const;
//- Average density
tmp<volScalarField> rho() const;
//- Prandtl number
tmp<volScalarField> Pr() const;
//- Surface tension coefficient
tmp<volScalarField> sigma() const;
// Access
// Phase 1
inline const phaseModel& phase1() const;
// Phase 2
inline const phaseModel& phase2() const;
// Gravitation acceleration
inline const uniformDimensionedVectorField& g() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "phasePairI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::phaseModel& Foam::phasePair::phase1() const
{
return phase1_;
}
inline const Foam::phaseModel& Foam::phasePair::phase2() const
{
return phase2_;
}
inline const Foam::uniformDimensionedVectorField& Foam::phasePair::g() const
{
return g_;
}
// ************************************************************************* //

View File

@ -0,0 +1,172 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "phasePairKey.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::phasePairKey::hash::hash()
{}
Foam::phasePairKey::phasePairKey()
{}
Foam::phasePairKey::phasePairKey
(
const word& name1,
const word& name2,
const bool ordered
)
:
Pair<word>(name1, name2),
ordered_(ordered)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::phasePairKey::~phasePairKey()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::phasePairKey::ordered() const
{
return ordered_;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
Foam::label Foam::phasePairKey::hash::operator()
(
const phasePairKey& key
) const
{
if (key.ordered_)
{
return
word::hash()
(
key.first(),
word::hash()(key.second())
);
}
else
{
return
word::hash()(key.first())
+ word::hash()(key.second());
}
}
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
bool Foam::operator==
(
const phasePairKey& a,
const phasePairKey& b
)
{
const label c = Pair<word>::compare(a,b);
return
(a.ordered_ == b.ordered_)
&& (
(a.ordered_ && (c == 1))
|| (!a.ordered_ && (c != 0))
);
}
bool Foam::operator!=
(
const phasePairKey& a,
const phasePairKey& b
)
{
return !(a == b);
}
// * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
{
const FixedList<word, 3> temp(is);
key.first() = temp[0];
if (temp[1] == "and")
{
key.ordered_ = false;
}
else if(temp[1] == "to")
{
key.ordered_ = true;
}
else
{
FatalErrorIn
(
"friend Istream& operator>>"
"("
"Istream& is, "
"phasePairKey& key"
")"
) << "Phase pair type is not recognised. "
<< temp
<< "Use (phaseDispersed to phaseContinuous) for an ordered"
<< "pair, or (phase1 and pase2) for an unordered pair."
<< exit(FatalError);
}
key.second() = temp[2];
return is;
}
// * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const phasePairKey& key)
{
os << token::BEGIN_LIST
<< key.first()
<< token::SPACE
<< (key.ordered_ ? "to" : "and")
<< token::SPACE
<< key.second()
<< token::END_LIST;
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phasePairKey
Description
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef phasePairKey_H
#define phasePairKey_H
#include "Pair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class phasePairKey Declaration
\*---------------------------------------------------------------------------*/
class phasePairKey
:
public Pair<word>
{
public:
class hash
:
public Hash<phasePairKey>
{
public:
// Constructors
// Construct null
hash();
// Member operators
// Generate a hash from a phase pair key
label operator()(const phasePairKey& key) const;
};
private:
// Private data
//- Flag to indicate whether ordering is important
bool ordered_;
public:
// Constructors
//- Construct null
phasePairKey();
//- Construct from names and the ordering flag
phasePairKey
(
const word& name1,
const word& name2,
const bool ordered = false
);
// Destructor
virtual ~phasePairKey();
// Access
//- Return the ordered flag
bool ordered() const;
// Friend Operators
//- Test if keys are equal
friend bool operator==(const phasePairKey& a, const phasePairKey& b);
//- Test if keys are unequal
friend bool operator!=(const phasePairKey& a, const phasePairKey& b);
//- Read from stdin
friend Istream& operator>>(Istream& is, phasePairKey& key);
//- Write to stdout
friend Ostream& operator<<(Ostream& os, const phasePairKey& key);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,599 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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 "multiphaseSystem.H"
#include "fixedValueFvsPatchFields.H"
#include "Time.H"
#include "subCycle.H"
#include "fvcMeshPhi.H"
#include "MULES.H"
#include "surfaceInterpolate.H"
#include "fvcGrad.H"
#include "fvcSnGrad.H"
#include "fvcDiv.H"
#include "fvcDdt.H"
#include "fvcFlux.H"
#include "fvcAverage.H"
#include "fvMatrix.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(multiphaseSystem, 0);
defineRunTimeSelectionTable(multiphaseSystem, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::multiphaseSystem::multiphaseSystem
(
const fvMesh& mesh
)
:
phaseSystem(mesh),
dmdtContinuityError_
(
IOobject
(
"dmdtContinuityError",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("0", inv(dimTime), 0)
)
{
label phaseI = 0;
phases_.setSize(phaseModels_.size());
forAllConstIter(HashTable<autoPtr<phaseModel> >, phaseModels_, iter)
{
phaseModel& pm = const_cast<phaseModel&>(iter()());
phases_.set(phaseI++, &pm);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::multiphaseSystem::~multiphaseSystem()
{
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::multiphaseSystem::solve()
{
const fvMesh& mesh = this->mesh();
const dictionary& alphaControls = mesh.solverDict("alpha");
label nAlphaSubCycles(readLabel(alphaControls.lookup("nAlphaSubCycles")));
label nAlphaCorr(readLabel(alphaControls.lookup("nAlphaCorr")));
scalar cAlpha(readScalar(alphaControls.lookup("cAlpha")));
scalar icAlpha(readScalar(alphaControls.lookup("icAlpha")));
PtrList<surfaceScalarField> phiAlphaCorrs(phases_.size());
const surfaceScalarField& phi = this->phi();
surfaceScalarField phic(mag((phi)/mesh_.magSf()));
phic = min(cAlpha*phic, max(phic));
// Add the optional isotropic compression contribution
if (icAlpha > 0)
{
phic *= (1.0 - icAlpha);
phic += (cAlpha*icAlpha)*fvc::interpolate(mag(this->U()));
}
forAllIter(UPtrList<phaseModel>, phases_, iter)
{
phaseModel& phase1 = iter();
volScalarField& alpha1 = phase1;
alpha1.correctBoundaryConditions();
}
for (int acorr=0; acorr<nAlphaCorr; acorr++)
{
int phasei = 0;
forAllIter(UPtrList<phaseModel>, phases_, iter)
{
phaseModel& phase1 = iter();
const volScalarField& alpha1 = phase1;
phiAlphaCorrs.set
(
phasei,
new surfaceScalarField
(
"phi" + alpha1.name() + "Corr",
fvc::flux
(
phi,
alpha1,
"div(phi," + alpha1.name() + ')'
)
)
);
surfaceScalarField& phiAlphaCorr = phiAlphaCorrs[phasei];
forAllIter(UPtrList<phaseModel>, phases_, iter2)
{
phaseModel& phase2 = iter2();
const volScalarField& alpha2 = phase2;
if (&phase2 == &phase1)
{
continue;
}
surfaceScalarField phir(phic*nHatf(alpha1, alpha2));
word phirScheme
(
"div(phir," + alpha2.name() + ',' + alpha1.name() + ')'
);
phiAlphaCorr += fvc::flux
(
-fvc::flux(-phir, alpha2, phirScheme),
alpha1,
phirScheme
);
}
// Ensure that the flux at inflow BCs is preserved
forAll(phiAlphaCorr.boundaryField(), patchi)
{
fvsPatchScalarField& phiAlphaCorrp =
phiAlphaCorr.boundaryFieldRef()[patchi];
if (!phiAlphaCorrp.coupled())
{
const scalarField& phi1p = phi.boundaryField()[patchi];
const scalarField& alpha1p =
alpha1.boundaryField()[patchi];
forAll(phiAlphaCorrp, facei)
{
if (phi1p[facei] < 0)
{
phiAlphaCorrp[facei] = alpha1p[facei]*phi1p[facei];
}
}
}
}
phasei++;
}
// Set Su and Sp tp zero
forAllIter(UPtrList<phaseModel>, phases_, iter)
{
phaseModel& phase = iter();
Su_[phase.name()] = dimensionedScalar("Su", dimless/dimTime, 0.0);
Sp_[phase.name()] = dimensionedScalar("Sp", dimless/dimTime, 0.0);
// Add alpha*div(U)
const volScalarField& alpha = phase;
Su_[phase.name()] +=
fvc::div(phi)*min(max(alpha, scalar(0)), scalar(1));
}
// Fill Su and Sp
forAllIter(phaseSystem::phasePairTable, totalPhasePairs_, iter)
{
const phasePair& pair = iter()();
const phaseModel& phase1 = pair.phase1();
const phaseModel& phase2 = pair.phase2();
const volScalarField& alpha1 = pair.phase1();
const volScalarField& alpha2 = pair.phase2();
tmp<volScalarField> tCoeffs1 = this->coeffs(phase1.name());
const volScalarField& coeffs1 = tCoeffs1();
tmp<volScalarField> tCoeffs2 = this->coeffs(phase2.name());
const volScalarField& coeffs2 = tCoeffs2();
// Phase 1 to phase 2
const phasePairKey key12
(
phase1.name(),
phase2.name(),
true
);
tmp<volScalarField> tdmdt12(this->dmdt(key12));
const volScalarField& dmdt12 = tdmdt12();
// Phase 2 to phase 1
const phasePairKey key21
(
phase2.name(),
phase1.name(),
true
);
tmp<volScalarField> tdmdt21(this->dmdt(key21));
const volScalarField& dmdt21 = tdmdt21();
volScalarField::Internal& SpPhase1 =
Sp_[phase1.name()];
volScalarField::Internal& SuPhase1 =
Su_[phase1.name()];
volScalarField::Internal& SpPhase2 =
Sp_[phase2.name()];
volScalarField::Internal& SuPhase2 =
Su_[phase2.name()];
const volScalarField dmdtNet(dmdt21 - dmdt12);
const volScalarField coeffs12(coeffs1 - coeffs2);
//DebugVar(max(coeffs1.internalField()));
//DebugVar(min(coeffs1.internalField()));
// NOTE: dmdtNet is distributed in terms =
// Source for phase 1 =
// dmdtNet/rho1
// - alpha1*dmdtNet(1/rho1 - 1/rho2)
forAll(dmdtNet, celli)
{
scalar dmdt21 = dmdtNet[celli];
scalar coeffs12Cell = coeffs12[celli];
scalar alpha1Limited = max(min(alpha1[celli], 1.0), 0.0);
// exp.
SuPhase1[celli] += coeffs1[celli]*dmdt21;
if (dmdt21 > 0)
{
if (coeffs12Cell > 0)
{
// imp
SpPhase1[celli] -= dmdt21*coeffs12Cell;
}
else if (coeffs12Cell < 0)
{
// exp
SuPhase1[celli] -=
dmdt21*coeffs12Cell*alpha1Limited;
}
}
else if (dmdt21 < 0)
{
if (coeffs12Cell > 0)
{
// exp
SuPhase1[celli] -=
dmdt21*coeffs12Cell*alpha1Limited;
}
else if (coeffs12Cell < 0)
{
// imp
SpPhase1[celli] -= dmdt21*coeffs12Cell;
}
}
}
forAll(dmdtNet, celli)
{
scalar dmdt12 = -dmdtNet[celli];
scalar coeffs21Cell = -coeffs12[celli];
scalar alpha2Limited = max(min(alpha2[celli], 1.0), 0.0);
// exp
SuPhase2[celli] += coeffs2[celli]*dmdt12;
if (dmdt12 > 0)
{
if (coeffs21Cell > 0)
{
// imp
SpPhase2[celli] -= dmdt12*coeffs21Cell;
}
else if (coeffs21Cell < 0)
{
// exp
SuPhase2[celli] -=
dmdt12*coeffs21Cell*alpha2Limited;
}
}
else if (dmdt12 < 0)
{
if (coeffs21Cell > 0)
{
// exp
SuPhase2[celli] -=
coeffs21Cell*dmdt12*alpha2Limited;
}
else if (coeffs21Cell < 0)
{
// imp
SpPhase2[celli] -= dmdt12*coeffs21Cell;
}
}
}
DebugVar(key12);
DebugVar(key21);
DebugVar(max(dmdt21.internalField()));
DebugVar(max(dmdt12.internalField()));
DebugVar(min(dmdt21.internalField()));
DebugVar(min(dmdt12.internalField()));
//DebugVar(max(SpPhase2));
//DebugVar(max(SpPhase1));
//DebugVar(min(SpPhase2));
//DebugVar(min(SpPhase1));
//DebugVar(max(SuPhase2));
//DebugVar(max(SuPhase1));
//DebugVar(min(SuPhase2));
//DebugVar(min(SuPhase1));
}
// Limit phiAlphaCorr on each phase
phasei = 0;
forAllIter(UPtrList<phaseModel>, phases_, iter)
{
phaseModel& phase = iter();
volScalarField& alpha1 = phase;
surfaceScalarField& phiAlphaCorr = phiAlphaCorrs[phasei];
volScalarField::Internal& Su = Su_[phase.name()];
volScalarField::Internal& Sp = Sp_[phase.name()];
MULES::limit
(
1.0/mesh_.time().deltaT().value(),
geometricOneField(),
alpha1,
phi,
phiAlphaCorr,
Sp,
Su,
1,
0,
true
);
phasei ++;
}
MULES::limitSum(phiAlphaCorrs);
volScalarField sumAlpha
(
IOobject
(
"sumAlpha",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar("sumAlpha", dimless, 0)
);
phasei = 0;
forAllIter(UPtrList<phaseModel>, phases_, iter)
{
phaseModel& phase = iter();
volScalarField& alpha1 = phase;
const volScalarField::Internal& Su =
Su_[phase.name()];
const volScalarField::Internal& Sp =
Sp_[phase.name()];
surfaceScalarField& phiAlpha = phiAlphaCorrs[phasei];
// Add a bounded upwind U-mean flux
phiAlpha += upwind<scalar>(mesh_, phi).flux(alpha1);
if (nAlphaSubCycles > 1)
{
for
(
subCycle<volScalarField> alphaSubCycle
(
alpha1,
nAlphaSubCycles
);
!(++alphaSubCycle).end();
)
{
//surfaceScalarField phiAlphaCorrs0(phiAlphaCorrs[phasei]);
MULES::explicitSolve
(
geometricOneField(),
alpha1,
phi,
phiAlpha,
(alphaSubCycle.index()*Sp)(),
(Su - (alphaSubCycle.index() - 1)*Sp*alpha1)(),
phase.alphaMax(),
0
);
if (alphaSubCycle.index() == 1)
{
phase.alphaPhi() = phiAlpha;//phiAlphaCorrs0;
}
else
{
phase.alphaPhi() += phiAlpha;//phiAlphaCorrs0;
}
}
phase.alphaPhi() /= nAlphaSubCycles;
}
else
{
phaseModel& phase = iter();
volScalarField& alpha1 = phase;
//surfaceScalarField& phiAlpha = phiAlphaCorrs[phasei];
MULES::explicitSolve
(
geometricOneField(),
alpha1,
phi,
phiAlpha,
Sp,
Su,
phase.alphaMax(),
0
);
phase.alphaPhi() = phiAlpha;
}
phasei++;
}
if (acorr == nAlphaCorr - 1)
{
volScalarField sumAlpha
(
IOobject
(
"sumAlpha",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar("sumAlpha", dimless, 0)
);
// Reset rhoPhi
rhoPhi_ = dimensionedScalar("rhoPhi", dimMass/dimTime, 0.0);
forAllIter(UPtrList<phaseModel>, phases_, iter)
{
phaseModel& phase = iter();
volScalarField& alpha1 = phase;
sumAlpha += alpha1;
// Update rhoPhi
rhoPhi_ +=
fvc::interpolate(phase.rho())*phase.alphaPhi();
Info<< alpha1.name() << " volume fraction = "
<< alpha1.weightedAverage(mesh.V()).value()
<< " Min(alpha) = " << min(alpha1).value()
<< " Max(alpha) = " << max(alpha1).value()
<< endl;
//DebugVar(max(alpha1.internalField()));
//DebugVar(min(alpha1.internalField()));
volScalarField dAlphadt("dAlphadt", fvc::ddt(alpha1));
//DebugVar(max(dAlphadt.internalField()));
//DebugVar(min(dAlphadt.internalField()));
if (mesh.time().outputTime())
{
//volScalarField divrhoPhi("divrhoPhi", fvc::div(rhoPhi_));
//divrhoPhi.write();
//dAlphadt.write();
}
}
Info<< "Phase-sum volume fraction, min, max = "
<< sumAlpha.weightedAverage(mesh_.V()).value()
<< ' ' << min(sumAlpha).value()
<< ' ' << max(sumAlpha).value()
<< endl;
}
}
}
const Foam::volScalarField& Foam::multiphaseSystem::dmdtContinuityError() const
{
return dmdtContinuityError_;
}
Foam::volScalarField& Foam::multiphaseSystem::dmdtContinuityError()
{
return dmdtContinuityError_;
}
const Foam::UPtrList<Foam::phaseModel>& Foam::multiphaseSystem::phases() const
{
return phases_;
}
Foam::UPtrList<Foam::phaseModel>& Foam::multiphaseSystem::phases()
{
return phases_;
}
const Foam::phaseModel& Foam::multiphaseSystem::phase(const label i) const
{
return phases_[i];
}
Foam::phaseModel& Foam::multiphaseSystem::phase(const label i)
{
return phases_[i];
}
// ************************************************************************* //

View File

@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::multiphaseSystem
Description
Class which solves the volume fraction equations for multiple phases
SourceFiles
multiphaseSystem.C
\*---------------------------------------------------------------------------*/
#ifndef multiphaseSystem_H
#define multiphaseSystem_H
#include "phaseSystem.H"
#include "UPtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class multiphaseSystem Declaration
\*---------------------------------------------------------------------------*/
class multiphaseSystem
:
public phaseSystem
{
protected:
// Protected data
//- Unallocated phase list
UPtrList<phaseModel> phases_;
//- dmdt continuity error
volScalarField dmdtContinuityError_;
public:
//- Runtime type information
TypeName("multiphaseSystem");
// Declare runtime construction
declareRunTimeSelectionTable
(
autoPtr,
multiphaseSystem,
dictionary,
(
const fvMesh& mesh
),
(mesh)
);
// Constructors
//- Construct from fvMesh
multiphaseSystem(const fvMesh&);
//- Destructor
virtual ~multiphaseSystem();
// Selectors
static autoPtr<multiphaseSystem> New(const fvMesh& mesh);
// Member Functions
//- Solve for the phase fractions
virtual void solve();
// Access
//- Constant access the dmdt continuity error
const volScalarField& dmdtContinuityError() const;
//- Access the dmdt continuity error
volScalarField& dmdtContinuityError();
//- Return phases
const UPtrList<phaseModel>& phases() const;
//- Return phases
UPtrList<phaseModel>& phases();
//- Constant access phase model i
virtual const phaseModel& phase(const label i) const;
//- Access phase model i
virtual phaseModel& phase(const label i);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "addToRunTimeSelectionTable.H"
#include "phaseSystem.H"
#include "multiphaseSystem.H"
#include "MeltingEvaporationPhaseSystem.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef
MeltingEvaporationPhaseSystem
<
multiphaseSystem
>
meltingEvaporationMultiphaseSystem;
addNamedToRunTimeSelectionTable
(
multiphaseSystem,
meltingEvaporationMultiphaseSystem,
dictionary,
meltingEvaporationMultiphaseSystem
);
}
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ 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 "multiphaseSystem.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::multiphaseSystem> Foam::multiphaseSystem::New
(
const fvMesh& mesh
)
{
const word multiphaseSystemType
(
IOdictionary
(
IOobject
(
propertiesName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
).lookup("type")
);
Info<< "Selecting multiphaseSystem " << multiphaseSystemType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(multiphaseSystemType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"multiphaseSystem::New"
) << "Unknown multiphaseSystemType type "
<< multiphaseSystemType << endl
<< "Valid multiphaseSystem types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<multiphaseSystem> (cstrIter()(mesh));
}
// ************************************************************************* //

View File

@ -0,0 +1,643 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::phaseSystem
Description
Class to represent a system of inmisible phases.
SourceFiles
phaseSystem.C
\*---------------------------------------------------------------------------*/
#ifndef phaseSystem_H
#define phaseSystem_H
#include "basicThermo.H"
#include "phaseModel.H"
#include "phasePair.H"
#include "orderedPhasePair.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "fvMatricesFwd.H"
#include "compressibleTransportModel.H"
#include "localMin.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class surfaceTensionModel;
class porousModel;
/*---------------------------------------------------------------------------*\
Class phaseSystem Declaration
\*---------------------------------------------------------------------------*/
class phaseSystem
:
public basicThermo,
public compressibleTransportModel
{
public:
// Public typedefs
typedef
HashPtrTable
<
fvScalarMatrix,
word,
string::hash
>
massTransferTable;
typedef
HashTable
<
autoPtr<phasePair>, phasePairKey, phasePairKey::hash
>
phasePairTable;
protected:
// Protected typedefs
typedef
HashTable<autoPtr<phaseModel>, word, word::hash> phaseModelTable;
typedef
HashTable<dictionary, phasePairKey, phasePairKey::hash> dictTable;
typedef
HashTable
<
autoPtr<surfaceTensionModel>,
phasePairKey,
phasePairKey::hash
>
surfaceTensionModelTable;
typedef
HashTable
<
autoPtr<porousModel>,
phasePairKey,
phasePairKey::hash
>
interfacePorousModelTable;
typedef
HashTable
<
volScalarField::Internal,
word,
word::hash
>
SuSpTable;
// Protected data
//- Reference to the mesh
const fvMesh& mesh_;
//- Phase names
wordList phaseNames_;
//- Mixture total volumetric flux
surfaceScalarField phi_;
//- Mixture total mass flux
surfaceScalarField rhoPhi_;
//- Phase models
phaseModelTable phaseModels_;
//- Phase pairs. Used to hold references for sub-models only.
// It accumulates phase pairs defined by sub-models
phasePairTable phasePairs_;
//- Total ordered phase pairs in the system
phasePairTable totalPhasePairs_;
//- Su phase source terms
SuSpTable Su_;
//- Sp phase source terms
SuSpTable Sp_;
//- Turbulent Prandt number
dimensionedScalar Prt_;
// Sub Models
//- Surface tension models
surfaceTensionModelTable surfaceTensionModels_;
//- Interface porous models
interfacePorousModelTable interfacePorousModelTable_;
// Protected member functions
//- Generate the phases
HashTable<autoPtr<phaseModel> > generatePhaseModels
(
const wordList& names
) const;
//- Generate the mixture flux
tmp<surfaceScalarField> generatePhi
(
const HashTable<autoPtr<phaseModel> >& phaseModels
) const;
//- Generate pairs
void generatePairs(const dictTable& modelDicts);
//- Generate pair table
void generatePairsTable();
//- Generate pairs and sub-model tables
template<class modelType>
void createSubModels
(
const dictTable& modelDicts,
HashTable
<
autoPtr<modelType>,
phasePairKey,
phasePairKey::hash
>& models
);
//- Generate pairs and sub-model tables
template<class modelType>
void generatePairsAndSubModels
(
const word& modelName,
HashTable
<
autoPtr<modelType>,
phasePairKey,
phasePairKey::hash
>& models
);
//- Generate pairs and per-phase sub-model tables
template<class modelType>
void generatePairsAndSubModels
(
const word& modelName,
HashTable
<
HashTable<autoPtr<modelType> >,
phasePairKey,
phasePairKey::hash
>& models
);
public:
//- Runtime type information
TypeName("phaseSystem");
//- Default name of the phase properties dictionary
static const word propertiesName;
// Constructors
//- Construct from fvMesh
phaseSystem(const fvMesh& mesh);
//- Destructor
virtual ~phaseSystem();
// Energy related thermo functionaliy functions
//- Return access to the inernal energy field [J/Kg]
virtual volScalarField& he()
{
NotImplemented;
return
(
const_cast<volScalarField&>
(
volScalarField::null()
)
);
}
//- Return access to the inernal energy field [J/Kg]
virtual const volScalarField& he() const
{
NotImplemented;
return
(
volScalarField::null()
);
}
//- Enthalpy/Internal energy
// for given pressure and temperature [J/kg]
virtual tmp<volScalarField> he
(
const volScalarField& p,
const volScalarField& T
) const;
//- Enthalpy/Internal energy for cell-set [J/kg]
virtual tmp<scalarField> he
(
const scalarField& p,
const scalarField& T,
const labelList& cells
) const;
//- Enthalpy/Internal energy for patch [J/kg]
virtual tmp<scalarField> he
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Chemical enthalpy oft he mixture [J/kg]
virtual tmp<volScalarField> hc() const;
//- Temperature from enthalpy/internal energy for cell-set
virtual tmp<scalarField> THE
(
const scalarField& h,
const scalarField& p,
const scalarField& T0, // starting temperature
const labelList& cells
) const;
//- Temperature from enthalpy/internal energy for patch
virtual tmp<scalarField> THE
(
const scalarField& h,
const scalarField& p,
const scalarField& T0, // starting temperature
const label patchi
) const;
// Thermo
//- Return the mixture density
virtual tmp<volScalarField> rho() const;
//- Return the mixture density on a patch
virtual tmp<scalarField> rho(const label patchi) const;
//- Return Cp of the mixture
virtual tmp<volScalarField> Cp() const;
//- Heat capacity at constant pressure for patch [J/kg/K]
virtual tmp<scalarField> Cp
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Return Cv of the mixture
virtual tmp<volScalarField> Cv() const;
//- Return rho weighted Cv of the mixture
tmp<volScalarField> rhoCv() const;
//- Heat capacity at constant volume for patch [J/kg/K]
virtual tmp<scalarField> Cv
(
const scalarField& p,
const scalarField& T,
const label patchI
) const;
//- Heat capacity rho weighted at constant volume for patch [J/kg/K]
tmp<scalarField> rhoCv
(
const scalarField& p,
const scalarField& T,
const label patchI
) const;
//- Gamma = Cp/Cv []
virtual tmp<volScalarField> gamma() const;
//- Gamma = Cp/Cv for patch []
virtual tmp<scalarField> gamma
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant pressure/volume [J/kg/K]
virtual tmp<volScalarField> Cpv() const;
//- Heat capacity at constant pressure/volume for patch [J/kg/K]
virtual tmp<scalarField> Cpv
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Heat capacity ratio []
virtual tmp<volScalarField> CpByCpv() const;
//- Heat capacity ratio for patch []
virtual tmp<scalarField> CpByCpv
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
// Transport
//- Thermal diffusivity for temperature of mixture [J/m/s/K]
virtual tmp<volScalarField> kappa() const;
//- Thermal diffusivity for temperature
// of mixture for patch [J/m/s/K]
virtual tmp<scalarField> kappa
(
const label patchi
) const;
//- Effective thermal diffusivity for temperature
// of mixture [J/m/s/K]
virtual tmp<volScalarField> kappaEff
(
const volScalarField& kappat
) const;
//- Effective thermal diffusivity for temperature
// of mixture for patch [J/m/s/K]
virtual tmp<scalarField> kappaEff
(
const scalarField& alphat,
const label patchi
) const;
//- Effective thermal diffusivity of mixture [kg/m/s]
virtual tmp<volScalarField> alphaEff
(
const volScalarField& alphat
) const;
//- Effective thermal diffusivity of mixture for patch [kg/m/s]
virtual tmp<scalarField> alphaEff
(
const scalarField& alphat,
const label patchi
) const;
//- Return Prandt number
const dimensionedScalar& Prt() const;
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/m/s]
virtual tmp<volScalarField> mu() const;
//- Dynamic viscosity of mixture for patch [kg/m/s]
virtual tmp<scalarField> mu(const label patchi) const;
//- Kinematic viscosity of mixture [m^2/s]
virtual tmp<volScalarField> nu() const;
//- Kinematic viscosity of mixture for patch [m^2/s]
virtual tmp<scalarField> nu(const label patchi) const;
// Phase fluxes
//- Constant access to the total flux
const surfaceScalarField& phi() const;
//- Access to the total mixture flux
surfaceScalarField& phi();
//- Constant access to the mixture mass flux
const surfaceScalarField& rhoPhi() const;
//- Access to the total mixture mass flux
surfaceScalarField& rhoPhi();
//- Mixture U
tmp<volVectorField> U() const;
//- Mixture phi
tmp<surfaceScalarField> phiMixture() const;
//- Calculate buoyant flux
tmp<surfaceScalarField> phig(const surfaceScalarField& ghf) const;
// Surface tension
//- Calculate surface tension of the mixture
tmp<surfaceScalarField> surfaceTensionForce() const;
//- Return the surface tension coefficient
virtual tmp<volScalarField> surfaceTensionCoeff
(
const phasePairKey& key
) const;
// Interface porous between solid/fluid phases
//- Add interface porosity on phasePair
void addInterfacePorosity(fvVectorMatrix& UEqn);
// Interphase mass and heat transfer defined in specialized systems
//- Return interfacial source mass rate per phase pair
virtual tmp<volScalarField> dmdt(const phasePairKey& key) const = 0;
//- Return species interfacial source mass rate per species other
// than the species driven models (i.e driven by pressure or temperature)
virtual tmp<volScalarField> dmdtYi
(
const word& phaseSpeciesName
) const = 0;
//- Return coefficients (1/rho)
virtual tmp<volScalarField> coeffs(const word& key) const = 0;
//- Return the heat transfer matrices
virtual tmp<fvScalarMatrix> heatTransfer
(
const volScalarField& T
) = 0;
//- Return mass transfer table
virtual autoPtr<massTransferTable> massTransfer
(
const volScalarField& T
) = 0;
// Solve phases and correct models
//- Solve for the phase fractions
virtual void solve() = 0;
//- Correct the thermo
virtual void correct();
//- Correct the turbulence
virtual void correctTurbulence();
//- Read base phaseProperties dictionary
virtual bool read();
// Access to phases models
//- Constant access the total phase pairs
const phasePairTable& totalPhasePairs() const;
//- Non-constant access the total phase pairs
phasePairTable& totalPhasePairs();
//- Constant access the phases
const phaseModelTable& phases() const;
//- Access the phases
phaseModelTable& phases();
//- Access a sub model between a phase pair
template <class modelType>
const modelType& lookupSubModel(const phasePair& key) const;
//- Access a sub model between two phases
template <class modelType>
const modelType& lookupSubModel
(
const phaseModel& dispersed,
const phaseModel& continuous
) const;
// Query phase thermo information
//- Return true if the equation of state is incompressible for all
// phases
virtual bool incompressible() const;
//- Return true if a phase is incompressible
virtual bool incompressible(const word) const;
//- Return true if the equation of state is isochoric for all phasses
// i.e. rho = const
virtual bool isochoric() const;
//- Return mesh
const fvMesh& mesh() const;
// Help functions for the interfaces
//- Interface normal surface vector
tmp<surfaceVectorField> nHatfv
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
//- Interface normal volume vector
tmp<surfaceScalarField> nHatf
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
//- Interface curvature
tmp<volScalarField> K
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
//- Near Interface of alpha1 and alpha2
tmp<volScalarField> nearInterface
(
const volScalarField& alpha1,
const volScalarField& alpha2
) const;
//- Near Interface of alpha'n
tmp<volScalarField> nearInterface() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "phaseSystemTemplates.H"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class modelType>
void Foam::phaseSystem::createSubModels
(
const dictTable& modelDicts,
HashTable
<
autoPtr<modelType>,
phasePairKey,
phasePairKey::hash
>& models
)
{
forAllConstIter(dictTable, modelDicts, iter)
{
const phasePairKey& key = iter.key();
models.insert
(
key,
modelType::New
(
*iter,
phasePairs_[key]
)
);
}
}
template<class modelType>
void Foam::phaseSystem::generatePairsAndSubModels
(
const word& modelName,
HashTable
<
autoPtr<modelType>,
phasePairKey,
phasePairKey::hash
>& models
)
{
dictTable modelDicts(lookup(modelName));
generatePairs(modelDicts);
createSubModels(modelDicts, models);
}
template<class modelType>
void Foam::phaseSystem::generatePairsAndSubModels
(
const word& modelName,
HashTable
<
HashTable<autoPtr<modelType> >,
phasePairKey,
phasePairKey::hash
>& models
)
{
typedef
HashTable<autoPtr<modelType>, phasePairKey, phasePairKey::hash>
modelTypeTable;
forAllConstIter(wordList, phaseNames_, phaseNameIter)
{
modelTypeTable tempModels;
generatePairsAndSubModels
(
IOobject::groupName(modelName, *phaseNameIter),
tempModels
);
forAllConstIter(typename modelTypeTable, tempModels, tempModelIter)
{
const phasePairKey key(tempModelIter.key());
if (!models.found(key))
{
models.insert
(
key,
HashTable<autoPtr<modelType> >()
);
}
models[tempModelIter.key()].insert
(
*phaseNameIter,
*tempModelIter
);
}
}
}
template <class modelType>
const modelType& Foam::phaseSystem::lookupSubModel(const phasePair& key) const
{
return
mesh().lookupObject<modelType>
(
IOobject::groupName(modelType::typeName, key.name())
);
}
template <class modelType>
const modelType& Foam::phaseSystem::lookupSubModel
(
const phaseModel& dispersed,
const phaseModel& continuous
) const
{
return lookupSubModel<modelType>(orderedPhasePair(dispersed, continuous));
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Global
setDeltaT
Description
Reset the timestep to maintain a constant maximum courant Number.
Reduction of time-step is immediate, but increase is damped to avoid
unstable oscillations.
\*---------------------------------------------------------------------------*/
if (adjustTimeStep)
{
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT
)
);
Info<< "deltaT = " << runTime.deltaTValue() << endl;
}
// ************************************************************************* //