From 029e7e04419e333bc4d66416d3cbb699c050f9ec Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Thu, 5 Mar 2015 23:37:58 +0000 Subject: [PATCH] phaseProperties: Handle special cases No species specified: indicates phase is not present Some species specified: missing entries assumed to have 0 mass-fraction --- .../phaseProperties/phaseProperties.C | 38 +++++++++++-------- .../CompositionModel/CompositionModel.H | 1 + 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C index ed00dafaa76..fcf5da9ae72 100644 --- a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C +++ b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phaseProperties.C @@ -51,31 +51,38 @@ const Foam::NamedEnum<Foam::phaseProperties::phaseType, 4> 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 - ( - "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); + return; } + // Store the current sames and mass-fractions List<word> names0(names_); scalarField Y0(Y_); + // Update the specie names to those given 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; - 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; break; } @@ -86,8 +93,9 @@ void Foam::phaseProperties::reorder(const wordList& specieNames) FatalErrorIn ( "void phaseProperties::reorder(const wordList&)" - ) << "Could not find specie " << names_[i] - << " in species properties " << names0 + ) << "Could not find specie " << names0[i] + << " in list " << names_ + << " for phase " << phaseTypeNames[phase_] << exit(FatalError); } } diff --git a/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.H b/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.H index b8f60a6f207..7938b702c4d 100644 --- a/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.H +++ b/src/lagrangian/intermediate/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.H @@ -63,6 +63,7 @@ class CompositionModel public CloudSubModelBase<CloudType> { // Private data + //- Reference to the thermo database const SLGThermo& thermo_; -- GitLab