thermophysicalModels: Corrections to selector error messages

This commit is contained in:
Will Bainbridge
2020-08-12 09:14:15 +01:00
parent 058562e1ef
commit aa20d9b895
5 changed files with 46 additions and 122 deletions

View File

@ -93,7 +93,7 @@ Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New
<< "Unknown " << combustionModel::typeName << " type "
<< combModelName << endl << endl;
const wordList names(dictionaryConstructorTablePtr_->toc());
const wordList names(dictionaryConstructorTablePtr_->sortedToc());
wordList thisCmpts;
thisCmpts.append(word::null);
@ -103,18 +103,17 @@ Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New
forAll(names, i)
{
wordList cmpts(basicThermo::splitThermoName(names[i], 1));
if (cmpts.size() != 1)
{
cmpts = basicThermo::splitThermoName(names[i], 6);
}
bool isValid = true;
for (label i = 1; i < cmpts.size() && isValid; ++ i)
{
isValid = isValid && cmpts[i] == thisCmpts[i];
}
if (isValid)
if
(
SubList<word>(cmpts, cmpts.size() - 1, 1)
== SubList<word>(thisCmpts, cmpts.size() - 1, 1)
)
{
validNames.append(cmpts[0]);
}
@ -124,41 +123,33 @@ Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New
<< "Valid " << combustionModel::typeName << " types for this "
<< "thermodynamic model are:" << endl << validNames << endl;
List<wordList> validCmpts1, validCmpts6;
validCmpts1.append(wordList(1, word::null));
validCmpts1[0][0] = combustionModel::typeName;
validCmpts6.append(wordList(6, word::null));
validCmpts6[0][0] = combustionModel::typeName;
validCmpts6[0][1] = "transport";
validCmpts6[0][2] = "thermo";
validCmpts6[0][3] = "equationOfState";
validCmpts6[0][4] = "specie";
validCmpts6[0][5] = "energy";
List<wordList> validCmpts;
validCmpts.append(wordList(6, word::null));
validCmpts[0][0] = combustionModel::typeName;
validCmpts[0][1] = "transport";
validCmpts[0][2] = "thermo";
validCmpts[0][3] = "equationOfState";
validCmpts[0][4] = "specie";
validCmpts[0][5] = "energy";
forAll(names, i)
{
const wordList cmpts1(basicThermo::splitThermoName(names[i], 1));
const wordList cmpts6(basicThermo::splitThermoName(names[i], 6));
if (cmpts1.size() == 1)
{
validCmpts1.append(cmpts1);
validCmpts.append(cmpts1);
validCmpts.last().append(wordList(5, "(any)"));
}
if (cmpts6.size() == 6)
{
validCmpts6.append(cmpts6);
validCmpts.append(cmpts6);
}
}
FatalErrorInFunction
<< "All " << validCmpts1[0][0]
<< " combinations are:" << endl << endl;
printTable(validCmpts1, FatalErrorInFunction);
FatalErrorInFunction << endl;
FatalErrorInFunction
<< "All " << validCmpts6[0][0] << '/' << validCmpts6[0][1]
<< "/thermoPhysics combinations are:" << endl << endl;
printTable(validCmpts6, FatalErrorInFunction);
<< "All " << validCmpts[0][0]
<< "/thermodynamics combinations are:" << endl << endl;
printTable(validCmpts, FatalErrorInFunction);
FatalErrorInFunction << exit(FatalError);
}

View File

@ -51,43 +51,34 @@ typename Table::iterator Foam::basicThermo::lookupCstrIter
<< nl << nl;
// Get the list of all the suitable thermo packages available
wordList validThermoTypeNames
(
tablePtr->sortedToc()
);
wordList validThermoTypeNames(tablePtr->sortedToc());
// Build a table of the thermo packages constituent parts
// Note: row-0 contains the names of constituent parts
List<wordList> validThermoTypeNameCmpts
(
validThermoTypeNames.size() + 1
);
DynamicList<wordList> validThermoTypeNameCmpts;
validThermoTypeNameCmpts[0].setSize(nCmpt);
forAll(validThermoTypeNameCmpts[0], j)
// Set row zero to the column headers
validThermoTypeNameCmpts.append(wordList(nCmpt));
forAll(validThermoTypeNameCmpts[0], i)
{
validThermoTypeNameCmpts[0][j] = cmptNames[j];
validThermoTypeNameCmpts[0][i] = cmptNames[i];
}
// Split the thermo package names into their constituent parts
// Removing incompatible entries from the list
label j = 0;
// Split the thermo package names into their constituent parts and add
// them to the table, removing any incompatible entries from the list
forAll(validThermoTypeNames, i)
{
wordList names
const wordList names
(
Thermo::splitThermoName(validThermoTypeNames[i], nCmpt)
);
if (names.size())
{
validThermoTypeNameCmpts[j++] = names;
validThermoTypeNameCmpts.append(names);
}
}
validThermoTypeNameCmpts.setSize(j);
// Print the table of available packages
// in terms of their constituent parts
printTable(validThermoTypeNameCmpts, FatalError);
FatalError<< exit(FatalError);

View File

@ -54,7 +54,7 @@ Foam::chemistryReductionMethod<ThermoType>::New
<< "Unknown " << typeName_() << " type " << methodName << endl
<< endl;
const wordList names(dictionaryConstructorTablePtr_->toc());
const wordList names(dictionaryConstructorTablePtr_->sortedToc());
wordList thisCmpts;
thisCmpts.append(word::null);
@ -68,41 +68,15 @@ Foam::chemistryReductionMethod<ThermoType>::New
{
const wordList cmpts(basicThermo::splitThermoName(names[i], 6));
bool isValid = true;
for (label i = 1; i < cmpts.size() && isValid; ++ i)
{
isValid = isValid && cmpts[i] == thisCmpts[i];
}
if (isValid)
if (SubList<word>(cmpts, 5, 1) == SubList<word>(thisCmpts, 5, 1))
{
validNames.append(cmpts[0]);
}
}
FatalErrorInFunction
<< "Valid " << typeName_() << " types for this thermodynamic model "
<< "are:" << endl << validNames << endl;
List<wordList> validCmpts;
validCmpts.append(wordList(6, word::null));
validCmpts[0][0] = typeName_();
validCmpts[0][1] = "transport";
validCmpts[0][2] = "thermo";
validCmpts[0][3] = "equationOfState";
validCmpts[0][4] = "specie";
validCmpts[0][5] = "energy";
forAll(names, i)
{
validCmpts.append(basicThermo::splitThermoName(names[i], 6));
}
FatalErrorInFunction
<< "All " << validCmpts[0][0] << '/' << validCmpts[0][1]
<< "/thermoPhysics combinations are:" << endl << endl;
printTable(validCmpts, FatalErrorInFunction);
FatalErrorInFunction << exit(FatalError);
<< "Valid " << typeName_() << " types are:" << validNames << endl
<< exit(FatalError);
}
return autoPtr<chemistryReductionMethod<ThermoType>>

View File

@ -54,7 +54,7 @@ Foam::chemistryTabulationMethod<ThermoType>::New
<< "Unknown " << typeName_() << " type " << methodName << endl
<< endl;
const wordList names(dictionaryConstructorTablePtr_->toc());
const wordList names(dictionaryConstructorTablePtr_->sortedToc());
wordList thisCmpts;
thisCmpts.append(word::null);
@ -68,41 +68,15 @@ Foam::chemistryTabulationMethod<ThermoType>::New
{
const wordList cmpts(basicThermo::splitThermoName(names[i], 6));
bool isValid = true;
for (label i = 1; i < cmpts.size() && isValid; ++ i)
{
isValid = isValid && cmpts[i] == thisCmpts[i];
}
if (isValid)
if (SubList<word>(cmpts, 5, 1) == SubList<word>(thisCmpts, 5, 1))
{
validNames.append(cmpts[0]);
}
}
FatalErrorInFunction
<< "Valid " << typeName_() << " types for this thermodynamic model "
<< "are:" << endl << validNames << endl;
List<wordList> validCmpts;
validCmpts.append(wordList(6, word::null));
validCmpts[0][0] = typeName_();
validCmpts[0][1] = "transport";
validCmpts[0][2] = "thermo";
validCmpts[0][3] = "equationOfState";
validCmpts[0][4] = "specie";
validCmpts[0][5] = "energy";
forAll(names, i)
{
validCmpts.append(basicThermo::splitThermoName(names[i], 6));
}
FatalErrorInFunction
<< "All " << validCmpts[0][0] << '/' << validCmpts[0][1]
<< "/thermoPhysics combinations are:" << endl << endl;
printTable(validCmpts, FatalErrorInFunction);
FatalErrorInFunction << exit(FatalError);
<< "Valid " << typeName_() << " types are:" << validNames << endl
<< exit(FatalError);
}
return autoPtr<chemistryTabulationMethod<ThermoType>>

View File

@ -98,15 +98,15 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
if (cstrIter == thermoConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown " << typeName_() << " type " << solverName << endl
<< "Unknown " << typeName_() << " type " << chemistryTypeDictNew
<< endl;
const wordList names(thermoConstructorTablePtr_->toc());
const wordList names(thermoConstructorTablePtr_->sortedToc());
wordList thisCmpts;
thisCmpts.append(word::null);
thisCmpts.append(word::null);
thisCmpts.append(basicThermo::splitThermoName(thermo.thermoName(), 4));
thisCmpts.append(basicThermo::splitThermoName(thermo.thermoName(), 5));
List<wordList> validNames;
validNames.append(wordList(2, word::null));
@ -116,20 +116,14 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
{
const wordList cmpts(basicThermo::splitThermoName(names[i], 7));
bool isValid = true;
for (label i = 2; i < cmpts.size() && isValid; ++ i)
{
isValid = isValid && cmpts[i] == thisCmpts[i];
}
if (isValid)
if (SubList<word>(cmpts, 5, 2) == SubList<word>(thisCmpts, 5, 2))
{
validNames.append(SubList<word>(cmpts, 2));
}
}
FatalErrorInFunction
<< "All " << validNames[0][0] << '/' << validNames[0][1]
<< "Valid " << validNames[0][0] << '/' << validNames[0][1]
<< " combinations for this thermodynamic model are:"
<< endl << endl;
printTable(validNames, FatalErrorInFunction);
@ -151,8 +145,8 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
}
FatalErrorInFunction
<< "All " << validCmpts[0][0] << '/' << validCmpts[0][1] << '/'
<< validCmpts[0][2] << "/thermoPhysics combinations are:"
<< "All " << validCmpts[0][0] << '/' << validCmpts[0][1]
<< "/thermodynamics combinations are:"
<< endl << endl;
printTable(validCmpts, FatalErrorInFunction);