basicMultiComponentMixture: Improved the handling of Ydefault

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

View File

@ -46,21 +46,61 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture
active_(species_.size(), true),
Y_(species_.size())
{
tmp<volScalarField> tYdefault;
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));
volScalarField Ydefault
tYdefault = new volScalarField
(
IOobject
(
YdefaultName,
exists(mesh.time().path()/mesh.time().timeName()/YdefaultName)
exists
(
mesh.time().path()/mesh.time().timeName()
/YdefaultName
)
? mesh.time().timeName()
: (
exists
(
mesh.time().path()/mesh.time().constant()/YdefaultName
mesh.time().path()/mesh.time().constant()
/YdefaultName
)
? mesh.time().constant()
: Time::timeName(0)
@ -71,6 +111,7 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture
),
mesh
);
}
Y_.set
(
@ -82,13 +123,14 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture
IOobject::groupName(species_[i], phaseName),
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
Ydefault
tYdefault()
)
);
}
}
// Do not enforce constraint of sum of mass fractions to equal 1 here
// - not applicable to all models

View File

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