Commit 6fd90e45 authored by mattijs's avatar mattijs
Browse files

Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

parents 239dc3a1 062846d7
sprayFoam.C
EXE = $(FOAM_APPBIN)/sprayFoam
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I${LIB_SRC}/meshTools/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/lagrangian/spray/lnInclude \
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(FOAM_SOLVERS)/lagrangian/reactingParcelFoam
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lcompressibleTurbulenceModel \
-lcompressibleRASModels \
-lcompressibleLESModels \
-llagrangian \
-llagrangianIntermediate \
-llagrangianSpray \
-lspecie \
-lbasicThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
-lchemistryModel \
-lradiationModels \
-lODE \
-lregionModels \
-lsurfaceFilmModels \
-lsampling
if (chemistry.chemistry())
{
Info<< "Solving chemistry" << endl;
chemistry.solve
(
runTime.value() - runTime.deltaTValue(),
runTime.deltaTValue()
);
// turbulent time scale
if (turbulentReaction)
{
tmp<volScalarField> tepsilon(turbulence->epsilon());
const volScalarField& epsilon = tepsilon();
tmp<volScalarField> tmuEff(turbulence->muEff());
const volScalarField& muEff = tmuEff();
tmp<volScalarField> ttc(chemistry.tc());
const volScalarField& tc = ttc();
forAll(epsilon, i)
{
if (epsilon[i] > 0)
{
// Chalmers PaSR model
scalar tk = Cmix.value()*Foam::sqrt(muEff[i]/rho[i]/epsilon[i]);
kappa[i] =
(runTime.deltaTValue() + tc[i])
/(runTime.deltaTValue() + tc[i] + tk);
}
else
{
// Return to laminar combustion
kappa[i] = 1.0;
}
}
}
else
{
kappa = 1.0;
}
chemistrySh = kappa*chemistry.Sh()();
}
Info<< "\nConstructing reacting cloud" << endl;
basicSprayCloud parcels
(
"sprayCloud",
rho,
U,
g,
slgThermo
);
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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
sprayFoam
Description
Transient PIMPLE solver for compressible, laminar or turbulent flow with
spray parcels.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "hCombustionThermo.H"
#include "turbulenceModel.H"
#include "basicSprayCloud.H"
#include "psiChemistryModel.H"
#include "chemistrySolver.H"
#include "radiationModel.H"
#include "SLGThermo.H"
#include "pimpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "readChemistryProperties.H"
#include "readGravitationalAcceleration.H"
#include "createFields.H"
#include "createClouds.H"
#include "createRadiationModel.H"
#include "initContinuityErrs.H"
#include "readTimeControls.H"
#include "compressibleCourantNo.H"
#include "setInitialDeltaT.H"
pimpleControl pimple(mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readTimeControls.H"
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
parcels.evolve();
#include "chemistry.H"
#include "rhoEqn.H"
// --- Pressure-velocity PIMPLE corrector loop
for (pimple.start(); pimple.loop(); pimple++)
{
#include "UEqn.H"
#include "YEqn.H"
#include "hsEqn.H"
// --- PISO loop
for (int corr=0; corr<pimple.nCorr(); corr++)
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence->correct();
}
}
rho = thermo.rho();
if (runTime.write())
{
chemistry.dQ()().write();
}
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //
......@@ -7,6 +7,7 @@ wmake $makeType distributionModels
wmake $makeType basic
wmake $makeType solidParticle
wmake $makeType intermediate
wmake $makeType spray
wmake $makeType dieselSpray
wmake $makeType dsmc
wmake $makeType coalCombustion
......
......@@ -126,17 +126,6 @@ void Foam::KinematicCloud<CloudType>::solve(TrackData& td)
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::preEvolve()
{
Info<< "\nSolving cloud " << this->name() << endl;
this->dispersion().cacheFields(true);
forces_.cacheFields(true);
updateCellOccupancy();
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::buildCellOccupancy()
{
......@@ -310,6 +299,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
U_(U),
mu_(mu),
g_(g),
pAmbient_(0.0),
forces_
(
*this,
......@@ -403,6 +393,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
U_(c.U_),
mu_(c.mu_),
g_(c.g_),
pAmbient_(c.pAmbient_),
forces_(c.forces_),
functions_(c.functions_),
dispersionModel_(c.dispersionModel_->clone()),
......@@ -478,6 +469,7 @@ Foam::KinematicCloud<CloudType>::KinematicCloud
U_(c.U_),
mu_(c.mu_),
g_(c.g_),
pAmbient_(c.pAmbient_),
forces_(*this, mesh),
functions_(*this),
dispersionModel_(NULL),
......@@ -507,7 +499,7 @@ bool Foam::KinematicCloud<CloudType>::hasWallImpactDistance() const
template<class CloudType>
void Foam::KinematicCloud<CloudType>::checkParcelProperties
void Foam::KinematicCloud<CloudType>::setParcelThermoProperties
(
parcelType& parcel,
const scalar lagrangianDt,
......@@ -518,7 +510,17 @@ void Foam::KinematicCloud<CloudType>::checkParcelProperties
{
parcel.rho() = constProps_.rho0();
}
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::checkParcelProperties
(
parcelType& parcel,
const scalar lagrangianDt,
const bool fullyDescribed
)
{
const scalar carrierDt = mesh_.time().deltaTValue();
parcel.stepFraction() = (carrierDt - lagrangianDt)/carrierDt;
parcel.typeId() = constProps_.parcelTypeId();
......@@ -600,6 +602,20 @@ void Foam::KinematicCloud<CloudType>::scaleSources()
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::preEvolve()
{
Info<< "\nSolving cloud " << this->name() << endl;
this->dispersion().cacheFields(true);
forces_.cacheFields(true);
updateCellOccupancy();
pAmbient_ = constProps_.dict().template
lookupOrDefault<scalar>("pAmbient", pAmbient_);
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::evolve()
{
......
......@@ -176,6 +176,9 @@ protected:
//- Gravity
const dimensionedVector& g_;
//- Averaged ambient domain pressure
scalar pAmbient_;
//- Optional particle forces
forceType forces_;
......@@ -230,9 +233,6 @@ protected:
template<class TrackData>
void solve(TrackData& td);
//- Pre-evolve
void preEvolve();
//- Build the cellOccupancy
void buildCellOccupancy();
......@@ -367,6 +367,12 @@ public:
//- Gravity
inline const dimensionedVector& g() const;
//- Return const-access to the ambient pressure
inline scalar pAmbient() const;
//- Return reference to the ambient pressure
inline scalar& pAmbient();
//- Optional particle forces
// inline const typename parcelType::forceType& forces() const;
......@@ -456,6 +462,12 @@ public:
//- Total rotational kinetic energy in the system
inline scalar rotationalKineticEnergyOfSystem() const;
//- Penetration for percentage of the current total mass
inline scalar penetration(const scalar& prc) const;
//- Mean diameter Dij
inline scalar Dij(const label i, const label j) const;
// Fields
......@@ -474,6 +486,14 @@ public:
// Cloud evolution functions
//- Set parcel thermo properties
void setParcelThermoProperties
(
parcelType& parcel,
const scalar lagrangianDt,
const bool fullyDescribed
);
//- Check parcel properties
void checkParcelProperties
(
......@@ -514,6 +534,9 @@ public:
//- Apply scaling to (transient) cloud sources
void scaleSources();
//- Pre-evolve
void preEvolve();
//- Evolve the cloud
void evolve();
......
......@@ -109,6 +109,20 @@ inline const Foam::dimensionedVector& Foam::KinematicCloud<CloudType>::g() const
}
template<class CloudType>
inline Foam::scalar Foam::KinematicCloud<CloudType>::pAmbient() const
{
return pAmbient_;
}
template<class CloudType>
inline Foam::scalar& Foam::KinematicCloud<CloudType>::pAmbient()
{
return pAmbient_;
}
template<class CloudType>
//inline const typename CloudType::parcelType::forceType&
inline const typename Foam::KinematicCloud<CloudType>::forceType&
......@@ -264,6 +278,131 @@ Foam::KinematicCloud<CloudType>::rotationalKineticEnergyOfSystem() const
}
template<class CloudType>
inline Foam::scalar Foam::KinematicCloud<CloudType>::Dij
(
const label i,
const label j
) const
{
scalar si = 0.0;
scalar sj = 0.0;
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
{
const parcelType& p = iter();
si += p.nParticle()*pow(p.d(), i);
sj += p.nParticle()*pow(p.d(), j);
}
reduce(si, sumOp<scalar>());
reduce(sj, sumOp<scalar>());
sj = max(sj, VSMALL);
return si/sj;
}
template<class CloudType>
inline Foam::scalar Foam::KinematicCloud<CloudType>::penetration
(
const scalar& prc
) const
{
scalar distance = 0.0;
scalar mTot = 0.0;
label np = this->size();
// arrays containing the parcels mass and
// distance from injector in ascending order
scalarField mass(np);
scalarField dist(np);
if (np > 0)
{
label n = 0;
// first arrange the parcels in ascending order
// the first parcel is closest to its injection position
// and the last one is most far away.
forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
{
const parcelType& p = iter();
scalar mi = p.nParticle()*p.mass();
scalar di = mag(p.position() - p.position0());
mTot += mi;
// insert at the last place
mass[n] = mi;
dist[n] = di;
label i = 0;
bool found = false;
// insert the parcel in the correct place
// and move the others
while ((i < n) && (!found))
{
if (di < dist[i])
{
found = true;
for (label j=n; j>i; j--)
{
mass[j] = mass[j-1];
dist[j] = dist[j-1];
}
mass[i] = mi;
dist[i] = di;
}
i++;
}
n++;
}
}
reduce(mTot, sumOp<scalar>());
if (np > 0)
{
scalar mLimit = prc*mTot;
scalar mOff = (1.0 - prc)*mTot;
if (np > 1)
{
// 'prc' is large enough that the parcel most far
// away will be used, no need to loop...
if (mLimit > mTot - mass[np-1])
{
distance = dist[np-1];
}
else
{
scalar mOffSum = 0.0;
label i = np;
while ((mOffSum < mOff) && (i>0))
{
i--;
mOffSum += mass[i];
}
distance =
dist[i+1]
+ (dist[i] - dist[i+1])*(mOffSum - mOff)
/mass[i+1] ;
}
}
else
{
distance = dist[0];
}
}
reduce(distance, maxOp<scalar>());
return distance;
}
template<class CloudType>
inline Foam::cachedRandom& Foam::KinematicCloud<CloudType>::rndGen()
{
......
......@@ -174,6 +174,9 @@ public:
//- Return const access to the coupled flag
inline const Switch coupled() const;
//- Return non-const access to the coupled flag
inline Switch& coupled();
//- Return const access to the cell value correction flag
inline const Switch cellValueSourceCorrection() const;
......
......@@ -101,6 +101,12 @@ inline Foam::scalar Foam::cloudSolution::trackTime() const
}
inline Foam::Switch& Foam::cloudSolution::coupled()
{
return coupled_;
}
inline const Foam::Switch Foam::cloudSolution::coupled() const
{
return coupled_;
......
......@@ -224,22 +224,18 @@ Foam::ReactingCloud<CloudType>::~ReactingCloud()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ReactingCloud<CloudType>::checkParcelProperties
void Foam::ReactingCloud<CloudType>::setParcelThermoProperties
(
parcelType& parcel,
const scalar lagrangianDt,
const bool fullyDescribed
)
{
CloudType::checkParcelProperties
(
parcel,
lagrangianDt,
fullyDescribed
);
CloudType::setParcelThermoProperties(parcel, lagrangianDt, fullyDescribed);
if (!fullyDescribed)
{
parcel.pc() = this->thermo().thermo().p()[parcel.cell()];
parcel.Y() = composition().YMixture0();