From aa20d9b895f864135ce1519f1eaf8604d1b6dc53 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 12 Aug 2020 09:14:15 +0100 Subject: [PATCH] thermophysicalModels: Corrections to selector error messages --- .../combustionModel/combustionModelNew.C | 51 ++++++++----------- .../basic/basicThermo/basicThermoTemplates.C | 29 ++++------- .../chemistryReductionMethodNew.C | 34 ++----------- .../chemistryTabulationMethodNew.C | 34 ++----------- .../basicChemistryModelNew.C | 20 +++----- 5 files changed, 46 insertions(+), 122 deletions(-) diff --git a/src/combustionModels/combustionModel/combustionModelNew.C b/src/combustionModels/combustionModel/combustionModelNew.C index 51ad8150ba..076c59290b 100644 --- a/src/combustionModels/combustionModel/combustionModelNew.C +++ b/src/combustionModels/combustionModel/combustionModelNew.C @@ -93,7 +93,7 @@ Foam::autoPtr 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::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(cmpts, cmpts.size() - 1, 1) + == SubList(thisCmpts, cmpts.size() - 1, 1) + ) { validNames.append(cmpts[0]); } @@ -124,41 +123,33 @@ Foam::autoPtr Foam::combustionModel::New << "Valid " << combustionModel::typeName << " types for this " << "thermodynamic model are:" << endl << validNames << endl; - List 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 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); } diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C b/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C index 569022d3a5..ba9e3b808e 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C @@ -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 validThermoTypeNameCmpts - ( - validThermoTypeNames.size() + 1 - ); + DynamicList 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); diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C index e31688eda6..dd22297b3d 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C @@ -54,7 +54,7 @@ Foam::chemistryReductionMethod::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::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(cmpts, 5, 1) == SubList(thisCmpts, 5, 1)) { validNames.append(cmpts[0]); } } FatalErrorInFunction - << "Valid " << typeName_() << " types for this thermodynamic model " - << "are:" << endl << validNames << endl; - - List 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> diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C index 29fc3c08bb..8e4680f162 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C @@ -54,7 +54,7 @@ Foam::chemistryTabulationMethod::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::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(cmpts, 5, 1) == SubList(thisCmpts, 5, 1)) { validNames.append(cmpts[0]); } } FatalErrorInFunction - << "Valid " << typeName_() << " types for this thermodynamic model " - << "are:" << endl << validNames << endl; - - List 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> diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelNew.C index 68b994891b..806cab953b 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelNew.C @@ -98,15 +98,15 @@ Foam::autoPtr 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 validNames; validNames.append(wordList(2, word::null)); @@ -116,20 +116,14 @@ Foam::autoPtr 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(cmpts, 5, 2) == SubList(thisCmpts, 5, 2)) { validNames.append(SubList(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::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);