Files
openfoam/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C

270 lines
6.5 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 "ReactingCloud.H"
#include "CompositionModel.H"
#include "PhaseChangeModel.H"
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::checkSuppliedComposition
(
const scalarField& YSupplied,
const scalarField& Y,
const word& YName
)
{
if (YSupplied.size() != Y.size())
{
FatalErrorIn
(
"ReactingCloud<ParcelType>::checkSuppliedComposition"
"("
"const scalarField&, "
"const scalarField&, "
"const word&"
")"
) << YName << " supplied, but size is not compatible with "
<< "parcel composition: " << nl << " "
<< YName << "(" << YSupplied.size() << ") vs required composition "
<< YName << "(" << Y.size() << ")" << nl
<< abort(FatalError);
}
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::preEvolve()
{
ThermoCloud<ParcelType>::preEvolve();
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::evolveCloud()
{
typename ParcelType::trackData td(*this);
label preInjectionSize = this->size();
this->surfaceFilm().inject(td);
// Update the cellOccupancy if the size of the cloud has changed
// during the injection.
if (preInjectionSize != this->size())
{
this->updateCellOccupancy();
preInjectionSize = this->size();
}
this->injection().inject(td);
if (this->solution().coupled())
{
resetSourceTerms();
}
// Assume that motion will update the cellOccupancy as necessary
// before it is required.
motion(td);
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::motion
(
typename ParcelType::trackData& td
)
{
ThermoCloud<ParcelType>::motion(td);
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::postEvolve()
{
ThermoCloud<ParcelType>::postEvolve();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParcelType>
Foam::ReactingCloud<ParcelType>::ReactingCloud
(
const word& cloudName,
const volScalarField& rho,
const volVectorField& U,
const dimensionedVector& g,
const SLGThermo& thermo,
bool readFields
)
:
ThermoCloud<ParcelType>(cloudName, rho, U, g, thermo, false),
reactingCloud(),
constProps_(this->particleProperties()),
compositionModel_
(
CompositionModel<ReactingCloud<ParcelType> >::New
(
this->subModelProperties(),
*this
)
),
phaseChangeModel_
(
PhaseChangeModel<ReactingCloud<ParcelType> >::New
(
this->subModelProperties(),
*this
)
),
rhoTrans_(thermo.carrier().species().size()),
dMassPhaseChange_(0.0)
{
// Set storage for mass source fields and initialise to zero
forAll(rhoTrans_, i)
{
const word& specieName = thermo.carrier().species()[i];
rhoTrans_.set
(
i,
new DimensionedField<scalar, volMesh>
(
IOobject
(
this->name() + "rhoTrans_" + specieName,
this->db().time().timeName(),
this->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
this->mesh(),
dimensionedScalar("zero", dimMass, 0.0)
)
);
}
if (readFields)
{
ParcelType::readFields(*this);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ParcelType>
Foam::ReactingCloud<ParcelType>::~ReactingCloud()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::checkParcelProperties
(
ParcelType& parcel,
const scalar lagrangianDt,
const bool fullyDescribed
)
{
ThermoCloud<ParcelType>::checkParcelProperties
(
parcel,
lagrangianDt,
fullyDescribed
);
if (!fullyDescribed)
{
parcel.Y() = composition().YMixture0();
}
else
{
checkSuppliedComposition
(
parcel.Y(),
composition().YMixture0(),
"YMixture"
);
}
// derived information - store initial mass
parcel.mass0() = parcel.mass();
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::resetSourceTerms()
{
ThermoCloud<ParcelType>::resetSourceTerms();
forAll(rhoTrans_, i)
{
rhoTrans_[i].field() = 0.0;
}
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::evolve()
{
if (this->solution().active())
{
preEvolve();
evolveCloud();
postEvolve();
info();
Info<< endl;
}
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::info() const
{
ThermoCloud<ParcelType>::info();
Info<< " Mass transfer phase change = "
<< returnReduce(dMassPhaseChange_, sumOp<scalar>()) << nl;
}
template<class ParcelType>
void Foam::ReactingCloud<ParcelType>::addToMassPhaseChange(const scalar dMass)
{
dMassPhaseChange_ += dMass;
}
// ************************************************************************* //