basicMultiComponentMixture: Improved the handling of Ydefault

This commit is contained in:
Henry Weller
2016-07-17 22:59:25 +01:00
parent 1d57269680
commit 8f16204390
2 changed files with 78 additions and 36 deletions

View File

@ -46,21 +46,61 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture
active_(species_.size(), true), active_(species_.size(), true),
Y_(species_.size()) Y_(species_.size())
{ {
tmp<volScalarField> tYdefault;
forAll(species_, i) forAll(species_, i)
{
IOobject header
(
IOobject::groupName(species_[i], phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ
);
// Check if field exists and can be read
if (header.headerOk())
{
Y_.set
(
i,
new volScalarField
(
IOobject
(
IOobject::groupName(species_[i], phaseName),
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
)
);
}
else
{
// Read Ydefault if not already read
if (!tYdefault.valid())
{ {
word YdefaultName(IOobject::groupName("Ydefault", phaseName)); word YdefaultName(IOobject::groupName("Ydefault", phaseName));
volScalarField Ydefault tYdefault = new volScalarField
( (
IOobject IOobject
( (
YdefaultName, YdefaultName,
exists(mesh.time().path()/mesh.time().timeName()/YdefaultName) exists
(
mesh.time().path()/mesh.time().timeName()
/YdefaultName
)
? mesh.time().timeName() ? mesh.time().timeName()
: ( : (
exists exists
( (
mesh.time().path()/mesh.time().constant()/YdefaultName mesh.time().path()/mesh.time().constant()
/YdefaultName
) )
? mesh.time().constant() ? mesh.time().constant()
: Time::timeName(0) : Time::timeName(0)
@ -71,6 +111,7 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture
), ),
mesh mesh
); );
}
Y_.set Y_.set
( (
@ -82,13 +123,14 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture
IOobject::groupName(species_[i], phaseName), IOobject::groupName(species_[i], phaseName),
mesh.time().timeName(), mesh.time().timeName(),
mesh, mesh,
IOobject::READ_IF_PRESENT, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
Ydefault tYdefault()
) )
); );
} }
}
// Do not enforce constraint of sum of mass fractions to equal 1 here // Do not enforce constraint of sum of mass fractions to equal 1 here
// - not applicable to all models // - not applicable to all models

View File

@ -11,7 +11,7 @@ FoamFile
format ascii; format ascii;
class volScalarField; class volScalarField;
location "0"; location "0";
object Ydefault; object Ydefault.gas;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //