phaseProperties: Handle special cases

No species specified: indicates phase is not present
Some species specified: missing entries assumed to have 0 mass-fraction
This commit is contained in:
Henry 2015-03-05 23:37:58 +00:00
parent e4e64e6eab
commit f9d7b982ce
2 changed files with 24 additions and 15 deletions

View file

@ -51,31 +51,38 @@ const Foam::NamedEnum<Foam::phaseProperties::phaseType, 4>
void Foam::phaseProperties::reorder(const wordList& specieNames) void Foam::phaseProperties::reorder(const wordList& specieNames)
{ {
if (names_.size() != specieNames.size()) // ***HGW Unfortunately in the current implementation it is assumed that
// if no species are specified the phase is not present and this MUST
// be checked at the point of use. This needs a rewrite.
if (!names_.size())
{ {
FatalErrorIn return;
(
"void phaseProperties::reorder(const wordList& specieNames)"
) << "Number of specie specifications "
<< names_.size() << nl
<< " is not equal to the number of species "
<< specieNames.size()
<< exit(FatalError);
} }
// Store the current sames and mass-fractions
List<word> names0(names_); List<word> names0(names_);
scalarField Y0(Y_); scalarField Y0(Y_);
// Update the specie names to those given
names_ = specieNames; names_ = specieNames;
forAll(names_, i) // Re-size mass-fractions if necessary, initialize to 0
if (names_.size() != names0.size())
{
Y_.setSize(names_.size());
Y_ = 0;
}
// Set the mass-fraction for each specie in the list to the corresponding
// value in the original list
forAll(names0, i)
{ {
bool found = false; bool found = false;
forAll(names0, j) forAll(names_, j)
{ {
if (names0[j] == names_[i]) if (names_[j] == names0[i])
{ {
Y_[i] = Y0[j]; Y_[j] = Y0[i];
found = true; found = true;
break; break;
} }
@ -86,8 +93,9 @@ void Foam::phaseProperties::reorder(const wordList& specieNames)
FatalErrorIn FatalErrorIn
( (
"void phaseProperties::reorder(const wordList&)" "void phaseProperties::reorder(const wordList&)"
) << "Could not find specie " << names_[i] ) << "Could not find specie " << names0[i]
<< " in species properties " << names0 << " in list " << names_
<< " for phase " << phaseTypeNames[phase_]
<< exit(FatalError); << exit(FatalError);
} }
} }

View file

@ -63,6 +63,7 @@ class CompositionModel
public CloudSubModelBase<CloudType> public CloudSubModelBase<CloudType>
{ {
// Private data // Private data
//- Reference to the thermo database //- Reference to the thermo database
const SLGThermo& thermo_; const SLGThermo& thermo_;