From 3416151deed918de563586f3ecdb91d566a30a2f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 14 Jul 2021 11:12:08 +0200 Subject: [PATCH 1/6] ENH: improve isolation of basicThermo internals (as private) - getThermoOrDie: returns constructor pointer, or FatalError. Better isolation and avoids additional template/typename previously needed with ambiguous method name (lookupThermo). - makeThermoName: centralize dictionary -> stringified name - splitThermoName: use stringOps functionality --- .../combustionModelTemplates.C | 93 ++++---- .../basic/basicThermo/basicThermo.C | 186 +++++++++++----- .../basic/basicThermo/basicThermo.H | 92 +++++--- .../basic/basicThermo/basicThermoTemplates.C | 199 ++++++------------ .../chemistryReductionMethodNew.C | 73 ++++--- .../chemistryTabulationMethodNew.C | 75 +++---- .../basicChemistryModelTemplates.C | 89 ++++---- .../basicSolidChemistryModel.H | 8 +- .../basicSolidChemistryModelNew.C | 77 +++---- 9 files changed, 468 insertions(+), 424 deletions(-) diff --git a/src/combustionModels/combustionModel/combustionModelTemplates.C b/src/combustionModels/combustionModel/combustionModelTemplates.C index e4576b87aa..fcf4d4a059 100644 --- a/src/combustionModels/combustionModel/combustionModelTemplates.C +++ b/src/combustionModels/combustionModel/combustionModelTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,6 +73,7 @@ Foam::autoPtr Foam::combustionModel::New << "combustion model " << combModelName << "." << endl; } + const word compCombModelName ( combModelName + '<' + CombustionModel::reactionThermo::typeName + '>' @@ -87,20 +88,27 @@ Foam::autoPtr Foam::combustionModel::New const auto& cnstrTable = *(CombustionModel::dictionaryConstructorTablePtr_); - auto compCstrIter = cnstrTable.cfind(compCombModelName); + auto ctorIter = cnstrTable.cfind(thermoCombModelName); - auto thermoCstrIter = cnstrTable.cfind(thermoCombModelName); - - if (!compCstrIter.found() && !thermoCstrIter.found()) + if (!ctorIter.found()) { - wordList thisCmpts; - thisCmpts.append(word::null); - thisCmpts.append(CombustionModel::reactionThermo::typeName); - thisCmpts.append(basicThermo::splitThermoName(thermo.thermoName(), 5)); + ctorIter = cnstrTable.cfind(compCombModelName); + } - wordList validNames; + if (!ctorIter.found()) + { + const wordList names(cnstrTable.sortedToc()); - List validCmpts2; + /// DynamicList thisCmpts(6); + /// thisCmpts.append(CombustionModel::reactionThermo::typeName); + /// thisCmpts.append(basicThermo::splitThermoName + /// ( + /// basicThermo::splitThermoName(thermo.thermoName(), 5) + /// ); + /// + /// DynamicList validNames; + + DynamicList validCmpts2; validCmpts2.append ( // Header @@ -112,7 +120,7 @@ Foam::autoPtr Foam::combustionModel::New }) ); - List validCmpts7; + DynamicList validCmpts7; validCmpts7.append ( // Header @@ -129,61 +137,56 @@ Foam::autoPtr Foam::combustionModel::New }) ); - for (const word& validName : cnstrTable.sortedToc()) + for (const word& validName : names) { - wordList cmpts(basicThermo::splitThermoName(validName, 2)); + wordList cmpts(basicThermo::splitThermoName(validName, 0)); if (cmpts.size() == 2) { - validCmpts2.append(cmpts); + validCmpts2.append(std::move(cmpts)); } - else + else if (cmpts.size() == 7) { - cmpts = basicThermo::splitThermoName(validName, 7); - if (cmpts.size() == 7) - { - validCmpts7.append(cmpts); - } - } - - bool isValid = true; - for (label i = 1; i < cmpts.size() && isValid; ++i) - { - isValid = isValid && cmpts[i] == thisCmpts[i]; - } - - if (isValid) - { - validNames.append(cmpts[0]); + /// if (thisCmpts == SubList(cmpts, 6, 1)) + /// { + /// validNames.append(cmpts[0]); + /// } + validCmpts7.append(std::move(cmpts)); } } - FatalErrorInLookup ( combustionModel::typeName, combModelName, cnstrTable - ) - << "All " << validCmpts2[0][0] << '/' << validCmpts2[0][1] - << " combinations are:" << nl << nl; + ); - printTable(validCmpts2, FatalErrorInFunction) - << nl; + if (validCmpts2.size() > 1) + { + FatalError + << "All " << validCmpts2[0][0] << '/' << validCmpts2[0][1] + << " combinations are:" << nl << nl; - FatalErrorInFunction - << "All " << validCmpts7[0][0] << '/' << validCmpts7[0][1] - << "/thermoPhysics combinations are:" << nl << nl; + printTable(validCmpts2, FatalError) << nl; + } - printTable(validCmpts7, FatalErrorInFunction) + if (validCmpts7.size() > 1) + { + FatalError + << "All " << validCmpts7[0][0] << '/' << validCmpts7[0][1] + << "/thermoPhysics combinations are:" << nl << nl; + + printTable(validCmpts7, FatalError) << nl; + } + + FatalError << exit(FatalError); } return autoPtr ( - thermoCstrIter.found() - ? thermoCstrIter()(combModelName, thermo, turb, combustionProperties) - : compCstrIter()(combModelName, thermo, turb, combustionProperties) + ctorIter()(combModelName, thermo, turb, combustionProperties) ); } diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index b25fd1d891..b2204d0d42 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -27,6 +27,8 @@ License \*---------------------------------------------------------------------------*/ #include "basicThermo.H" +#include "stringOps.H" +#include "wordIOList.H" #include "zeroGradientFvPatchFields.H" #include "fixedEnergyFvPatchScalarField.H" #include "gradientEnergyFvPatchScalarField.H" @@ -47,6 +49,115 @@ namespace Foam const Foam::word Foam::basicThermo::dictName("thermophysicalProperties"); +const Foam::wordList Foam::basicThermo::componentHeader4 +({ + "type", + "mixture", + "properties", + "energy" +}); + +const Foam::wordList Foam::basicThermo::componentHeader7 +({ + "type", + "mixture", + "transport", + "thermo", + "equationOfState", + "specie", + "energy" +}); + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::Ostream& Foam::basicThermo::printThermoNames +( + Ostream& os, + const wordList& cmptNames, + const wordList& thermoNames +) +{ + const int nCmpt = cmptNames.size(); + + // Build a table of constituent parts by split name into constituent parts + // - remove incompatible entries from the list + // - note: row-0 contains the names of constituent parts (ie, the header) + + DynamicList outputTbl; + outputTbl.resize(thermoNames.size()+1); + + label rowi = 0; + + // Header + outputTbl[rowi] = cmptNames; + if (!outputTbl[rowi].empty()) + { + ++rowi; + } + + for (const word& thermoName : thermoNames) + { + outputTbl[rowi] = basicThermo::splitThermoName(thermoName, nCmpt); + if (!outputTbl[rowi].empty()) + { + ++rowi; + } + } + + if (rowi > 1) + { + outputTbl.resize(rowi); + Foam::printTable(outputTbl, os); + } + + return os; +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::word Foam::basicThermo::makeThermoName +( + const dictionary& thermoTypeDict, + const wordList*& cmptHeaderPtr +) +{ + if (thermoTypeDict.found("properties")) + { + if (cmptHeaderPtr) + { + cmptHeaderPtr = &(componentHeader4); + } + + return word + ( + thermoTypeDict.get("type") + '<' + + thermoTypeDict.get("mixture") + '<' + + thermoTypeDict.get("properties") + ',' + + thermoTypeDict.get("energy") + ">>" + ); + } + else + { + if (cmptHeaderPtr) + { + cmptHeaderPtr = &(componentHeader7); + } + + return word + ( + thermoTypeDict.get("type") + '<' + + thermoTypeDict.get("mixture") + '<' + + thermoTypeDict.get("transport") + '<' + + thermoTypeDict.get("thermo") + '<' + + thermoTypeDict.get("equationOfState") + '<' + + thermoTypeDict.get("specie") + ">>," + + thermoTypeDict.get("energy") + ">>>" + ); + } +} + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -60,14 +171,17 @@ Foam::wordList Foam::basicThermo::heBoundaryBaseTypes() { if (isA(tbf[patchi])) { - const fixedJumpFvPatchScalarField& pf = - dynamic_cast(tbf[patchi]); + const auto& pf = + dynamic_cast + ( + tbf[patchi] + ); hbt[patchi] = pf.interfaceFieldType(); } else if (isA(tbf[patchi])) { - const fixedJumpAMIFvPatchScalarField& pf = + const auto& pf = dynamic_cast ( tbf[patchi] @@ -345,13 +459,14 @@ const Foam::basicThermo& Foam::basicThermo::lookupThermo forAllConstIters(thermos, iter) { + thermo = iter.val(); if ( - &(iter()->he().internalField()) + &(thermo->he().internalField()) == &(pf.internalField()) ) { - return *iter(); + return *thermo; } } @@ -455,60 +570,29 @@ void Foam::basicThermo::validate Foam::wordList Foam::basicThermo::splitThermoName ( - const word& thermoName, - const int nCmpt + const std::string& thermoName, + const int nExpectedCmpts ) { - wordList cmpts(nCmpt); + // Split on ",<>" but include space for good measure. + // Splits things like + // "hePsiThermo>,enthalpy>>>" - string::size_type beg=0, end=0, endb=0, endc=0; - int i = 0; + const auto parsed = stringOps::splitAny(thermoName, " ,<>"); + const int nParsed(parsed.size()); - while - ( - (endb = thermoName.find('<', beg)) != string::npos - || (endc = thermoName.find(',', beg)) != string::npos - ) + wordList cmpts; + + if (!nExpectedCmpts || nParsed == nExpectedCmpts) { - if (endb == string::npos) - { - end = endc; - } - else if ((endc = thermoName.find(',', beg)) != string::npos) - { - end = std::min(endb, endc); - } - else - { - end = endb; - } + cmpts.resize(nParsed); - if (beg < end) + auto iter = cmpts.begin(); + for (const auto& sub : parsed) { - cmpts[i] = thermoName.substr(beg, end-beg); - cmpts[i++].replaceAll(">",""); - - // If the number of number of components in the name - // is greater than nCmpt return an empty list - if (i == nCmpt) - { - return wordList::null(); - } + *iter = word(sub.str()); + ++iter; } - beg = end + 1; - } - - // If the number of number of components in the name is not equal to nCmpt - // return an empty list - if (i + 1 != nCmpt) - { - return wordList::null(); - } - - if (beg < thermoName.size()) - { - cmpts[i] = thermoName.substr(beg, string::npos); - cmpts[i].replaceAll(">",""); } return cmpts; diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.H b/src/thermophysicalModels/basic/basicThermo/basicThermo.H index dcd7dce5df..f4ffb6491f 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.H @@ -65,6 +65,55 @@ class basicThermo : public IOdictionary { + // Private Data + + //- Components names/order + static const wordList componentHeader4; + + //- Components names/order + static const wordList componentHeader7; + + + // Private Member Functions + + //- Construct name of thermo package from dictionary components + static word makeThermoName + ( + const dictionary& dict, + const wordList*& cmptHeaderPtr + ); + + //- Look up field from registry or construct and store + static volScalarField& lookupOrConstruct + ( + const fvMesh& mesh, + const word& fieldName, + bool& isOwner //!< Stored to registry by this instance + ); + + //- Generic lookup for thermodynamics package thermoTypeName + // \return constructor pointer, or FatalError + template + static typename ThermoConstructTable::mapped_type + getThermoOrDie + ( + const dictionary& thermoTypeDict, + ThermoConstructTable& thermoTable, + const word& thermoTypeName, + const wordList& cmptNames + ); + + //- Generic lookup for each of the related thermodynamics packages + // \return constructor pointer, or FatalError + template + static typename ThermoConstructTable::mapped_type + getThermoOrDie + ( + const dictionary& thermoDict, + ThermoConstructTable& thermoTable + ); + + protected: // Protected Data @@ -96,14 +145,6 @@ protected: // Protected Member Functions - //- Look up field from registry or construct and store - static volScalarField& lookupOrConstruct - ( - const fvMesh& mesh, - const word& fieldName, - bool& isOwner //!< Stored to registry by this instance - ); - //- Return the enthalpy/internal energy field boundary types //- by interrogating the temperature field boundary types wordList heBoundaryTypes(); @@ -173,24 +214,6 @@ public: // Selectors - //- Generic lookup for thermodynamics package thermoTypeName - template - static typename Table::iterator lookupThermo - ( - const dictionary& thermoTypeDict, - Table* tablePtr, - std::initializer_list cmptNames, - const word& thermoTypeName - ); - - //- Generic lookup for each of the related thermodynamics packages - template - static typename Table::iterator lookupThermo - ( - const dictionary& thermoDict, - Table* tablePtr - ); - //- Generic New for each of the related thermodynamics packages template static autoPtr New @@ -249,6 +272,14 @@ public: static const basicThermo& lookupThermo(const fvPatchScalarField& pf); + //- Print (filtered) table of thermo names, splits on \c " ,<>" + static Ostream& printThermoNames + ( + Ostream& os, + const wordList& cmptNames, + const wordList& thermoNames + ); + //- Check that the thermodynamics package is consistent // with energy forms supported by the application void validate @@ -287,11 +318,14 @@ public: const word& ) const; - //- Split name of thermo package into a list of the components names + //- Split thermo package name into a list of components names + // Splits on \c " ,<>" + // \return empty list if the split name does not have the + // expected number of components (non-zero). static wordList splitThermoName ( - const word& thermoName, - const int nCmpt + const std::string& thermoName, + const int nExpectedCmpts ); //- Update properties diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C b/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C index 38351182af..084e626996 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermoTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,140 +28,78 @@ License #include "basicThermo.H" -// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -typename Table::iterator Foam::basicThermo::lookupThermo +template +typename ThermoConstructTable::mapped_type +Foam::basicThermo::getThermoOrDie ( const dictionary& thermoTypeDict, - Table* tablePtr, - std::initializer_list cmptNames, - const word& thermoTypeName + ThermoConstructTable& thermoTable, + const word& thermoTypeName, + const wordList& cmptNames ) { // Lookup the thermo package - // Table iterator, not const_iterator - auto cstrIter = tablePtr->find(thermoTypeName); + auto ctorIter = thermoTable.cfind(thermoTypeName); // Print error message if package not found in the table - if (!cstrIter.found()) + if (!ctorIter.found()) { - const int nCmpt = cmptNames.size(); - - // Build a table of the thermo packages constituent parts - // Note: row-0 contains the names of constituent parts - List validCmpts(tablePtr->size()+1); - - // Header (row 0) - validCmpts[0].resize(nCmpt); - std::copy(cmptNames.begin(), cmptNames.end(), validCmpts[0].begin()); - - // Split the thermo package names into their constituent parts - // Removing incompatible entries from the list - label rowi = 1; - for (const word& validName : tablePtr->sortedToc()) - { - validCmpts[rowi] = Thermo::splitThermoName(validName, nCmpt); - - if (validCmpts[rowi].size()) - { - ++rowi; - } - } - validCmpts.resize(rowi); - - FatalIOErrorInLookup ( thermoTypeDict, Thermo::typeName, word::null, // Suppress long name? Just output dictionary (above) - *tablePtr + thermoTable ); - // Table of available packages (as constituent parts) - printTable(validCmpts, FatalIOError) - << exit(FatalIOError); + basicThermo::printThermoNames + ( + FatalIOError, + cmptNames, + thermoTable.sortedToc() + ) << exit(FatalIOError); + + // return nullptr; } - return cstrIter; + return ctorIter.val(); } -template -typename Table::iterator Foam::basicThermo::lookupThermo +template +typename ThermoConstructTable::mapped_type +Foam::basicThermo::getThermoOrDie ( const dictionary& thermoDict, - Table* tablePtr + ThermoConstructTable& thermoTable ) { - if (thermoDict.isDict("thermoType")) + const dictionary* dictptr = thermoDict.findDict("thermoType"); + + if (dictptr) { - const dictionary& thermoTypeDict = thermoDict.subDict("thermoType"); + const auto& thermoTypeDict = *dictptr; + + const wordList* cmptHeaderPtr = &(wordList::null()); + + // Thermo package name, constructed from components + const word thermoTypeName + ( + basicThermo::makeThermoName(thermoTypeDict, cmptHeaderPtr) + ); Info<< "Selecting thermodynamics package " << thermoTypeDict << endl; - if (thermoTypeDict.found("properties")) - { - std::initializer_list cmptNames - { - "type", - "mixture", - "properties", - "energy" - }; - - // Construct the name of the thermo package from the components - const word thermoTypeName - ( - thermoTypeDict.get("type") + '<' - + thermoTypeDict.get("mixture") + '<' - + thermoTypeDict.get("properties") + ',' - + thermoTypeDict.get("energy") + ">>" - ); - - return lookupThermo - ( - thermoTypeDict, - tablePtr, - cmptNames, - thermoTypeName - ); - } - else - { - std::initializer_list cmptNames - { - "type", - "mixture", - "transport", - "thermo", - "equationOfState", - "specie", - "energy" - }; - - // Construct the name of the thermo package from the components - const word thermoTypeName - ( - thermoTypeDict.get("type") + '<' - + thermoTypeDict.get("mixture") + '<' - + thermoTypeDict.get("transport") + '<' - + thermoTypeDict.get("thermo") + '<' - + thermoTypeDict.get("equationOfState") + '<' - + thermoTypeDict.get("specie") + ">>," - + thermoTypeDict.get("energy") + ">>>" - ); - - return lookupThermo - ( - thermoTypeDict, - tablePtr, - cmptNames, - thermoTypeName - ); - } + return getThermoOrDie + ( + thermoTypeDict, + thermoTable, + thermoTypeName, + *cmptHeaderPtr + ); } else { @@ -169,25 +107,26 @@ typename Table::iterator Foam::basicThermo::lookupThermo Info<< "Selecting thermodynamics package " << thermoTypeName << endl; - // Table iterator, not const_iterator - auto cstrIter = tablePtr->find(thermoTypeName); + auto ctorIter = thermoTable.cfind(thermoTypeName); - if (!cstrIter.found()) + if (!ctorIter.found()) { FatalIOErrorInLookup ( thermoDict, Thermo::typeName, thermoTypeName, - *tablePtr + thermoTable ) << exit(FatalIOError); } - return cstrIter; + return ctorIter.val(); } } +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + template Foam::autoPtr Foam::basicThermo::New ( @@ -208,14 +147,13 @@ Foam::autoPtr Foam::basicThermo::New ) ); - auto cstrIter = - lookupThermo - ( - thermoDict, - Thermo::fvMeshConstructorTablePtr_ - ); + auto* ctorPtr = getThermoOrDie + ( + thermoDict, + *(Thermo::fvMeshConstructorTablePtr_) + ); - return autoPtr(cstrIter()(mesh, phaseName)); + return autoPtr(ctorPtr(mesh, phaseName)); } @@ -227,14 +165,13 @@ Foam::autoPtr Foam::basicThermo::New const word& phaseName ) { - auto cstrIter = - lookupThermo - ( - dict, - Thermo::dictionaryConstructorTablePtr_ - ); + auto* ctorPtr = getThermoOrDie + ( + dict, + *(Thermo::dictionaryConstructorTablePtr_) + ); - return autoPtr(cstrIter()(mesh, dict, phaseName)); + return autoPtr(ctorPtr(mesh, dict, phaseName)); } @@ -259,16 +196,14 @@ Foam::autoPtr Foam::basicThermo::New ) ); - auto cstrIter = - lookupThermo - ( - thermoDict, - Thermo::fvMeshDictPhaseConstructorTablePtr_ - ); + auto* ctorPtr = getThermoOrDie + ( + thermoDict, + *(Thermo::fvMeshDictPhaseConstructorTablePtr_) + ); - return autoPtr(cstrIter()(mesh, phaseName, dictName)); + return autoPtr(ctorPtr(mesh, phaseName, dictName)); } - // ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C index a42f3a37f5..e2fe639651 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethodNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,23 +51,26 @@ Foam::chemistryReductionMethod::New + '<' + CompType::typeName + ',' + ThermoType::typeName() + '>' ); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodTypeName); + const auto& cnstrTable = *(dictionaryConstructorTablePtr_); + + auto cstrIter = cnstrTable.cfind(methodTypeName); if (!cstrIter.found()) { + const wordList names(cnstrTable.sortedToc()); + constexpr const int nCmpt = 7; - wordList thisCmpts; - thisCmpts.append(word::null); - thisCmpts.append(CompType::typeName); - thisCmpts.append - ( - basicThermo::splitThermoName(ThermoType::typeName(), 5) - ); + /// DynamicList thisCmpts(6); + /// thisCmpts.append(CompType::typeName); + /// thisCmpts.append + /// ( + /// basicThermo::splitThermoName(ThermoType::typeName(), 5) + /// ); + /// + /// DynamicList validNames; - wordList validNames; - - List validCmpts; + DynamicList validCmpts; validCmpts.append ( // Header @@ -83,42 +86,38 @@ Foam::chemistryReductionMethod::New }) ); - for - ( - const word& validName - : dictionaryConstructorTablePtr_->sortedToc() - ) + for (const word& validName : names) { - validCmpts.append - ( - basicThermo::splitThermoName(validName, nCmpt) - ); - const wordList& cmpts = validCmpts.last(); + wordList cmpts(basicThermo::splitThermoName(validName, nCmpt)); - bool isValid = true; - for (label i = 1; i < cmpts.size() && isValid; ++i) + if (!cmpts.empty()) { - isValid = isValid && cmpts[i] == thisCmpts[i]; - } - - if (isValid) - { - validNames.append(cmpts[0]); + /// if (thisCmpts == SubList(cmpts, 6, 1)) + /// { + /// validNames.append(cmpts[0]); + /// } + validCmpts.append(std::move(cmpts)); } } - FatalErrorInLookup ( typeName_(), methodName, - *dictionaryConstructorTablePtr_ - ) - << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] - << "/thermoPhysics combinations:" << nl << nl; + cnstrTable + ); - // Table of available packages (as constituent parts) - printTable(validCmpts, FatalErrorInFunction) + if (validCmpts.size() > 1) + { + FatalError + << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] + << "/thermoPhysics combinations:" << nl << nl; + + // Table of available packages (as constituent parts) + printTable(validCmpts, FatalError) << nl; + } + + FatalError << exit(FatalError); } diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C index 09ac87d906..78217af122 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,7 +39,7 @@ Foam::chemistryTabulationMethod::New TDACChemistryModel& chemistry ) { - const dictionary& tabulationDict(dict.subDict("tabulation")); + const dictionary& tabulationDict = dict.subDict("tabulation"); const word methodName(tabulationDict.get("method")); @@ -50,21 +50,26 @@ Foam::chemistryTabulationMethod::New + '<' + CompType::typeName + ',' + ThermoType::typeName() + '>' ); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodTypeName); + const auto& cnstrTable = *(dictionaryConstructorTablePtr_); + + auto cstrIter = cnstrTable.cfind(methodTypeName); if (!cstrIter.found()) { - wordList thisCmpts; - thisCmpts.append(word::null); - thisCmpts.append(CompType::typeName); - thisCmpts.append - ( - basicThermo::splitThermoName(ThermoType::typeName(), 5) - ); + const wordList names(cnstrTable.sortedToc()); - wordList validNames; + constexpr const int nCmpt = 7; - List validCmpts; + /// DynamicList thisCmpts(6); + /// thisCmpts.append(CompType::typeName); + /// thisCmpts.append + /// ( + /// basicThermo::splitThermoName(ThermoType::typeName(), 5) + /// ); + /// + /// DynamicList validNames; + + DynamicList validCmpts; validCmpts.append ( wordList @@ -79,27 +84,17 @@ Foam::chemistryTabulationMethod::New }) ); - for - ( - const word& validName - : dictionaryConstructorTablePtr_->sortedToc() - ) + for (const word& validName : names) { - validCmpts.append - ( - basicThermo::splitThermoName(validName, 7) - ); - const wordList& cmpts = validCmpts.last(); + wordList cmpts(basicThermo::splitThermoName(validName, nCmpt)); - bool isValid = true; - for (label i = 1; i < cmpts.size() && isValid; ++i) + if (!cmpts.empty()) { - isValid = isValid && cmpts[i] == thisCmpts[i]; - } - - if (isValid) - { - validNames.append(cmpts[0]); + /// if (thisCmpts == SubList(cmpts, 6, 1)) + /// { + /// validNames.append(cmpts[0]); + /// } + validCmpts.append(std::move(cmpts)); } } @@ -108,13 +103,20 @@ Foam::chemistryTabulationMethod::New ( typeName_(), methodName, - *dictionaryConstructorTablePtr_ - ) - << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] - << "/thermoPhysics combinations:" << nl << nl; + cnstrTable + ); - // Table of available packages (as constituent parts) - printTable(validCmpts, FatalErrorInFunction) + if (validCmpts.size() > 1) + { + FatalError + << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] + << "/thermoPhysics combinations:" << nl << nl; + + // Table of available packages (as constituent parts) + printTable(validCmpts, FatalError) << nl; + } + + FatalError << exit(FatalError); } @@ -122,7 +124,6 @@ Foam::chemistryTabulationMethod::New ( cstrIter()(dict, chemistry) ); - } diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelTemplates.C b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelTemplates.C index b6293541dd..1dff300bf7 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelTemplates.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModelTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -87,13 +87,14 @@ Foam::autoPtr Foam::basicChemistryModel::New ) ); - dictionary chemistryTypeDictNew; - chemistryTypeDictNew.add("solver", solverName); - chemistryTypeDictNew.add("method", methodName); + { + dictionary chemistryTypeDictNew; - Info<< "Selecting chemistry solver " << chemistryTypeDictNew << endl; + chemistryTypeDictNew.add("solver", solverName); + chemistryTypeDictNew.add("method", methodName); - const auto& cnstrTable = *(ChemistryModel::thermoConstructorTablePtr_); + Info<< "Selecting chemistry solver " << chemistryTypeDictNew << endl; + } const word chemSolverCompThermoName ( @@ -102,30 +103,32 @@ Foam::autoPtr Foam::basicChemistryModel::New + thermo.thermoName() + ">>" ); - auto cstrIter = cnstrTable.cfind(chemSolverCompThermoName); - if (!cstrIter.found()) + const auto& cnstrTable = *(ChemistryModel::thermoConstructorTablePtr_); + + auto ctorIter = cnstrTable.cfind(chemSolverCompThermoName); + + if (!ctorIter.found()) { + const wordList names(cnstrTable.sortedToc()); + constexpr const int nCmpt = 8; - wordList thisCmpts; - thisCmpts.append(word::null); - thisCmpts.append(word::null); + DynamicList thisCmpts(6); thisCmpts.append(ChemistryModel::reactionThermo::typeName); thisCmpts.append ( basicThermo::splitThermoName(thermo.thermoName(), 5) ); - List validNames; - + DynamicList validNames; validNames.append ( // Header wordList({"solver", "method"}) ); - List validCmpts; + DynamicList validCmpts(names.size() + 1); validCmpts.append ( // Header @@ -142,48 +145,50 @@ Foam::autoPtr Foam::basicChemistryModel::New }) ); - for (const word& validName : cnstrTable.sortedToc()) + for (const word& validName : names) { - validCmpts.append - ( - basicThermo::splitThermoName(validName, nCmpt) - ); + wordList cmpts(basicThermo::splitThermoName(validName, nCmpt)); - const wordList& cmpts = validCmpts.last(); - - bool isValid = true; - for (label i = 2; i < cmpts.size() && isValid; ++i) + if (!cmpts.empty()) { - isValid = isValid && cmpts[i] == thisCmpts[i]; - } - - if (isValid) - { - validNames.append(SubList(cmpts, 2)); + if (thisCmpts == SubList(cmpts, 6, 2)) + { + validNames.append(SubList(cmpts, 2)); + } + validCmpts.append(std::move(cmpts)); } } - FatalErrorInFunction << "Unknown " << typeName_() << " type " << solverName << nl << nl; - FatalErrorInFunction - << "All " << validNames[0][0] << '/' << validNames[0][1] - << "combinations for this thermodynamic model:" << nl << nl; + if (validNames.size() > 1) + { + FatalError + << "All " << validNames[0][0] << '/' << validNames[0][1] + << " combinations for this thermodynamic model:" + << nl << nl; - // Table of available packages (as constituent parts) - printTable(validNames, FatalErrorInFunction) - << nl - << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] << '/' - << validCmpts[0][2] << "/thermoPhysics combinations are:" - << nl << nl; + // Table of available packages (as constituent parts) + printTable(validNames, FatalError) << nl; + } - // Table of available packages (as constituent parts) - printTable(validCmpts, FatalErrorInFunction) + if (validCmpts.size() > 1) + { + FatalError + << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] << '/' + << validCmpts[0][2] << "/thermoPhysics combinations:" + << nl << nl; + + // Table of available packages (as constituent parts) + printTable(validCmpts, FatalError) << nl; + } + + FatalError << exit(FatalError); } - return autoPtr(cstrIter()(thermo)); + return autoPtr(ctorIter()(thermo)); } // ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H index 5f54dfbfcc..f704e843a4 100644 --- a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H @@ -32,7 +32,7 @@ Description SourceFiles basicSolidChemistryModelI.H basicSolidChemistryModel.C - newChemistrySolidModel.C + basicSolidChemistryModelNew.C \*---------------------------------------------------------------------------*/ @@ -50,11 +50,11 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class fvMesh; /*---------------------------------------------------------------------------*\ - class basicSolidChemistryModel Declaration + Class basicSolidChemistryModel Declaration \*---------------------------------------------------------------------------*/ class basicSolidChemistryModel @@ -72,7 +72,7 @@ class basicSolidChemistryModel protected: - // Protected data + // Protected Data //- Solid thermo solidReactionThermo& solidThermo_; diff --git a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModelNew.C b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModelNew.C index 7170f2cb76..83e272847a 100644 --- a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModelNew.C +++ b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,23 +51,6 @@ Foam::basicSolidChemistryModel::New(solidReactionThermo& thermo) Info<< "Selecting chemistry type " << chemistryTypeDict << endl; - std::initializer_list cmptNames - { - "chemistrySolver", - "chemistryThermo", - "baseChemistry", - "transport", - "thermo", - "equationOfState", - "specie", - "energy", - "transport", - "thermo", - "equationOfState", - "specie", - "energy" - }; - const IOdictionary thermoDict ( IOobject @@ -112,48 +95,48 @@ Foam::basicSolidChemistryModel::New(solidReactionThermo& thermo) Info<< "chemistryTypeName " << chemistryTypeName << endl; - auto cstrIter = thermoConstructorTablePtr_->cfind(chemistryTypeName); + const auto& cnstrTable = *(thermoConstructorTablePtr_); - if (!cstrIter.found()) + auto ctorIter = cnstrTable.cfind(chemistryTypeName); + + if (!ctorIter.found()) { - const int nCmpt = cmptNames.size(); - - // Build a table of the thermo packages constituent parts - // Note: row-0 contains the names of constituent parts - List validCmpts(thermoConstructorTablePtr_->size()+1); - - // Header (row 0) - validCmpts[0].resize(nCmpt); - std::copy(cmptNames.begin(), cmptNames.end(), validCmpts[0].begin()); - - label rowi = 1; - for (const word& validName : thermoConstructorTablePtr_->sortedToc()) - { - validCmpts[rowi] = basicThermo::splitThermoName(validName, nCmpt); - - if (validCmpts[rowi].size()) - { - ++rowi; - } - } - validCmpts.resize(rowi); - - FatalIOErrorInLookup ( chemistryTypeDict, typeName, word::null, // Suppress long name? Just output dictionary (above) - *thermoConstructorTablePtr_ + cnstrTable ); // Table of available packages (as constituent parts) - printTable(validCmpts, FatalIOError) + basicThermo::printThermoNames + ( + FatalIOError, + wordList + ({ + "chemistrySolver", + "chemistryThermo", + "baseChemistry", + "transport", + "thermo", // solid + "equationOfState", + "specie", + "energy", + "transport", + "thermo", // gas + "equationOfState", + "specie", + "energy" + }), + cnstrTable.sortedToc() + ); + + FatalIOError << exit(FatalIOError); } - return - autoPtr(cstrIter()(thermo)); + return autoPtr(ctorIter()(thermo)); } From 7f8ecd98f5a5c9d5034dbc66105d642a470632fa Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 14 Jul 2021 21:15:51 +0200 Subject: [PATCH 2/6] ENH: rename runTime selection typedefs - better distinction between content and storage type by appending 'Type' to the typedef. old: 'Class::abcConstructorTable* tablePtr' new: 'Class::abcConstructorTableType* tablePtr' Was rarely used in any exposed code. BREAKING: LESdelta::New with additional table - parameter change to dictionaryConstructorTableType (was dictionaryConstructorTable) --- .../construction/runTimeSelectionTables.H | 24 +++++++------- .../memberFunctionSelectionTables.H | 14 ++++---- .../LES/LESdeltas/LESdelta/LESdelta.C | 32 +++++++++++-------- .../LES/LESdeltas/LESdelta/LESdelta.H | 7 ++-- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H index a6a2a528df..51b615a76b 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H @@ -51,16 +51,16 @@ Description /* Construct from argList function pointer type */ \ typedef autoPtr (*argNames##ConstructorPtr)argList; \ \ - /* Construct from argList function table type */ \ - typedef HashTable \ + /* Function table type: construct from argList */ \ + typedef ::Foam::HashTable \ < \ argNames##ConstructorPtr, \ ::Foam::word, \ ::Foam::string::hasher \ - > argNames##ConstructorTable; \ + > argNames##ConstructorTableType; \ \ /* Construct from argList function pointer table pointer */ \ - static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ + static argNames##ConstructorTableType* argNames##ConstructorTablePtr_; \ \ /* Table constructor called from the table add function */ \ static void construct##argNames##ConstructorTables(); \ @@ -155,16 +155,16 @@ Description /* Construct from argList function pointer type */ \ typedef autoPtr (*argNames##ConstructorPtr)argList; \ \ - /* Construct from argList function table type */ \ - typedef HashTable \ + /* Function table type: construct from argList */ \ + typedef ::Foam::HashTable \ < \ argNames##ConstructorPtr, \ ::Foam::word, \ ::Foam::string::hasher \ - > argNames##ConstructorTable; \ + > argNames##ConstructorTableType; \ \ /* Construct from argList function pointer table pointer */ \ - static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ + static argNames##ConstructorTableType* argNames##ConstructorTablePtr_; \ \ /* Table constructor called from the table add function */ \ static void construct##argNames##ConstructorTables(); \ @@ -272,7 +272,7 @@ Description { \ constructed = true; \ baseType::argNames##ConstructorTablePtr_ \ - = new baseType::argNames##ConstructorTable; \ + = new baseType::argNames##ConstructorTableType; \ } \ } @@ -295,7 +295,7 @@ Description #define defineRunTimeSelectionTablePtr(baseType,argNames) \ \ /* Define the constructor function table */ \ - baseType::argNames##ConstructorTable* \ + baseType::argNames##ConstructorTableType* \ baseType::argNames##ConstructorTablePtr_(nullptr) @@ -335,7 +335,7 @@ Description { \ constructed = true; \ baseType::argNames##ConstructorTablePtr_ \ - = new baseType::argNames##ConstructorTable; \ + = new baseType::argNames##ConstructorTableType; \ } \ } @@ -359,7 +359,7 @@ Description #define defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ) \ \ /* Define the constructor function table */ \ - baseType::argNames##ConstructorTable* \ + baseType::argNames##ConstructorTableType* \ baseType::argNames##ConstructorTablePtr_(nullptr) diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H index df70160dad..b807c40f69 100644 --- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H @@ -46,15 +46,15 @@ Description typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \ \ /* Construct from argList function table type */ \ - typedef HashTable \ + typedef ::Foam::HashTable \ < \ memberFunction##argNames##MemberFunctionPtr, \ ::Foam::word, \ ::Foam::string::hasher \ - > memberFunction##argNames##MemberFunctionTable; \ + > memberFunction##argNames##MemberFunctionTableType; \ \ /* Construct from argList function pointer table pointer */ \ - static memberFunction##argNames##MemberFunctionTable* \ + static memberFunction##argNames##MemberFunctionTableType* \ memberFunction##argNames##MemberFunctionTablePtr_; \ \ /* Class to add constructor from argList to table */ \ @@ -101,7 +101,7 @@ Description { \ constructed = true; \ baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ - = new baseType::memberFunction##argNames##MemberFunctionTable; \ + = new baseType::memberFunction##argNames##MemberFunctionTableType; \ } \ } @@ -127,7 +127,7 @@ Description #define defineMemberFunctionSelectionTablePtr(baseType,memberFunction,argNames)\ \ /* Define the memberFunction table */ \ - baseType::memberFunction##argNames##MemberFunctionTable* \ + baseType::memberFunction##argNames##MemberFunctionTableType* \ baseType::memberFunction##argNames##MemberFunctionTablePtr_(nullptr) @@ -176,7 +176,7 @@ Description constructed = true; \ baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ = new baseType::memberFunction##argNames## \ - MemberFunctionTable; \ + MemberFunctionTableType; \ } \ } @@ -206,7 +206,7 @@ Description baseType,memberFunction,argNames,Targ) \ \ /* Define the memberFunction table */ \ - baseType::memberFunction##argNames##MemberFunctionTable* \ + baseType::memberFunction##argNames##MemberFunctionTableType* \ baseType::memberFunction##argNames## \ MemberFunctionTablePtr_(nullptr) diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C index bdc8a8a116..554def6e99 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -99,7 +99,7 @@ Foam::autoPtr Foam::LESdelta::New const word& name, const turbulenceModel& turbulence, const dictionary& dict, - const dictionaryConstructorTable& additionalConstructors, + const dictionaryConstructorTableType& additionalConstructors, const word& lookupName ) { @@ -107,18 +107,15 @@ Foam::autoPtr Foam::LESdelta::New Info<< "Selecting LES " << lookupName << " type " << deltaType << endl; - // First any additional ones + // Additional ones first + auto cstrIter = additionalConstructors.cfind(deltaType); + + // Regular ones + if (!cstrIter.found()) { - auto cstrIter = additionalConstructors.cfind(deltaType); - - if (cstrIter.found()) - { - return autoPtr(cstrIter()(name, turbulence, dict)); - } + cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType); } - auto cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType); - if (!cstrIter.found()) { FatalIOErrorInLookup @@ -126,9 +123,16 @@ Foam::autoPtr Foam::LESdelta::New dict, "LESdelta", deltaType, - additionalConstructors - ) - << " and " << dictionaryConstructorTablePtr_->sortedToc() + *dictionaryConstructorTablePtr_ + ); + + if (additionalConstructors.size()) + { + FatalIOError + << " and " << additionalConstructors.sortedToc() << nl; + } + + FatalIOError << exit(FatalIOError); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.H index ba2edbcc9d..52f1679e84 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.H +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,10 +53,9 @@ namespace Foam class LESdelta { - protected: - // Protected data + // Protected Data const turbulenceModel& turbulenceModel_; @@ -121,7 +120,7 @@ public: const word& name, const turbulenceModel& turbulence, const dictionary& dict, - const dictionaryConstructorTable& additionalConstructors, + const dictionaryConstructorTableType& additionalConstructors, const word& lookupName = "delta" ); From 0bd113f537b2c4891782be2eb605acdf13de5c99 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 16 Sep 2021 10:48:08 +0200 Subject: [PATCH 3/6] ENH: refactored and simplified runtime declaration macros - improves future maintenance, avoids code/macro duplication --- .../construction/addToRunTimeSelectionTable.H | 73 +-- .../construction/runTimeSelectionTables.H | 501 ++++++++---------- .../addToMemberFunctionSelectionTable.H | 118 ++--- .../memberFunctionSelectionTables.H | 236 +++------ 4 files changed, 376 insertions(+), 552 deletions(-) diff --git a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H index 56579765c8..dc839d6dab 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +27,10 @@ License Description Macros for easy insertion into run-time selection tables +Note + The helper macro names used here must remain synchronized with + definitions in runTimeSelectionTables.H + \*---------------------------------------------------------------------------*/ #ifndef addToRunTimeSelectionTable_H @@ -33,88 +38,88 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Add to hash-table of functions with typename as the key +//- Add to construction table with typeName as the key #define addToRunTimeSelectionTable\ (baseType,thisType,argNames) \ \ - /* Add the thisType constructor function to the table */ \ + /* Add thisType factory method to the table */ \ baseType::add##argNames##ConstructorToTable \ add##thisType##argNames##ConstructorTo##baseType##Table_ -//- Add to hash-table of functions with 'lookup' as the key -#define addNamedToRunTimeSelectionTable\ -(baseType,thisType,argNames,lookup) \ - \ - /* Add the thisType constructor function to the table, find by lookup */ \ - baseType::add##argNames##ConstructorToTable \ - add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_ \ - (#lookup) - - -//- Add to hash-table of functions with typename as the key +//- Add to construction table with typeName as the key #define addRemovableToRunTimeSelectionTable\ (baseType,thisType,argNames) \ \ - /* Add the thisType constructor function to the table */ \ + /* Add thisType factory method to the table */ \ baseType::addRemovable##argNames##ConstructorToTable \ addRemovable##thisType##argNames##ConstructorTo##baseType##Table_ -//- Add to hash-table of functions with 'lookup' as the key -#define addRemovableNamedToRunTimeSelectionTable\ -(baseType,thisType,argNames,lookup) \ +//- Add to construction table with 'lookupName' as the key +#define addNamedToRunTimeSelectionTable\ +(baseType,thisType,argNames,lookupName) \ \ - /* Add the thisType constructor function to the table, find by lookup */ \ + /* Add thisType factory method to the table, find by lookupName */ \ + baseType::add##argNames##ConstructorToTable \ + add##thisType##argNames##ConstructorTo## \ + baseType##Table_##lookupName##_(#lookupName) + + +//- Add to construction table with 'lookupName' as the key +#define addRemovableNamedToRunTimeSelectionTable\ +(baseType,thisType,argNames,lookupName) \ + \ + /* Add thisType factory method to the table, find by lookupName */ \ baseType::addRemovable##argNames##ConstructorToTable \ - addRemovable_##lookup##_##thisType##argNames##ConstructorTo \ - ##baseType##Table_(#lookup) + addRemovable##thisType##argNames##ConstructorTo## \ + baseType##Table_##lookupName##_(#lookupName) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Add to hash-table of functions with typename as the key. +//- Add to construction table with typeName as the key. // Use when baseType doesn't need a template argument (eg, is a typedef) #define addTemplateToRunTimeSelectionTable\ (baseType,thisType,Targ,argNames) \ \ - /* Add the thisType constructor function to the table */ \ + /* Add thisType factory method to the table */ \ baseType::add##argNames##ConstructorToTable> \ add##thisType##Targ##argNames##ConstructorTo##baseType##Table_ -//- Add to hash-table of functions with 'lookup' as the key. +//- Add to construction table with 'lookupName' as the key. // Use when baseType doesn't need a template argument (eg, is a typedef) #define addNamedTemplateToRunTimeSelectionTable\ -(baseType,thisType,Targ,argNames,lookup) \ +(baseType,thisType,Targ,argNames,lookupName) \ \ - /* Add the thisType constructor function to the table, find by lookup */ \ + /* Add thisType factory method to the table, find by lookupName */ \ baseType::add##argNames##ConstructorToTable> \ - add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType \ - ##Table_(#lookup) + add##thisType##Targ##argNames##ConstructorTo## \ + baseType##Table_##lookupName##_(#lookupName) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Add to hash-table of functions with typename as the key. +//- Add to construction table with typeName as the key. // Use when baseType requires the Targ template argument as well #define addTemplatedToRunTimeSelectionTable\ (baseType,thisType,Targ,argNames) \ \ - /* Add the thisType constructor function to the table */ \ + /* Add thisType factory method to the table */ \ baseType::add##argNames##ConstructorToTable> \ add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_ -//- Add to hash-table of functions with 'lookup' as the key. +//- Add to construction table with 'lookupName' as the key. // Use when baseType requires the Targ template argument as well #define addNamedTemplatedToRunTimeSelectionTable\ -(baseType,thisType,Targ,argNames,lookup) \ +(baseType,thisType,Targ,argNames,lookupName) \ \ - /* Add the thisType constructor function to the table, find by lookup */ \ + /* Add thisType factory method to the table, find by lookupName */ \ baseType::add##argNames##ConstructorToTable> \ - add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType## \ - Targ##Table_(#lookup) + add##thisType##Targ##argNames##ConstructorTo## \ + baseType##Targ##Table_##lookupName##_(#lookupName) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H index 51b615a76b..0fa16f0e6f 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H @@ -45,334 +45,253 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Declare a run-time selection -#define declareRunTimeSelectionTable(autoPtr,baseType,argNames,argList,parList)\ +// Common infrastructure + +// Not used directly: declare run-time selection (variables and methods) +#define declareRunTimeSelectionTableBase(returnType,prefix,argList) \ \ - /* Construct from argList function pointer type */ \ - typedef autoPtr (*argNames##ConstructorPtr)argList; \ + /* Function pointer type: construct from argList */ \ + typedef returnType (*prefix##Ptr)argList; \ \ /* Function table type: construct from argList */ \ typedef ::Foam::HashTable \ < \ - argNames##ConstructorPtr, \ + prefix##Ptr, \ ::Foam::word, \ ::Foam::string::hasher \ - > argNames##ConstructorTableType; \ + > prefix##TableType; \ \ - /* Construct from argList function pointer table pointer */ \ - static argNames##ConstructorTableType* argNames##ConstructorTablePtr_; \ + /* Table singleton (storage) */ \ + static prefix##TableType* prefix##TablePtr_; \ \ - /* Table constructor called from the table add function */ \ - static void construct##argNames##ConstructorTables(); \ - \ - /* Table destructor called from the table add function destructor */ \ - static void destroy##argNames##ConstructorTables(); \ - \ - /* Class to add constructor from argList to table */ \ - template \ - class add##argNames##ConstructorToTable \ - { \ - public: \ - \ - static autoPtr New argList \ - { \ - return autoPtr(new baseType##Type parList); \ - } \ - \ - explicit add##argNames##ConstructorToTable \ - ( \ - const ::Foam::word& lookup = baseType##Type::typeName \ - ) \ - { \ - construct##argNames##ConstructorTables(); \ - if (!argNames##ConstructorTablePtr_->insert(lookup, New)) \ - { \ - std::cerr<< "Duplicate entry " << lookup \ - << " in runtime selection table " << #baseType \ - << std::endl; \ - error::safePrintStack(std::cerr); \ - } \ - } \ - \ - ~add##argNames##ConstructorToTable() \ - { \ - destroy##argNames##ConstructorTables(); \ - } \ - \ - add##argNames##ConstructorToTable \ - (const add##argNames##ConstructorToTable&) = delete; \ - \ - void operator= \ - (const add##argNames##ConstructorToTable&) = delete; \ - }; \ - \ - /* Class to add constructor from argList to table */ \ - /* Remove only the entry (not the table) upon destruction */ \ - template \ - class addRemovable##argNames##ConstructorToTable \ - { \ - public: \ - \ - const ::Foam::word name; /* Lookup name for later removal */ \ - \ - static autoPtr New argList \ - { \ - return autoPtr(new baseType##Type parList); \ - } \ - \ - explicit addRemovable##argNames##ConstructorToTable \ - ( \ - const ::Foam::word& lookup = baseType##Type::typeName \ - ) \ - : \ - name(lookup) \ - { \ - construct##argNames##ConstructorTables(); \ - argNames##ConstructorTablePtr_->set(lookup, New); \ - } \ - \ - ~addRemovable##argNames##ConstructorToTable() \ - { \ - if (argNames##ConstructorTablePtr_) \ - { \ - argNames##ConstructorTablePtr_->erase(name); \ - } \ - } \ - \ - addRemovable##argNames##ConstructorToTable \ - (const addRemovable##argNames##ConstructorToTable&) = delete; \ - \ - void operator= \ - (const addRemovable##argNames##ConstructorToTable&) = delete; \ - }; + /* Table construct/destruct helper */ \ + static void prefix##TablePtr_construct(bool load) - -//- Declare a run-time selection for derived classes -#define declareRunTimeNewSelectionTable( \ - autoPtr,baseType,argNames,argList,parList) \ +// Not used directly: storage and helper methods for runtime tables +#define defineRunTimeSelectionTableBase(baseType,prefix,Tspecialize) \ \ - /* Construct from argList function pointer type */ \ - typedef autoPtr (*argNames##ConstructorPtr)argList; \ + /* Define table singleton (storage) */ \ + Tspecialize prefix##TableType* prefix##TablePtr_(nullptr); \ \ - /* Function table type: construct from argList */ \ - typedef ::Foam::HashTable \ - < \ - argNames##ConstructorPtr, \ - ::Foam::word, \ - ::Foam::string::hasher \ - > argNames##ConstructorTableType; \ - \ - /* Construct from argList function pointer table pointer */ \ - static argNames##ConstructorTableType* argNames##ConstructorTablePtr_; \ - \ - /* Table constructor called from the table add function */ \ - static void construct##argNames##ConstructorTables(); \ - \ - /* Table destructor called from the table add function destructor */ \ - static void destroy##argNames##ConstructorTables(); \ - \ - /* Class to add constructor from argList to table */ \ - template \ - class add##argNames##ConstructorToTable \ - { \ - public: \ - \ - static autoPtr New##baseType argList \ - { \ - return autoPtr(baseType##Type::New parList.ptr()); \ - } \ - \ - explicit add##argNames##ConstructorToTable \ - ( \ - const ::Foam::word& lookup = baseType##Type::typeName \ - ) \ - { \ - construct##argNames##ConstructorTables(); \ - if \ - ( \ - !argNames##ConstructorTablePtr_->insert \ - ( \ - lookup, \ - New##baseType \ - ) \ - ) \ - { \ - std::cerr<< "Duplicate entry " << lookup \ - << " in runtime selection table " << #baseType \ - << std::endl; \ - error::safePrintStack(std::cerr); \ - } \ - } \ - \ - ~add##argNames##ConstructorToTable() \ - { \ - destroy##argNames##ConstructorTables(); \ - } \ - \ - add##argNames##ConstructorToTable \ - (const add##argNames##ConstructorToTable&) = delete; \ - \ - void operator= \ - (const add##argNames##ConstructorToTable&) = delete; \ - }; \ - \ - /* Class to add constructor from argList to table */ \ - template \ - class addRemovable##argNames##ConstructorToTable \ - { \ - public: \ - \ - const ::Foam::word name; /* Lookup name for later removal */ \ - \ - static autoPtr New##baseType argList \ - { \ - return autoPtr(baseType##Type::New parList.ptr()); \ - } \ - \ - explicit addRemovable##argNames##ConstructorToTable \ - ( \ - const ::Foam::word& lookup = baseType##Type::typeName \ - ) \ - : \ - name(lookup) \ - { \ - construct##argNames##ConstructorTables(); \ - argNames##ConstructorTablePtr_->set \ - ( \ - lookup, \ - New##baseType \ - ); \ - } \ - \ - ~addRemovable##argNames##ConstructorToTable() \ - { \ - if (argNames##ConstructorTablePtr_) \ - { \ - argNames##ConstructorTablePtr_->erase(name); \ - } \ - } \ - \ - addRemovable##argNames##ConstructorToTable \ - (const addRemovable##argNames##ConstructorToTable&) = delete; \ - \ - void operator= \ - (const addRemovable##argNames##ConstructorToTable&) = delete; \ - }; - - -// Constructor aid -#define defineRunTimeSelectionTableConstructor(baseType,argNames) \ - \ - /* Table constructor called from the table add function */ \ - void baseType::construct##argNames##ConstructorTables() \ + /* Table construct/destruct helper */ \ + Tspecialize void prefix##TablePtr_construct(bool load) \ { \ static bool constructed = false; \ - if (!constructed) \ + if (load) \ { \ - constructed = true; \ - baseType::argNames##ConstructorTablePtr_ \ - = new baseType::argNames##ConstructorTableType; \ + if (!constructed) \ + { \ + prefix##TablePtr_ = new prefix##TableType; \ + constructed = true; \ + } \ + } \ + else if (prefix##TablePtr_) \ + { \ + delete prefix##TablePtr_; \ + prefix##TablePtr_ = nullptr; \ + constructed = false; \ } \ } -// Destructor aid -#define defineRunTimeSelectionTableDestructor(baseType,argNames) \ - \ - /* Table destructor called from the table add function destructor */ \ - void baseType::destroy##argNames##ConstructorTables() \ - { \ - if (baseType::argNames##ConstructorTablePtr_) \ - { \ - delete baseType::argNames##ConstructorTablePtr_; \ - baseType::argNames##ConstructorTablePtr_ = nullptr; \ - } \ - } - - -// Create pointer to hash-table of functions -#define defineRunTimeSelectionTablePtr(baseType,argNames) \ - \ - /* Define the constructor function table */ \ - baseType::argNames##ConstructorTableType* \ - baseType::argNames##ConstructorTablePtr_(nullptr) - - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// +// Declaration Macros +// + +//- Declare a run-time selection (variables and adder classes) +// The ptrWrapper is typically a Foam::autoPtr or a Foam::tmp container. +#define declareRunTimeSelectionTable\ +(ptrWrapper,baseType,argNames,argList,parList) \ + \ + declareRunTimeSelectionTableBase( \ + ptrWrapper, argNames##Constructor, argList); \ + \ + /* Helper to add constructor from argList to table */ \ + template \ + struct add##argNames##ConstructorToTable \ + { \ + static ptrWrapper New argList \ + { \ + return ptrWrapper(new baseType##Type parList); \ + } \ + \ + explicit add##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + { \ + argNames##ConstructorTablePtr_construct(true); \ + if (!argNames##ConstructorTablePtr_->insert(k, New)) \ + { \ + std::cerr \ + << "Duplicate entry " << k << " in runtime table " \ + << #baseType << std::endl; \ + ::Foam::error::safePrintStack(std::cerr); \ + } \ + } \ + \ + ~add##argNames##ConstructorToTable() \ + { \ + argNames##ConstructorTablePtr_construct(false); \ + } \ + \ + add##argNames##ConstructorToTable \ + (const add##argNames##ConstructorToTable&) = delete; \ + \ + void operator= \ + (const add##argNames##ConstructorToTable&) = delete; \ + }; \ + \ + /* Helper to add constructor from argList to table */ \ + /* Remove only the entry (not the table) upon destruction */ \ + template \ + struct addRemovable##argNames##ConstructorToTable \ + { \ + const ::Foam::word name; /* Lookup name for later removal */ \ + \ + static ptrWrapper New argList \ + { \ + return ptrWrapper(new baseType##Type parList); \ + } \ + \ + explicit addRemovable##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + : \ + name(k) \ + { \ + argNames##ConstructorTablePtr_construct(true); \ + argNames##ConstructorTablePtr_->set(k, New); \ + } \ + \ + ~addRemovable##argNames##ConstructorToTable() \ + { \ + if (argNames##ConstructorTablePtr_) \ + { \ + argNames##ConstructorTablePtr_->erase(name); \ + } \ + } \ + \ + addRemovable##argNames##ConstructorToTable \ + (const addRemovable##argNames##ConstructorToTable&) = delete; \ + \ + void operator= \ + (const addRemovable##argNames##ConstructorToTable&) = delete; \ + }; + + +//- Declare a run-time selection for derived classes +#define declareRunTimeNewSelectionTable\ +(ptrWrapper,baseType,argNames,argList,parList) \ + \ + declareRunTimeSelectionTableBase( \ + ptrWrapper,argNames##Constructor,argList); \ + \ + /* Helper to add constructor from argList to table */ \ + template \ + struct add##argNames##ConstructorToTable \ + { \ + static ptrWrapper New##baseType argList \ + { \ + return ptrWrapper(baseType##Type::New parList.ptr()); \ + } \ + \ + explicit add##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + { \ + argNames##ConstructorTablePtr_construct(true); \ + if (!argNames##ConstructorTablePtr_->insert(k, New##baseType)) \ + { \ + std::cerr \ + << "Duplicate entry " << k << " in runtime table " \ + << #baseType << std::endl; \ + ::Foam::error::safePrintStack(std::cerr); \ + } \ + } \ + \ + ~add##argNames##ConstructorToTable() \ + { \ + argNames##ConstructorTablePtr_construct(false); \ + } \ + \ + add##argNames##ConstructorToTable \ + (const add##argNames##ConstructorToTable&) = delete; \ + \ + void operator= \ + (const add##argNames##ConstructorToTable&) = delete; \ + }; \ + \ + /* Helper to add constructor from argList to table */ \ + template \ + struct addRemovable##argNames##ConstructorToTable \ + { \ + const ::Foam::word name; /* Retain name for later removal */ \ + \ + static ptrWrapper New##baseType argList \ + { \ + return ptrWrapper(baseType##Type::New parList.ptr()); \ + } \ + \ + explicit addRemovable##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + : \ + name(k) \ + { \ + argNames##ConstructorTablePtr_construct(true); \ + argNames##ConstructorTablePtr_->set(k, New##baseType); \ + } \ + \ + ~addRemovable##argNames##ConstructorToTable() \ + { \ + if (argNames##ConstructorTablePtr_) \ + { \ + argNames##ConstructorTablePtr_->erase(name); \ + } \ + } \ + \ + addRemovable##argNames##ConstructorToTable \ + (const addRemovable##argNames##ConstructorToTable&) = delete; \ + \ + void operator= \ + (const addRemovable##argNames##ConstructorToTable&) = delete; \ + }; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// +// Definition Macros +// + //- Define run-time selection table #define defineRunTimeSelectionTable(baseType,argNames) \ \ - defineRunTimeSelectionTablePtr(baseType,argNames); \ - defineRunTimeSelectionTableConstructor(baseType,argNames); \ - defineRunTimeSelectionTableDestructor(baseType,argNames) + defineRunTimeSelectionTableBase( \ + baseType,baseType::argNames##Constructor,) //- Define run-time selection table for template classes // use when baseType doesn't need a template argument (eg, is a typedef) #define defineTemplateRunTimeSelectionTable(baseType,argNames) \ \ - template<> \ - defineRunTimeSelectionTablePtr(baseType,argNames); \ - template<> \ - defineRunTimeSelectionTableConstructor(baseType,argNames); \ - template<> \ - defineRunTimeSelectionTableDestructor(baseType,argNames) - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Constructor aid: use when baseType requires the Targ template argument -#define defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ)\ - \ - /* Table constructor called from the table add function */ \ - void baseType::construct##argNames##ConstructorTables() \ - { \ - static bool constructed = false; \ - if (!constructed) \ - { \ - constructed = true; \ - baseType::argNames##ConstructorTablePtr_ \ - = new baseType::argNames##ConstructorTableType; \ - } \ - } - - -// Destructor aid: use when baseType requires the Targ template argument -#define defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ) \ - \ - /* Table destructor called from the table add function destructor */ \ - void baseType::destroy##argNames##ConstructorTables() \ - { \ - if (baseType::argNames##ConstructorTablePtr_) \ - { \ - delete baseType::argNames##ConstructorTablePtr_; \ - baseType::argNames##ConstructorTablePtr_ = nullptr; \ - } \ - } - - -//- Create pointer to hash-table of functions -// use when baseType requires the Targ template argument -#define defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ) \ - \ - /* Define the constructor function table */ \ - baseType::argNames##ConstructorTableType* \ - baseType::argNames##ConstructorTablePtr_(nullptr) + defineRunTimeSelectionTableBase( \ + baseType,baseType::argNames##Constructor,template<>) //- Define run-time selection table for template classes // use when baseType requires the Targ template argument #define defineTemplatedRunTimeSelectionTable(baseType,argNames,Targ) \ \ - template<> \ - defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \ - template<> \ - defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \ - template<> \ - defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ) + defineRunTimeSelectionTableBase( \ + baseType,baseType::argNames##Constructor,template<>) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H index 07f83717d7..1fc559276f 100644 --- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +30,10 @@ InClass Description Macros for easy insertion into member function selection tables +Note + The helper macro names used here must remain synchronized with + definitions in memberFunctionSelectionTables.H + \*---------------------------------------------------------------------------*/ #ifndef addToMemberFunctionSelectionTable_H @@ -36,99 +41,70 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// add to hash-table of functions with typename as the key +//- Add to hash-table of functions with typeName as the key. #define addToMemberFunctionSelectionTable\ -(baseType,thisType,memberFunction,argNames) \ +(baseType,thisType,funcName,argNames) \ \ - /* Add the thisType memberFunction to the table */ \ - baseType::add##memberFunction##argNames##MemberFunctionToTable \ - add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_ + /* Add thisType funcName to the table */ \ + baseType::add##funcName##argNames##MemberFunctionToTable \ + add##thisType##funcName##argNames##MemberFunctionTo##baseType##Table_ - -// add to hash-table of functions with 'lookup' as the key +//- Add to hash-table of functions with 'lookupName' as the key. #define addNamedToMemberFunctionSelectionTable\ -(baseType,thisType,memberFunction,argNames,lookup) \ +(baseType,thisType,funcName,argNames,lookupName) \ \ - /* Add the thisType memberFunction to the table, find by lookup name */ \ - baseType::add##memberFunction##argNames##MemberFunctionToTable \ - add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo## \ - baseType##Table_(#lookup) + /* Add thisType funcName to the table, find by lookup name */ \ + baseType::add##funcName##argNames##MemberFunctionToTable \ + add##thisType##funcName##argNames##MemberFunctionTo## \ + baseType##Table_##lookupName##_(#lookupName) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// add to hash-table of functions with typename as the key -// use when baseType doesn't need a template argument (eg, is a typedef) +//- Add to hash-table of functions with typeName as the key. +// Use when baseType doesn't need a template argument (eg, is a typedef) #define addTemplateToMemberFunctionSelectionTable\ -(baseType,thisType,Targ,memberFunction,argNames) \ +(baseType,thisType,Targ,funcName,argNames) \ \ - /* Add the thisType memberFunction to the table */ \ - baseType::add##memberFunction##argNames## \ - MemberFunctionToTable> \ - add##thisType##Targ##memberFunction##argNames##MemberFunctionTo## \ - baseType##Table_ + /* Add thisType funcName to the table */ \ + baseType::add##funcName##argNames##MemberFunctionToTable> \ + add##thisType##Targ##funcName##argNames##MemberFunctionTo## \ + baseType##Table_ -// add to hash-table of functions with 'lookup' as the key -// use when baseType doesn't need a template argument (eg, is a typedef) +//- Add to hash-table of functions with 'lookupName' as the key. +// Use when baseType doesn't need a template argument (eg, is a typedef) #define addNamedTemplateToMemberFunctionSelectionTable\ -(baseType,thisType,Targ,memberFunction,argNames,lookup) \ +(baseType,thisType,Targ,funcName,argNames,lookupName) \ \ - /* Add the thisType memberFunction to the table, find by lookup name */ \ - baseType::add##memberFunction##argNames## \ - MemberFunctionToTable> \ - add_##lookup##_##thisType##Targ##memberFunction##argNames## \ - MemberFunctionTo##baseType##Table_(#lookup) + /* Add thisType funcName to the table, find by lookupName */ \ + baseType::add##funcName##argNames##MemberFunctionToTable> \ + add##thisType##Targ##funcName##argNames##MemberFunctionTo## \ + baseType##Table_##lookupName##_(#lookupName) -// use when baseType requires the Targ template argument as well + +//- Add to hash-table of functions with typeName as the key. +// Use when baseType requires the Targ template argument as well #define addTemplatedToMemberFunctionSelectionTable\ -(baseType,thisType,Targ,memberFunction,argNames) \ +(baseType,thisType,Targ,funcName,argNames) \ \ - /* Add the thisType memberFunction to the table */ \ - baseType::add##memberFunction##argNames## \ - MemberFunctionToTable> \ - add##thisType##Targ##memberFunction##argNames##MemberFunctionTo## \ - baseType##Targ##Table_ + /* Add thisType funcName to the table */ \ + baseType::add##funcName##argNames##MemberFunctionToTable \ + > \ + add##thisType##Targ##funcName##argNames##MemberFunctionTo## \ + baseType##Targ##Table_ -// use when baseType requires the Targ template argument as well +//- Add to hash-table of functions with 'lookupName' as the key. +// Use when baseType requires the Targ template argument as well #define addNamedTemplatedToMemberFunctionSelectionTable\ -(baseType,thisType,Targ,memberFunction,argNames,lookup) \ +(baseType,thisType,Targ,funcName,argNames,lookupName) \ \ - /* Add the thisType memberFunction to the table, find by lookup name */ \ - baseType::add##memberFunction##argNames## \ - MemberFunctionToTable> \ - add_##lookup##_##thisType##Targ##memberFunction##argNames## \ - MemberFunctionTo##baseType##Targ##Table_(#lookup) - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - -// add to hash-table of functions with typename as the key -// use when baseType requires the Targ template argument as well -#define addTemplatedToMemberFunctionSelectionTable\ -(baseType,thisType,Targ,memberFunction,argNames) \ - \ - /* Add the thisType memberFunction to the table */ \ - baseType::add##memberFunction##argNames## \ - MemberFunctionToTable> \ - add##thisType##Targ##memberFunction##argNames##MemberFunctionTo## \ - baseType##Targ##Table_ - - -// add to hash-table of functions with 'lookup' as the key -// use when baseType requires the Targ template argument as well -#define addNamedTemplatedToMemberFunctionSelectionTable\ -(baseType,thisType,Targ,memberFunction,argNames,lookup) \ - \ - /* Add the thisType memberFunction to the table, find by lookup name */ \ - baseType::add##memberFunction##argNames## \ - MemberFunctionToTable> \ - add_##lookup##_##thisType##Targ##memberFunction##argNames## \ - MemberFunctionTo##baseType##Targ##Table_(#lookup) + /* Add thisType funcName to the table, find by lookupName */ \ + baseType::add##funcName##argNames##MemberFunctionToTable \ + > \ + add##thisType##Targ##funcName##argNames##MemberFunctionTo## \ + baseType##Targ##Table_##lookupName##_(#lookupName) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H index b807c40f69..206007a9b2 100644 --- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H @@ -25,206 +25,130 @@ License along with OpenFOAM. If not, see . Description - Macros to enable the easy declaration of member function selection tables. + Macros to ease declaration of member function selection tables. + +Note + Uses macros from runTimeSelectionTables.H \*---------------------------------------------------------------------------*/ -#include "token.H" - #ifndef memberFunctionSelectionTables_H #define memberFunctionSelectionTables_H -#include "HashTable.H" +#include "runTimeSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Declare a run-time selection: -#define declareMemberFunctionSelectionTable( \ - returnType,baseType,memberFunction,argNames,argList,parList) \ +// +// Declaration Macros +// + +//- Declare a run-time member-function selection (variables and adder classes) +#define declareMemberFunctionSelectionTable\ +(returnType,baseType,funcName,argNames,argList,parListUnused) \ \ - /* Construct from argList function pointer type */ \ - typedef returnType (*memberFunction##argNames##MemberFunctionPtr)argList; \ + declareRunTimeSelectionTableBase( \ + returnType, funcName##argNames##MemberFunction, argList); \ \ - /* Construct from argList function table type */ \ - typedef ::Foam::HashTable \ - < \ - memberFunction##argNames##MemberFunctionPtr, \ - ::Foam::word, \ - ::Foam::string::hasher \ - > memberFunction##argNames##MemberFunctionTableType; \ - \ - /* Construct from argList function pointer table pointer */ \ - static memberFunction##argNames##MemberFunctionTableType* \ - memberFunction##argNames##MemberFunctionTablePtr_; \ - \ - /* Class to add constructor from argList to table */ \ + /* Helper to add funcName to table */ \ template \ - class add##memberFunction##argNames##MemberFunctionToTable \ + struct add##funcName##argNames##MemberFunctionToTable \ { \ - public: \ - \ - explicit add##memberFunction##argNames##MemberFunctionToTable \ + explicit add##funcName##argNames##MemberFunctionToTable \ ( \ - const ::Foam::word& lookup = baseType##Type::typeName \ + const ::Foam::word& k = baseType##Type::typeName \ ) \ { \ - construct##memberFunction##argNames##MemberFunctionTables(); \ - memberFunction##argNames##MemberFunctionTablePtr_->insert \ + funcName##argNames##MemberFunctionTablePtr_construct(true); \ + if \ ( \ - lookup, \ - baseType##Type::memberFunction \ - ); \ + !funcName##argNames##MemberFunctionTablePtr_ \ + ->insert(k, baseType##Type::funcName) \ + ) \ + { \ + std::cerr \ + << "Duplicate entry " << k << " in member table " \ + << #baseType << std::endl; \ + ::Foam::error::safePrintStack(std::cerr); \ + } \ } \ \ - ~add##memberFunction##argNames##MemberFunctionToTable() \ + ~add##funcName##argNames##MemberFunctionToTable() \ { \ - destroy##memberFunction##argNames##MemberFunctionTables(); \ + funcName##argNames##MemberFunctionTablePtr_construct(false); \ } \ + \ + add##funcName##argNames##MemberFunctionToTable \ + (const add##funcName##argNames##MemberFunctionToTable&) \ + = delete; \ + void operator= \ + (const add##funcName##argNames##MemberFunctionToTable&) \ + = delete; \ }; \ \ - /* Table memberFunction called from the table add function */ \ - static void construct##memberFunction##argNames##MemberFunctionTables(); \ - \ - /* Table destructor called from the table add function destructor */ \ - static void destroy##memberFunction##argNames##MemberFunctionTables() - - -// Constructor aid -#define defineMemberFunctionSelectionTableMemberFunction( \ - baseType,memberFunction,argNames) \ - \ - /* Table memberFunction called from the table add function */ \ - void baseType::construct##memberFunction##argNames##MemberFunctionTables() \ + /* Helper to add funcName to table */ \ + template \ + struct addRemovable##funcName##argNames##MemberFunctionToTable \ { \ - static bool constructed = false; \ - if (!constructed) \ - { \ - constructed = true; \ - baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ - = new baseType::memberFunction##argNames##MemberFunctionTableType; \ - } \ - } - - -// Destructor aid -#define defineMemberFunctionSelectionTableDestructor( \ - baseType,memberFunction,argNames) \ + const ::Foam::word name; /* Retain name for later removal */ \ \ - /* Table destructor called from the table add function destructor */ \ - void baseType::destroy##memberFunction##argNames##MemberFunctionTables() \ - { \ - if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \ + explicit addRemovable##funcName##argNames##MemberFunctionToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + : \ + name(k) \ { \ - delete baseType::memberFunction##argNames## \ - MemberFunctionTablePtr_; \ - baseType::memberFunction##argNames## \ - MemberFunctionTablePtr_ = nullptr; \ + funcName##argNames##MemberFunctionTablePtr_construct(true); \ + funcName##argNames##MemberFunctionTablePtr_ \ + ->set(k, baseType##Type::funcName); \ } \ - } - - -// Create pointer to hash-table of functions -#define defineMemberFunctionSelectionTablePtr(baseType,memberFunction,argNames)\ \ - /* Define the memberFunction table */ \ - baseType::memberFunction##argNames##MemberFunctionTableType* \ - baseType::memberFunction##argNames##MemberFunctionTablePtr_(nullptr) + ~addRemovable##funcName##argNames##MemberFunctionToTable() \ + { \ + if (funcName##argNames##MemberFunctionTablePtr_) \ + { \ + funcName##argNames##MemberFunctionTablePtr_->erase(name); \ + } \ + } \ + \ + addRemovable##funcName##argNames##MemberFunctionToTable \ + (const addRemovable##funcName##argNames##MemberFunctionToTable&) \ + = delete; \ + void operator= \ + (const addRemovable##funcName##argNames##MemberFunctionToTable&) \ + = delete; \ + }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// +// Definition Macros +// + //- Define run-time selection table -#define defineMemberFunctionSelectionTable(baseType,memberFunction,argNames) \ +#define defineMemberFunctionSelectionTable(baseType,funcName,argNames) \ \ - defineMemberFunctionSelectionTablePtr \ - (baseType,memberFunction,argNames); \ - defineMemberFunctionSelectionTableMemberFunction \ - (baseType,memberFunction,argNames) \ - defineMemberFunctionSelectionTableDestructor \ - (baseType,memberFunction,argNames) + declareRunTimeSelectionTableBase( \ + baseType,baseType::funcName##argNames##MemberFunction,) //- Define run-time selection table for template classes // use when baseType doesn't need a template argument (eg, is a typedef) -#define defineTemplateMemberFunctionSelectionTable( \ - baseType,memberFunction,argNames) \ +#define defineTemplateMemberFunctionSelectionTable(baseType,funcName,argNames) \ \ - template<> \ - defineMemberFunctionSelectionTablePtr \ - (baseType,memberFunction,argNames); \ - template<> \ - defineMemberFunctionSelectionTableMemberFunction \ - (baseType,memberFunction,argNames) \ - template<> \ - defineMemberFunctionSelectionTableDestructor \ - (baseType,memberFunction,argNames) - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Constructor aid: use when baseType requires the Targ template argument -#define defineTemplatedMemberFunctionSelectionTableMemberFunction( \ - baseType,memberFunction,argNames,Targ) \ - \ - /* Table memberFunction called from the table add function */ \ - void baseType::construct##memberFunction##argNames## \ - MemberFunctionTables() \ - { \ - static bool constructed = false; \ - if (!constructed) \ - { \ - constructed = true; \ - baseType::memberFunction##argNames##MemberFunctionTablePtr_ \ - = new baseType::memberFunction##argNames## \ - MemberFunctionTableType; \ - } \ - } - - -// Destructor aid -// use when baseType requires the Targ template argument -#define defineTemplatedMemberFunctionSelectionTableDestructor( \ - baseType,memberFunction,argNames,Targ) \ - \ - /* Table destructor called from the table add function destructor */ \ - void baseType::destroy##memberFunction##argNames## \ - MemberFunctionTables() \ - { \ - if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \ - { \ - delete baseType::memberFunction##argNames## \ - MemberFunctionTablePtr_; \ - baseType::memberFunction##argNames## \ - MemberFunctionTablePtr_ = nullptr; \ - } \ - } - - -// Create pointer to hash-table of functions -// use when baseType requires the Targ template argument -#define defineTemplatedMemberFunctionSelectionTablePtr( \ - baseType,memberFunction,argNames,Targ) \ - \ - /* Define the memberFunction table */ \ - baseType::memberFunction##argNames##MemberFunctionTableType* \ - baseType::memberFunction##argNames## \ - MemberFunctionTablePtr_(nullptr) + declareRunTimeSelectionTableBase( \ + baseType,baseType::funcName##argNames##MemberFunction,template<>) //- Define run-time selection table for template classes // use when baseType requires the Targ template argument -#define defineTemplatedMemberFunctionSelectionTable( \ - baseType,memberFunction,argNames,Targ) \ +#define defineTemplatedMemberFunctionSelectionTable\ +(baseType,funcName,argNames,Targ) \ \ - template<> \ - defineTemplatedMemberFunctionSelectionTablePtr \ - (baseType,memberFunction,argNames,Targ); \ - template<> \ - defineTemplatedMemberFunctionSelectionTableMemberFunction \ - (baseType,memberFunction,argNames,Targ) \ - template<> \ - defineTemplatedMemberFunctionSelectionTableDestructor \ - (baseType,memberFunction,argNames,Targ) + declareRunTimeSelectionTableBase( \ + baseType,baseType::funcName##argNames##MemberFunction,template<>) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // From 794e23e083fe3412cc6e5054e906af5290c3e9e6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 4 Nov 2021 11:39:39 +0100 Subject: [PATCH 4/6] ENH: add error::master() static for low-level messages - a Pstream::master with a Pstream::parRun guard in case Pstream has not yet been initialised, as will be the case for low-level messages during startup. - propagate relativeName handling into IOstreams --- src/OpenFOAM/db/IOobject/IOobjectReadHeader.C | 10 ++--- .../decomposedBlockData/decomposedBlockData.C | 12 +++--- .../db/IOstreams/IOstreams/IOstream.C | 10 ++++- .../db/IOstreams/IOstreams/IOstream.H | 4 ++ src/OpenFOAM/db/dictionary/dictionary.C | 41 ++++++++++--------- src/OpenFOAM/db/dictionary/dictionaryCompat.C | 13 ++---- .../dictionaryEntry/dictionaryEntry.H | 8 +++- src/OpenFOAM/db/dictionary/entry/entry.C | 26 +++++++++--- src/OpenFOAM/db/dictionary/entry/entry.H | 13 +++++- src/OpenFOAM/db/dictionary/entry/entryIO.C | 3 +- .../functionEntries/calcEntry/calcEntry.C | 5 ++- .../functionEntries/codeStream/codeStream.C | 2 +- .../functionEntries/evalEntry/evalEntry.C | 39 +++++++----------- .../functionEntry/functionEntry.C | 15 +++---- .../functionEntry/functionEntry.H | 22 +++++----- .../functionEntries/ifeqEntry/ifeqEntry.C | 4 +- .../includeEntry/includeEntry.C | 6 +-- .../includeEtcEntry/includeEtcEntry.C | 6 +-- .../primitiveEntry/primitiveEntry.H | 6 +++ .../primitiveEntry/primitiveEntryIO.C | 31 +++----------- src/OpenFOAM/db/error/IOerror.C | 15 ++++--- src/OpenFOAM/db/error/error.C | 24 ++++++++--- src/OpenFOAM/db/error/error.H | 11 ++++- src/OpenFOAM/db/error/messageStream.C | 4 +- src/OpenFOAM/global/argList/argList.C | 2 + .../primitives/strings/stringOps/stringOps.C | 6 +-- .../coordinate/systems/coordinateSystemNew.C | 28 +++++++------ .../coordinate/systems/coordinateSystems.C | 13 +++--- .../coordinate/systems/cylindricalCS.C | 4 +- 29 files changed, 212 insertions(+), 171 deletions(-) diff --git a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C index 04e9dac79b..099b2d7e30 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C @@ -84,7 +84,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is) { FatalIOErrorInFunction(is) << " stream not open for reading essential object from file " - << is.name() + << is.relativeName() << exit(FatalIOError); } @@ -92,7 +92,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is) { SeriousIOErrorInFunction(is) << " stream not open for reading from file " - << is.name() << endl; + << is.relativeName() << endl; } return false; @@ -135,8 +135,8 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is) FatalIOErrorInFunction(is) << " stream failure while reading header" << " on line " << is.lineNumber() - << " of file " << is.name() - << " for essential object" << name() + << " of file " << is.relativeName() + << " for essential object:" << name() << exit(FatalIOError); } @@ -145,7 +145,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is) InfoInFunction << "Stream failure while reading header" << " on line " << is.lineNumber() - << " of file " << is.name() << endl; + << " of file " << is.relativeName() << endl; } objState_ = BAD; diff --git a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C index ac00d96cca..f91e5d83a9 100644 --- a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C +++ b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C @@ -259,8 +259,8 @@ Foam::decomposedBlockData::readBlock if (!headerIO.readHeader(*realIsPtr)) { FatalIOErrorInFunction(*realIsPtr) - << "Problem while reading header for object " - << is.name() << nl + << "Problem while reading object header " + << is.relativeName() << nl << exit(FatalIOError); } } @@ -273,8 +273,8 @@ Foam::decomposedBlockData::readBlock if (!headerIO.readHeader(headerStream)) { FatalIOErrorInFunction(headerStream) - << "Problem while reading header for object " - << is.name() << nl + << "Problem while reading object header " + << is.relativeName() << nl << exit(FatalIOError); } streamOptData = static_cast(headerStream); @@ -447,8 +447,8 @@ Foam::autoPtr Foam::decomposedBlockData::readBlocks if (!headerIO.readHeader(*realIsPtr)) { FatalIOErrorInFunction(*realIsPtr) - << "Problem while reading header for object " - << is.name() << nl + << "Problem while reading object header " + << is.relativeName() << nl << exit(FatalIOError); } } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.C b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.C index a824586944..66c6ff87f2 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.C @@ -28,6 +28,7 @@ License #include "IOstream.H" #include "error.H" +#include "argList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -48,6 +49,12 @@ Foam::fileName& Foam::IOstream::name() } +Foam::fileName Foam::IOstream::relativeName() const +{ + return argList::envRelativePath(this->name()); +} + + bool Foam::IOstream::check(const char* operation) const { return fatalCheck(operation); @@ -61,7 +68,8 @@ bool Foam::IOstream::fatalCheck(const char* operation) const if (!ok) { FatalIOErrorInFunction(*this) - << "error in IOstream " << name() << " for operation " << operation + << "error in IOstream " << relativeName() + << " for operation " << operation << exit(FatalIOError); } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H index 2ac6ca0b8e..415fd7d862 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H @@ -201,6 +201,10 @@ public: //- Return stream name for modification virtual fileName& name(); + //- Return the name of the stream relative to the current case. + // Uses argList::envRelativePath() + fileName relativeName() const; + // Check diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 9ef4d995d6..cef7f9ea24 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -262,7 +262,7 @@ void Foam::dictionary::checkITstream "", // functionName "", // sourceFileName 0, // sourceFileLineNumber - this->name(), // ioFileName + relativeName(), // ioFileName == dictionary name is.lineNumber() // ioStartLineNumber ); @@ -284,7 +284,8 @@ void Foam::dictionary::checkITstream << remaining << " excess tokens in stream" << nl << nl; std::cerr - << "file: " << this->name() + // ioFileName == dictionary name + << "file: " << relativeName() << " at line " << is.lineNumber() << '.' << nl << std::endl; @@ -301,7 +302,7 @@ void Foam::dictionary::checkITstream "", // functionName "", // sourceFileName 0, // sourceFileLineNumber - this->name(), // ioFileName + relativeName(), // ioFileName == dictionary name is.lineNumber() // ioStartLineNumber ) << "Entry '" << keyword @@ -317,7 +318,8 @@ void Foam::dictionary::checkITstream << "' had no tokens in stream" << nl << nl; std::cerr - << "file: " << this->name() + // ioFileName == dictionary name + << "file: " << relativeName() << " at line " << is.lineNumber() << '.' << nl << std::endl; @@ -340,7 +342,7 @@ void Foam::dictionary::raiseBadInput "", // functionName "", // sourceFileName 0, // sourceFileLineNumber - this->name(), // ioFileName + relativeName(), // ioFileName == dictionary name is.lineNumber(), // ioStartLineNumber -1 // ioEndLineNumber ) @@ -401,7 +403,7 @@ const Foam::entry& Foam::dictionary::lookupEntry { FatalIOErrorInFunction(*this) << "Entry '" << keyword << "' not found in dictionary " - << name() << nl + << relativeName() << nl << exit(FatalIOError); } @@ -525,7 +527,7 @@ const Foam::dictionary& Foam::dictionary::subDict { FatalIOErrorInFunction(*this) << "Entry '" << keyword << "' not found in dictionary " - << name() << nl + << relativeName() << nl << exit(FatalIOError); } @@ -545,7 +547,7 @@ Foam::dictionary& Foam::dictionary::subDict { FatalIOErrorInFunction(*this) << "Entry '" << keyword << "' not found in dictionary " - << name() << nl + << relativeName() << nl << exit(FatalIOError); } @@ -574,7 +576,7 @@ Foam::dictionary& Foam::dictionary::subDictOrAdd FatalIOErrorInFunction(*this) << "Entry '" << keyword << "' is not a sub-dictionary in dictionary " - << name() << nl + << relativeName() << nl << exit(FatalIOError); } @@ -585,7 +587,7 @@ Foam::dictionary& Foam::dictionary::subDictOrAdd FatalIOErrorInFunction(*this) << "Failed to insert sub-dictionary '" << keyword << "' in dictionary " - << name() << nl + << relativeName() << nl << exit(FatalIOError); } @@ -613,7 +615,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict FatalIOErrorInFunction(*this) << "Entry '" << keyword << "' is not a sub-dictionary in dictionary " - << name() << nl + << relativeName() << nl << exit(FatalIOError); } @@ -622,7 +624,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict IOWarningInFunction(*this) << "Entry '" << keyword << "' found but not a sub-dictionary in dictionary " - << name() << endl; + << relativeName() << endl; } // The move constructor properly qualifies the dictionary name @@ -649,7 +651,7 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict IOWarningInFunction(*this) << "Entry '" << keyword << "' found but not a sub-dictionary in dictionary " - << name() << endl; + << relativeName() << endl; } return *this; @@ -737,7 +739,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) IOWarningInFunction(*this) << "Problem replacing entry "<< entryPtr->keyword() - << " in dictionary " << name() << endl; + << " in dictionary " << relativeName() << endl; parent_type::remove(entryPtr); @@ -765,7 +767,8 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry) IOWarningInFunction(*this) << "Attempt to add entry " << entryPtr->keyword() - << " which already exists in dictionary " << name() << endl; + << " which already exists in dictionary " + << relativeName() << endl; delete entryPtr; return nullptr; @@ -871,7 +874,7 @@ bool Foam::dictionary::merge(const dictionary& dict) { FatalIOErrorInFunction(*this) << "Attempted merge to self, for dictionary " - << name() << nl + << relativeName() << nl << abort(FatalIOError); } @@ -960,7 +963,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs) { FatalIOErrorInFunction(*this) << "Attempted addition to self, for dictionary " - << name() << nl + << relativeName() << nl << abort(FatalIOError); } @@ -977,7 +980,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs) { FatalIOErrorInFunction(*this) << "Attempted |= merging to self, for dictionary " - << name() << nl + << relativeName() << nl << abort(FatalIOError); } @@ -997,7 +1000,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs) { FatalIOErrorInFunction(*this) << "Attempted addition to self, for dictionary " - << name() << nl + << relativeName() << nl << abort(FatalIOError); } diff --git a/src/OpenFOAM/db/dictionary/dictionaryCompat.C b/src/OpenFOAM/db/dictionary/dictionaryCompat.C index c4668e57bf..67fc777866 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryCompat.C +++ b/src/OpenFOAM/db/dictionary/dictionaryCompat.C @@ -50,21 +50,14 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat if (finder.good()) { - // Want single warning (on master), but guard with parRun to avoid - // Pstream::master() when Pstream has not yet been initialized - if - ( - (Pstream::parRun() ? Pstream::master() : true) - && error::warnAboutAge(alt.second) - ) + if (error::warnAboutAge(alt.second) && error::master()) { std::cerr << "--> FOAM IOWarning :" << nl << " Found [v" << alt.second << "] '" << alt.first << "' entry instead of '" << keyword.c_str() << "' in dictionary \"" - << name().c_str() << "\" " - << nl + << relativeName() << '"' << nl << std::endl; error::warnAboutAge("keyword", alt.second); @@ -113,7 +106,7 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat { FatalIOErrorInFunction(*this) << "Entry '" << keyword << "' not found in dictionary " - << name() + << relativeName() << exit(FatalIOError); } diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H index 21ed4be264..1380f427d6 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H +++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H @@ -125,6 +125,12 @@ public: return dictionary::name(); } + //- Return scoped dictionary name relative to the current case + virtual fileName relativeName() const + { + return dictionary::relativeName(); + } + //- Return line number of first token in dictionary virtual label startLineNumber() const; @@ -132,7 +138,7 @@ public: virtual label endLineNumber() const; //- This entry is not a primitive, - // calling this function generates a FatalError + //- calling this function generates a FatalError virtual ITstream& stream() const; diff --git a/src/OpenFOAM/db/dictionary/entry/entry.C b/src/OpenFOAM/db/dictionary/entry/entry.C index 3e5fe33877..a357421a7f 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.C +++ b/src/OpenFOAM/db/dictionary/entry/entry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,6 +44,20 @@ Foam::entry::inputMode Foam::entry::globalInputMode = inputMode::MERGE; // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // +void Foam::entry::reportReadWarning +( + const IOstream& is, + const std::string& msg +) +{ + std::cerr + << "--> FOAM Warning :\n" + << " Reading \"" << is.relativeName() + << "\" at line " << is.lineNumber() << '\n' + << " " << msg << std::endl; +} + + void Foam::entry::resetInputMode() { globalInputMode = inputMode::MERGE; @@ -85,7 +99,7 @@ void Foam::entry::raiseBadInput(const ITstream& is) const "", // functionName "", // sourceFileName 0, // sourceFileLineNumber - this->name(), // ioFileName + this->relativeName(), // ioFileName is.lineNumber() // ioStartLineNumber ) << "Entry '" << keyword << "' with invalid input" << nl << nl @@ -110,7 +124,7 @@ void Foam::entry::checkITstream(const ITstream& is) const "", // functionName "", // sourceFileName 0, // sourceFileLineNumber - this->name(), // ioFileName + this->relativeName(), // ioFileName is.lineNumber() // ioStartLineNumber ); @@ -132,7 +146,7 @@ void Foam::entry::checkITstream(const ITstream& is) const << remaining << " excess tokens in stream" << nl << nl; std::cerr - << "file: " << this->name() + << "file: " << this->relativeName() << " at line " << is.lineNumber() << '.' << nl << std::endl; @@ -149,7 +163,7 @@ void Foam::entry::checkITstream(const ITstream& is) const "", // functionName "", // sourceFileName 0, // sourceFileLineNumber - this->name(), // ioFileName + this->relativeName(), // ioFileName is.lineNumber() // ioStartLineNumber ) << "Entry '" << keyword @@ -165,7 +179,7 @@ void Foam::entry::checkITstream(const ITstream& is) const << "' had no tokens in stream" << nl << nl; std::cerr - << "file: " << this->name() + << "file: " << this->relativeName() << " at line " << is.lineNumber() << '.' << nl << std::endl; diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H index a180e93c23..e91f8aaca1 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.H +++ b/src/OpenFOAM/db/dictionary/entry/entry.H @@ -87,7 +87,7 @@ public: private: - // Private data + // Private Data //- Keyword of entry keyType keyword_; @@ -114,6 +114,14 @@ private: void raiseBadInput(const ITstream& is) const; +protected: + + // Protected Member Functions + + //- Report a read warning (on std::cerr) + static void reportReadWarning(const IOstream&, const std::string&); + + public: //- Enable or disable use of function entries and variable expansions. @@ -202,6 +210,9 @@ public: //- Return the entry name for modification virtual fileName& name() = 0; + //- Return the entry name relative to the current case + virtual fileName relativeName() const = 0; + //- Return line number of first token in dictionary virtual label startLineNumber() const = 0; diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index 48a0d9d83a..886458d77f 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -92,10 +92,11 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is) << "--> FOAM Warning :" << nl << " From function " << FUNCTION_NAME << nl << " in file " << __FILE__ << " at line " << __LINE__ << nl - << " Reading " << is.name() << nl + << " Reading " << is.relativeName() << nl << " found " << keyToken << nl << " expected either " << token::END_BLOCK << " or EOF" << std::endl; + return false; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C index 94c128ef7d..cf3b0734de 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C @@ -68,8 +68,9 @@ Foam::string Foam::functionEntries::calcEntry::evaluate ) { DetailInfo - << "Using #calc at line " << is.lineNumber() - << " in file " << parentDict.name() << endl; + << "Using #calc - line " + << is.lineNumber() << " in file " + << parentDict.relativeName() << nl; dynamicCode::checkSecurity ( diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 78d33f4553..2eedd92ce7 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -356,7 +356,7 @@ Foam::string Foam::functionEntries::codeStream::evaluate { DetailInfo << "Using #codeStream at line " << is.lineNumber() - << " in file " << parentDict.name() << endl; + << " in file " << parentDict.relativeName() << endl; dynamicCode::checkSecurity ( diff --git a/src/OpenFOAM/db/dictionary/functionEntries/evalEntry/evalEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/evalEntry/evalEntry.C index efce884ea6..89d153a31a 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/evalEntry/evalEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/evalEntry/evalEntry.C @@ -58,25 +58,6 @@ namespace functionEntries // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // -namespace -{ - // This is akin to a SafeIOWarning, which does not yet exist - inline void safeIOWarning - ( - const Foam::IOstream& is, - const std::string& msg - ) - { - std::cerr - << "--> FOAM Warning :\n" - << " Reading \"" << is.name() << "\" at line " - << is.lineNumber() << '\n' - << " " << msg << std::endl; - } - -} // End anonymous namespace - - namespace Foam { @@ -158,8 +139,6 @@ static bool slurpUntilBalancedBrace(ISstream& is, std::string& str) str.append(buf, nChar); // Finalize pending content - safeIOWarning(is, "Premature end while reading expression - missing '}'?"); - is.fatalCheck(FUNCTION_NAME); return false; } @@ -252,7 +231,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate { InfoErr << "Empty #eval - line " - << is.lineNumber() << " in file " << parentDict.name() << nl; + << is.lineNumber() << " in file " + << parentDict.relativeName() << nl; return tokenList(); } @@ -268,7 +248,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate { InfoErr << "Failed #eval - line " - << is.lineNumber() << " in file " << parentDict.name() << nl; + << is.lineNumber() << " in file " + << parentDict.relativeName() << nl; return tokenList(); } @@ -296,7 +277,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate #ifdef FULLDEBUG DetailInfo << "Using #eval - line " - << is.lineNumber() << " in file " << parentDict.name() << nl; + << is.lineNumber() << " in file " + << parentDict.relativeName() << nl; #endif token tok(is); @@ -321,7 +303,14 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate else if (tok.isPunctuation(token::BEGIN_BLOCK)) { // - #eval { expr } - slurpUntilBalancedBrace(dynamic_cast(is), str); + if (!slurpUntilBalancedBrace(dynamic_cast(is), str)) + { + reportReadWarning + ( + is, + "Premature end while reading expression - missing '}'?" + ); + } } else { diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 837221ad30..62664f00df 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +72,7 @@ Foam::functionEntry::functionEntry : primitiveEntry ( - word(key+dict.name()+Foam::name(is.lineNumber())), + word(key + dict.name() + Foam::name(is.lineNumber())), readLine(key, is) ) {} @@ -106,9 +107,9 @@ bool Foam::functionEntry::execute { FatalErrorInFunction << "Unknown functionEntry '" << functionName - << "' in " << is.name() << " near line " << is.lineNumber() - << nl << nl - << "Valid functionEntries :" << endl + << "' in " << is.relativeName() + << " near line " << is.lineNumber() << nl << nl + << "Valid functionEntries :" << nl << executedictionaryIstreamMemberFunctionTablePtr_->sortedToc() << exit(FatalError); } @@ -148,9 +149,9 @@ bool Foam::functionEntry::execute { FatalErrorInFunction << "Unknown functionEntry '" << functionName - << "' in " << is.name() << " near line " << is.lineNumber() - << nl << nl - << "Valid functionEntries :" << endl + << "' in " << is.relativeName() + << " near line " << is.lineNumber() << nl << nl + << "Valid functionEntries :" << nl << executeprimitiveEntryIstreamMemberFunctionTablePtr_->sortedToc() << exit(FatalError); } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H index 8eaca87156..9b796f3f60 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,15 +49,15 @@ SourceFiles #ifndef functionEntry_H #define functionEntry_H -#include "word.H" -#include "memberFunctionSelectionTables.H" #include "primitiveEntry.H" +#include "memberFunctionSelectionTables.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward Declarations class dictionary; /*---------------------------------------------------------------------------*\ @@ -67,17 +68,10 @@ class functionEntry : public primitiveEntry { - // Private Member Functions - - //- No copy construct - functionEntry(const functionEntry&) = delete; - - //- No copy assignment - void operator=(const functionEntry&) = delete; - - protected: + // Protected Member Functions + //- Read line and return as a string token static token readLine(const word& key, Istream& is); @@ -86,6 +80,12 @@ protected: template static List readStringList(Istream& is); + //- No copy construct + functionEntry(const functionEntry&) = delete; + + //- No copy assignment + void operator=(const functionEntry&) = delete; + public: // Constructors diff --git a/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C index ab4979f5a9..5e77c6c68a 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/ifeqEntry/ifeqEntry.C @@ -391,8 +391,8 @@ bool Foam::functionEntries::ifeqEntry::execute if (ifEntry::isTrue(e.stream())) { - // Info<< "Using #elif " << doIf << " at line " << lineNo - // << " in file " << is.name() << endl; + // Info<< "Using #elif " << doIf << " - line " << lineNo + // << " in file " << is.relativeName() << endl; break; } } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index 6e7fd29ab8..78620c7da3 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -170,7 +170,7 @@ bool Foam::functionEntries::includeEntry::execute FatalIOErrorInFunction(is) << "Cannot open include file " << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() + << " while reading dictionary " << parentDict.relativeName() << exit(FatalIOError); return false; @@ -222,7 +222,7 @@ bool Foam::functionEntries::includeEntry::execute FatalIOErrorInFunction(is) << "Cannot open include file " << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() + << " while reading dictionary " << parentDict.relativeName() << exit(FatalIOError); return false; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C index 9431a57a92..9c55a6f0c9 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -138,7 +138,7 @@ bool Foam::functionEntries::includeEtcEntry::execute FatalIOErrorInFunction(is) << "Cannot open etc file " << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() + << " while reading dictionary " << parentDict.relativeName() << exit(FatalIOError); return false; @@ -178,7 +178,7 @@ bool Foam::functionEntries::includeEtcEntry::execute FatalIOErrorInFunction(is) << "Cannot open etc file " << (ifs.name().size() ? ifs.name() : rawName) - << " while reading dictionary " << parentDict.name() + << " while reading dictionary " << parentDict.relativeName() << exit(FatalIOError); return false; diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index f05a9b19c6..14e0dfb5ba 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H @@ -155,6 +155,12 @@ public: return ITstream::name(); } + //- Return token stream name relative to the current case + virtual fileName relativeName() const + { + return ITstream::relativeName(); + } + //- Return line number of first token in dictionary virtual label startLineNumber() const; diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 5dccf2fb0a..713351dc12 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -30,27 +30,6 @@ License #include "functionEntry.H" #include "evalEntry.H" -// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // - -namespace -{ - // This is akin to a SafeIOWarning, which does not yet exist - inline void safeIOWarning - ( - const Foam::IOstream& is, - const std::string& msg - ) - { - std::cerr - << "--> FOAM Warning :\n" - << " Reading \"" << is.name() << "\" at line " - << is.lineNumber() << '\n' - << " " << msg << std::endl; - } - -} // End anonymous namespace - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // bool Foam::primitiveEntry::acceptToken @@ -182,7 +161,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) --depth; if (depth < 0) { - safeIOWarning + reportReadWarning ( is, "Too many closing ')' ... was a ';' forgotten?" @@ -191,7 +170,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) else if (depth < 61 && ((balanced >> depth) & 1u)) { // Bit was set, but expected it to be unset. - safeIOWarning(is, "Imbalanced '{' with ')'"); + reportReadWarning(is, "Imbalanced '{' with ')'"); } } break; @@ -201,7 +180,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) --depth; if (depth < 0) { - safeIOWarning + reportReadWarning ( is, "Too many closing '}' ... was a ';' forgotten?" @@ -210,7 +189,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) else if (depth < 61 && !((balanced >> depth) & 1u)) { // Bit was unset, but expected it to be set. - safeIOWarning(is, "Imbalanced '(' with '}'"); + reportReadWarning(is, "Imbalanced '(' with '}'"); } } break; @@ -230,7 +209,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is) if (depth) { - safeIOWarning(is, "Imbalanced brackets"); + reportReadWarning(is, "Imbalanced brackets"); } is.fatalCheck(FUNCTION_NAME); diff --git a/src/OpenFOAM/db/error/IOerror.C b/src/OpenFOAM/db/error/IOerror.C index ec1c7836d2..7f1084498d 100644 --- a/src/OpenFOAM/db/error/IOerror.C +++ b/src/OpenFOAM/db/error/IOerror.C @@ -27,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "error.H" -#include "argList.H" #include "StringStream.H" #include "fileName.H" #include "dictionary.H" @@ -100,7 +99,7 @@ Foam::OSstream& Foam::IOerror::operator() functionName, sourceFileName, sourceFileLineNumber, - argList::envRelativePath(ioStream.name()), + ioStream.relativeName(), ioStream.lineNumber(), -1 // No known endLineNumber ); @@ -137,8 +136,8 @@ Foam::OSstream& Foam::IOerror::operator() ( where.c_str(), "", // No source file - 1, // Non-zero to ensure that 'where' is reported - argList::envRelativePath(ioStream.name()), + -1, // Non-zero to ensure 'where' is reported + ioStream.relativeName(), ioStream.lineNumber(), -1 // No known endLineNumber ); @@ -155,7 +154,7 @@ Foam::OSstream& Foam::IOerror::operator() ( where.c_str(), "", // No source file - 1, // Non-zero to ensure that 'where' is reported + -1, // Non-zero to ensure 'where' is reported dict.relativeName(), dict.startLineNumber(), dict.endLineNumber() @@ -188,7 +187,7 @@ void Foam::IOerror::SafeFatalIOError << nl << "--> FOAM FATAL IO ERROR:" << nl << msg << nl - << "file: " << ioStream.name() + << "file: " << ioStream.relativeName() << " at line " << ioStream.lineNumber() << '.' << nl << nl << " From " << functionName << nl << " in file " << sourceFileName @@ -253,7 +252,7 @@ void Foam::IOerror::abort() } -void Foam::IOerror::write(Ostream& os, const bool includeTitle) const +void Foam::IOerror::write(Ostream& os, const bool withTitle) const { if (os.bad()) { @@ -261,7 +260,7 @@ void Foam::IOerror::write(Ostream& os, const bool includeTitle) const } os << nl; - if (includeTitle && !title().empty()) + if (withTitle && !title().empty()) { os << title().c_str() << "(openfoam-" << foamVersion::api; diff --git a/src/OpenFOAM/db/error/error.C b/src/OpenFOAM/db/error/error.C index 50aebea816..c3acb23a03 100644 --- a/src/OpenFOAM/db/error/error.C +++ b/src/OpenFOAM/db/error/error.C @@ -38,6 +38,20 @@ License // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // +bool Foam::error::master(const label communicator) +{ + // Trap negative value for comm as 'default'. This avoids direct use + // of Pstream::worldComm which may not have been initialised + + return + ( + UPstream::parRun() + ? (communicator < 0 ? UPstream::master() : UPstream::master(communicator)) + : true + ); +} + + bool Foam::error::warnAboutAge(const int version) noexcept { // No warning for 0 (unversioned) or -ve values (silent versioning) @@ -245,20 +259,20 @@ void Foam::error::simpleExit(const int errNo, const bool isAbort) error::printStack(Perr); std::abort(); } - else if (Pstream::parRun()) + else if (UPstream::parRun()) { if (isAbort) { Perr<< nl << *this << nl << "\nFOAM parallel run aborting\n" << endl; error::printStack(Perr); - Pstream::abort(); + UPstream::abort(); } else { Perr<< nl << *this << nl << "\nFOAM parallel run exiting\n" << endl; - Pstream::exit(errNo); + UPstream::exit(errNo); } } else @@ -326,7 +340,7 @@ void Foam::error::abort() } -void Foam::error::write(Ostream& os, const bool includeTitle) const +void Foam::error::write(Ostream& os, const bool withTitle) const { if (os.bad()) { @@ -334,7 +348,7 @@ void Foam::error::write(Ostream& os, const bool includeTitle) const } os << nl; - if (includeTitle && !title().empty()) + if (withTitle && !title().empty()) { os << title().c_str() << "(openfoam-" << foamVersion::api; diff --git a/src/OpenFOAM/db/error/error.H b/src/OpenFOAM/db/error/error.H index 931896bf07..22fe3ad136 100644 --- a/src/OpenFOAM/db/error/error.H +++ b/src/OpenFOAM/db/error/error.H @@ -119,6 +119,13 @@ public: // Static Functions + //- Like Pstream::master but with a Pstream::parRun guard in case + //- Pstream has not yet been initialised. + // + // \param communicator is the numbered MPI communicator. + // By default it uses UPstream::worldComm + static bool master(const label communicator = -1); + //- Test if an age warning should be emitted. // \param version is the old version (YYMM) for determining the // age in months compared to the current OpenFOAM version @@ -244,7 +251,7 @@ public: void abort(); //- Print error message - virtual void write(Ostream& os, const bool includeTitle = true) const; + virtual void write(Ostream& os, const bool withTitle = true) const; // Housekeeping @@ -405,7 +412,7 @@ public: void abort(); //- Print error message - virtual void write(Ostream& os, const bool includeTitle = true) const; + virtual void write(Ostream& os, const bool withTitle = true) const; }; diff --git a/src/OpenFOAM/db/error/messageStream.C b/src/OpenFOAM/db/error/messageStream.C index c0fdd7d6c7..064a95ea87 100644 --- a/src/OpenFOAM/db/error/messageStream.C +++ b/src/OpenFOAM/db/error/messageStream.C @@ -80,10 +80,10 @@ Foam::OSstream& Foam::messageStream::stream(OSstream* alternative) || severity_ == INFO_STDERR || severity_ == WARNING ) - || !Pstream::parRun() + || !UPstream::parRun() ); - if (serialOnly && (Pstream::parRun() && !Pstream::master())) + if (serialOnly && (UPstream::parRun() && !UPstream::master())) { return Snull; // Non-serial, non-master: exit early } diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index ddeb11f77f..8179f39dd2 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -571,6 +571,7 @@ Foam::word Foam::argList::optionCompat(const word& optName) { const auto& alt = fnd.val(); + // No error::master() guard - only called on master anyhow if (error::warnAboutAge(alt.second)) { std::cerr @@ -609,6 +610,7 @@ int Foam::argList::optionIgnore(const word& optName) // '-option ARG' or '-option' const int nskip = (alt.first ? 2 : 1); + // No error::master() guard - only called on master anyhow if (error::warnAboutAge(alt.second)) { std::cerr diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index 63a7a5a60c..c544b1ad99 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -161,9 +161,7 @@ static void expandLeadingTilde(std::string& s) // Compat Warning const int version(1806); - // Single warning (on master) with guard to avoid Pstream::master() - // when Pstream has not yet been initialized - if (UPstream::parRun() ? UPstream::master() : true) + if (error::master()) { std::cerr << nl diff --git a/src/meshTools/coordinate/systems/coordinateSystemNew.C b/src/meshTools/coordinate/systems/coordinateSystemNew.C index 4db528d396..834f1b4183 100644 --- a/src/meshTools/coordinate/systems/coordinateSystemNew.C +++ b/src/meshTools/coordinate/systems/coordinateSystemNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,19 +56,21 @@ const Foam::dictionary* Foam::coordinateSystem::subDictCompat const word csName(finder.ref().stream()); // Deprecated, unsupported syntax + if (error::master()) + { + std::cerr + << "--> FOAM IOWarning :" << nl + << " Ignoring 'coordinateSystem' as a keyword." + " Perhaps you meant this instead?" << nl + << '{' << nl + << " type " << coordSystem::indirect::typeName_() + << ';' << nl + << " name " << csName << ';' << nl + << '}' << nl + << std::endl; - std::cerr - << "--> FOAM IOWarning :" << nl - << " Ignoring 'coordinateSystem' as a keyword." - " Perhaps you meant this instead?" << nl - << '{' << nl - << " type " << coordSystem::indirect::typeName_() - << ';' << nl - << " name " << csName << ';' << nl - << '}' << nl - << std::endl; - - error::warnAboutAge("syntax change", 1806); + error::warnAboutAge("syntax change", 1806); + } } } diff --git a/src/meshTools/coordinate/systems/coordinateSystems.C b/src/meshTools/coordinate/systems/coordinateSystems.C index ce9eb81152..0581a897a9 100644 --- a/src/meshTools/coordinate/systems/coordinateSystems.C +++ b/src/meshTools/coordinate/systems/coordinateSystems.C @@ -60,12 +60,15 @@ void Foam::coordinateSystems::readFromStream(const bool valid) else if (headerClassName() == headerTypeCompat) { // Older (1806 and earlier) header name - std::cerr - << "--> FOAM IOWarning :" << nl - << " Found header class name '" << headerTypeCompat - << "' instead of '" << typeName << "'" << nl; + if (error::master()) + { + std::cerr + << "--> FOAM IOWarning :" << nl + << " Found header class name '" << headerTypeCompat + << "' instead of '" << typeName << "'" << nl; - error::warnAboutAge("header class", 1806); + error::warnAboutAge("header class", 1806); + } this->readIstream(is, coordinateSystem::iNew()); close(); diff --git a/src/meshTools/coordinate/systems/cylindricalCS.C b/src/meshTools/coordinate/systems/cylindricalCS.C index a4884af3e1..6b75f35a90 100644 --- a/src/meshTools/coordinate/systems/cylindricalCS.C +++ b/src/meshTools/coordinate/systems/cylindricalCS.C @@ -55,12 +55,12 @@ namespace Foam static inline void warnCompatDegrees(const Foam::dictionary& dict) { - if (Pstream::parRun() ? Pstream::master() : true) + if (error::master()) { std::cerr << "--> FOAM IOWarning :" << nl << " Found [v1806] 'degrees' keyword in dictionary \"" - << dict.name().c_str() << "\" Ignored, now radians only." << nl + << dict.relativeName() << "\" Ignored, now radians only." << nl << std::endl; } } From 4fc6ec1d1d1c6cd4a537de21e34caa23255f8450 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 15 Jul 2021 01:05:30 +0200 Subject: [PATCH 5/6] ENH: define singleton-style lookups for runTime selection, alias handling - this makes the lookup and use of tables slightly cleaner and provides a hook for update (compat) messages The singleton-style method returns the function pointer directly, or nullptr on not-found. NEW access method (mnemonic: 'ctor' prefix for constructors) ``` auto* ctorPtr = dictionaryConstructorTable(modelType); if (!ctorPtr) { ... } return autoPtr(ctorPtr(dict, ...)); ``` OLD method, which also still works, but without any compat handling: ``` auto ctorIter = dictionaryConstructorTablePtr_->cfind(modelType); if (!ctorIter.found()) { ... } return autoPtr(ctorIter()(dict, ...)); ``` --- .../construction/addToRunTimeSelectionTable.H | 31 ++++++ .../construction/runTimeSelectionTables.H | 102 +++++++++++++++++- .../addToMemberFunctionSelectionTable.H | 33 ++++++ .../memberFunctionSelectionTables.H | 22 +++- 4 files changed, 184 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H index dc839d6dab..885c8bcab4 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H @@ -76,6 +76,16 @@ Note baseType##Table_##lookupName##_(#lookupName) +//- Add lookup alias for runTime selection +#define addAliasToRunTimeSelectionTable\ +(baseType,thisType,argNames,lookup,other,ver) \ + \ + /* Add thisType constructor function to the table, find by lookup */ \ + baseType::addAlias##argNames##ConstructorToTable \ + add##thisType##argNames##ConstructorTo##baseType##Table_ \ + ##lookup##_##other##_(#lookup,#other,ver) + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Add to construction table with typeName as the key. @@ -99,6 +109,16 @@ Note baseType##Table_##lookupName##_(#lookupName) +//- Add lookup alias for for runTime selection +#define addAliasTemplateToRunTimeSelectionTable\ +(baseType,thisType,Targ,argNames,lookup,other,ver) \ + \ + /* Add thisType constructor function to the table, find by lookup */ \ + baseType::addAlias##argNames##ConstructorToTable> \ + add##thisType##Targs##argNames##ConstructorTo##baseType##Table_ \ + ##lookup##_##other##_(#lookup,#other,ver) + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Add to construction table with typeName as the key. @@ -122,6 +142,17 @@ Note baseType##Targ##Table_##lookupName##_(#lookupName) +//- Add lookup alias for for runTime selection +// Use when baseType requires the Targ template argument as well +#define addAliasTemplatedToRunTimeSelectionTable\ +(baseType,thisType,Targ,argNames,lookup,other,ver) \ + \ + /* Add the thisType constructor function to the table, find by lookup */ \ + baseType::add##argNames##ConstructorToTable> \ + add##thisType##Targ##argNames##ConstructorTo##baseType##Targ## \ + Table_##lookup##_##other##_(#lookup,#other,ver) + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H index 0fa16f0e6f..976bd6e7df 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H @@ -40,6 +40,9 @@ Description #ifndef runTimeSelectionTables_H #define runTimeSelectionTables_H +#include // For std::unique_ptr +#include // For std::pair + #include "autoPtr.H" #include "HashTable.H" @@ -61,11 +64,28 @@ Description ::Foam::string::hasher \ > prefix##TableType; \ \ + /* Lookup aliases for constructors */ \ + typedef ::Foam::HashTable \ + < \ + std::pair<::Foam::word,int>, \ + ::Foam::word, \ + ::Foam::string::hasher \ + > prefix##CompatTableType; \ + \ /* Table singleton (storage) */ \ static prefix##TableType* prefix##TablePtr_; \ \ + /* Lookup aliases singleton (storage) */ \ + static std::unique_ptr prefix##CompatTablePtr_; \ + \ + /* Aliases singleton (access) */ \ + static prefix##CompatTableType& prefix##CompatTable(); \ + \ /* Table construct/destruct helper */ \ - static void prefix##TablePtr_construct(bool load) + static void prefix##TablePtr_construct(bool load); \ + \ + /* Lookup function pointer from singleton, nullptr if not found */ \ + static prefix##Ptr prefix##Table(const ::Foam::word& k) // Not used directly: storage and helper methods for runtime tables @@ -74,6 +94,20 @@ Description /* Define table singleton (storage) */ \ Tspecialize prefix##TableType* prefix##TablePtr_(nullptr); \ \ + /* Define aliases singleton (storage) */ \ + Tspecialize \ + std::unique_ptr prefix##CompatTablePtr_(nullptr); \ + \ + /* Define table singleton (access) for aliases */ \ + Tspecialize prefix##CompatTableType& prefix##CompatTable() \ + { \ + if (!prefix##CompatTablePtr_) \ + { \ + prefix##CompatTablePtr_.reset(new prefix##CompatTableType(16)); \ + } \ + return *(prefix##CompatTablePtr_); \ + } \ + \ /* Table construct/destruct helper */ \ Tspecialize void prefix##TablePtr_construct(bool load) \ { \ @@ -90,8 +124,42 @@ Description { \ delete prefix##TablePtr_; \ prefix##TablePtr_ = nullptr; \ + prefix##CompatTablePtr_.reset(nullptr); \ constructed = false; \ } \ + } \ + \ + /* Define lookup function pointer (singleton) */ \ + Tspecialize prefix##Ptr prefix##Table(const ::Foam::word& k) \ + { \ + if (prefix##TablePtr_) \ + { \ + const auto& tbl = *prefix##TablePtr_; \ + auto iter = tbl.cfind(k); \ + if (!iter.found() && prefix##CompatTablePtr_) \ + { \ + const auto altIter = prefix##CompatTablePtr_->cfind(k); \ + if (altIter.found()) \ + { \ + const auto& alt = altIter.val(); /* */ \ + iter = tbl.cfind(alt.first); \ + if (::Foam::error::warnAboutAge(alt.second)) \ + { \ + std::cerr \ + << "Using [v" << alt.second << "] '" << k \ + << "' instead of '" << alt.first \ + << " in runtime selection table: " \ + << #baseType << '\n' << std::endl; \ + ::Foam::error::warnAboutAge("lookup", alt.second); \ + } \ + } \ + } \ + if (iter.found()) \ + { \ + return iter.val(); \ + } \ + } \ + return nullptr; \ } @@ -109,6 +177,22 @@ Description declareRunTimeSelectionTableBase( \ ptrWrapper, argNames##Constructor, argList); \ \ + /* Helper to add compatibility/alias for runtime selection table */ \ + template \ + struct addAlias##argNames##ConstructorToTable \ + { \ + explicit addAlias##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k, \ + const ::Foam::word& alias, \ + const int ver \ + ) \ + { \ + argNames##ConstructorCompatTable() \ + .set(alias, std::pair<::Foam::word,int>(k,ver)); \ + } \ + }; \ + \ /* Helper to add constructor from argList to table */ \ template \ struct add##argNames##ConstructorToTable \ @@ -191,6 +275,22 @@ Description declareRunTimeSelectionTableBase( \ ptrWrapper,argNames##Constructor,argList); \ \ + /* Helper to add compatibility/alias for runtime selection table */ \ + template \ + struct addAlias##argNames##ConstructorToTable \ + { \ + explicit addAlias##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k, \ + const ::Foam::word& alias, \ + const int ver \ + ) \ + { \ + argNames##ConstructorCompatTable() \ + .set(alias, std::pair<::Foam::word,int>(k,ver)); \ + } \ + }; \ + \ /* Helper to add constructor from argList to table */ \ template \ struct add##argNames##ConstructorToTable \ diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H index 1fc559276f..4bd87c3fe4 100644 --- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/addToMemberFunctionSelectionTable.H @@ -60,6 +60,16 @@ Note baseType##Table_##lookupName##_(#lookupName) +//- Add lookup alias for runTime member selection. +#define addAliasToMemberFunctionSelectionTable\ +(baseType,thisType,funcName,argNames,lookup,other,ver) \ + \ + /* Add thisType funcName to the table, find by lookup name */ \ + baseType::addAlias##funcName##argNames##MemberFunctionToTable \ + add##thisType##funcName##argNames##MemberFunctionTo##baseType##Table_ \ + ##lookup##_##other##_(#lookup,#other,ver) + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Add to hash-table of functions with typeName as the key. @@ -84,6 +94,19 @@ Note baseType##Table_##lookupName##_(#lookupName) +//- Add lookup alias for runTime member selection. +#define addAliasTemplateToMemberFunctionSelectionTable\ +(baseType,thisType,Targ,funcName,argNames,lookup,other,ver) \ + \ + /* Add thisType funcName to the table, find by lookup name */ \ + baseType::addAlias##funcName##argNames##MemberFunctionToTable \ + > \ + add##thisType##Targ##funcName##argNames##MemberFunctionTo##baseType \ + ##lookup##_##other##_(#lookup,#other,ver) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + //- Add to hash-table of functions with typeName as the key. // Use when baseType requires the Targ template argument as well #define addTemplatedToMemberFunctionSelectionTable\ @@ -106,6 +129,16 @@ Note add##thisType##Targ##funcName##argNames##MemberFunctionTo## \ baseType##Targ##Table_##lookupName##_(#lookupName) +//- Add lookup alias for runTime member selection. +#define addAliasTemplatedToMemberFunctionSelectionTable\ +(baseType,thisType,Targ,funcName,argNames,lookup,other,ver) \ + \ + /* Add thisType funcName to the table, find by lookup name */ \ + baseType::addAlias##funcName##argNames##MemberFunctionToTable \ + > \ + add##thisType##Targ##funcName##argNames##MemberFunctionTo##baseType## \ + Targ##Table_##lookup##_##other##_(#lookup,#other,ver) + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H index 206007a9b2..bab205eff7 100644 --- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H @@ -118,6 +118,22 @@ Note void operator= \ (const addRemovable##funcName##argNames##MemberFunctionToTable&) \ = delete; \ + }; \ + \ + /* Helper to add alias for funcName to table */ \ + template \ + struct addAlias##funcName##argNames##MemberFunctionToTable \ + { \ + explicit addAlias##funcName##argNames##MemberFunctionToTable \ + ( \ + const ::Foam::word& k, \ + const ::Foam::word& alias, \ + const int ver \ + ) \ + { \ + funcName##argNames##MemberFunctionCompatTable() \ + .set(alias, std::pair<::Foam::word,int>(k,ver)); \ + } \ }; @@ -130,7 +146,7 @@ Note //- Define run-time selection table #define defineMemberFunctionSelectionTable(baseType,funcName,argNames) \ \ - declareRunTimeSelectionTableBase( \ + defineRunTimeSelectionTableBase( \ baseType,baseType::funcName##argNames##MemberFunction,) @@ -138,7 +154,7 @@ Note // use when baseType doesn't need a template argument (eg, is a typedef) #define defineTemplateMemberFunctionSelectionTable(baseType,funcName,argNames) \ \ - declareRunTimeSelectionTableBase( \ + defineRunTimeSelectionTableBase( \ baseType,baseType::funcName##argNames##MemberFunction,template<>) @@ -147,7 +163,7 @@ Note #define defineTemplatedMemberFunctionSelectionTable\ (baseType,funcName,argNames,Targ) \ \ - declareRunTimeSelectionTableBase( \ + defineRunTimeSelectionTableBase( \ baseType,baseType::funcName##argNames##MemberFunction,template<>) From ba8d6bddcc0209cc242525b5e95d8f132d2995f9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 12 Oct 2021 19:44:00 +0200 Subject: [PATCH 6/6] ENH: use singleton method for accessing runtime selection STYLE: use alias to mark partialFaceAreaWeightAMI deprecation after v2012 --- .../dragModels/PDRDragModel/PDRDragModelNew.C | 10 +++-- .../XiEqModels/XiEqModel/XiEqModelNew.C | 8 ++-- .../XiModels/XiGModels/XiGModel/XiGModelNew.C | 8 ++-- .../PDRFoam/XiModels/XiModel/XiModelNew.C | 10 +++-- .../mixtureViscosityModelNew.C | 10 +++-- .../relativeVelocityModel.C | 8 ++-- .../reflectionModel/reflectionModelNew.C | 8 ++-- ...temperaturePhaseChangeTwoPhaseMixtureNew.C | 8 ++-- .../phaseChangeTwoPhaseMixtureNew.C | 8 ++-- .../cellSizeAndAlignmentControl.C | 8 ++-- .../cellSizeFunction/cellSizeFunction.C | 8 ++-- .../cellSizeCalculationType.C | 8 ++-- .../surfaceCellSizeFunction.C | 8 ++-- .../faceAreaWeightModel/faceAreaWeightModel.C | 8 ++-- .../initialPointsMethod/initialPointsMethod.C | 8 ++-- .../relaxationModel/relaxationModel.C | 8 ++-- .../searchableSurfaceFeatures.C | 8 ++-- .../faceSelection/faceSelection.C | 8 ++-- .../helpBoundary/helpBoundaryTemplates.C | 1 + .../foamHelp/helpTypes/helpType/helpTypeNew.C | 7 +-- .../PDR/pdrFields/obstacles/PDRobstacle.C | 4 +- .../PDR/pdrFields/obstacles/PDRobstacle.H | 4 +- .../PDR/pdrFields/obstacles/PDRobstacleIO.C | 20 +++++---- .../pdrFields/obstacles/PDRobstacleTypes.C | 4 +- .../implicitFunctions/implicitFunction.C | 8 ++-- .../tabulatedWallFunctionNew.C | 8 ++-- .../surfaceFeaturesExtraction.C | 8 ++-- .../searchableSurfaceModifier.C | 8 ++-- src/ODE/ODESolvers/ODESolver/ODESolverNew.C | 8 ++-- src/OpenFOAM/db/IOstreams/token/token.C | 6 +-- .../functionEntry/functionEntry.C | 19 ++++---- .../functionObject/functionObject.C | 8 ++-- .../expressions/exprEntry/expressionEntry.C | 8 ++-- .../expressions/exprResult/exprResult.C | 12 ++--- .../calculated/calculatedPointPatchField.C | 8 ++-- .../pointPatchField/pointPatchFieldNew.C | 36 +++++++-------- .../fileOperation/fileOperation.C | 6 +-- .../fileOperationInitialise.C | 6 +-- src/OpenFOAM/graph/graph.C | 8 ++-- .../tableReaders/tableReader.C | 8 ++-- .../interpolationWeights.C | 8 ++-- .../LduMatrix/LduMatrixPreconditioner.C | 16 +++---- .../LduMatrix/LduMatrix/LduMatrixSmoother.C | 14 +++--- .../LduMatrix/LduMatrix/LduMatrixSolver.C | 12 ++--- .../lduMatrix/lduMatrixPreconditioner.C | 14 +++--- .../lduMatrix/lduMatrix/lduMatrixSmoother.C | 14 +++--- .../lduMatrix/lduMatrix/lduMatrixSolver.C | 12 ++--- .../GAMGAgglomeration/GAMGAgglomeration.C | 25 +++++------ .../GAMGProcAgglomeration.C | 7 +-- .../GAMGInterfaceFieldNew.C | 14 +++--- .../GAMGInterface/GAMGInterfaceNew.C | 14 +++--- .../facePointPatch/facePointPatchNew.C | 8 ++-- .../polyPatches/polyPatch/polyPatch.C | 16 ++++--- .../polyPatches/polyPatch/polyPatchNew.C | 18 ++++---- .../polyMesh/zones/cellZone/cellZoneNew.C | 8 ++-- .../polyMesh/zones/faceZone/faceZoneNew.C | 8 ++-- .../polyMesh/zones/pointZone/pointZoneNew.C | 8 ++-- .../Function1/Function1/Function1New.C | 6 +-- .../turbulenceModels/LES/LESModel/LESModel.C | 6 +-- .../LES/LESdeltas/LESdelta/LESdelta.C | 27 +++++++----- .../LES/LESfilters/LESfilter/LESfilter.C | 8 ++-- .../turbulenceModels/RAS/RASModel/RASModel.C | 6 +-- .../TurbulenceModel/TurbulenceModel.C | 8 ++-- .../generalizedNewtonianViscosityModelNew.C | 8 ++-- .../laminar/laminarModel/laminarModel.C | 8 ++-- .../reactionRateFlameAreaNew.C | 8 ++-- .../combustionModelTemplates.C | 2 +- .../dynamicFvMesh/dynamicFvMeshNew.C | 13 +++--- .../simplifiedDynamicFvMesh.C | 8 ++-- .../meshCut/cellLooper/cellLooper.C | 8 ++-- .../displacement/displacementMotionSolver.C | 8 ++-- .../solidBodyMotionFunctionNew.C | 8 ++-- .../motionSolvers/motionSolver/motionSolver.C | 6 +-- .../polyMeshModifier/polyMeshModifierNew.C | 8 ++-- .../engineMesh/engineMesh/engineMeshNew.C | 8 ++-- .../engineTime/engineTime/engineTimeNew.C | 8 ++-- src/faOptions/faOption/faOption.C | 6 +-- src/fileFormats/sampledSetWriters/writer.C | 8 ++-- .../faMesh/faPatches/faPatch/faPatchNew.C | 8 ++-- .../basic/calculated/calculatedFaPatchField.C | 8 ++-- .../faPatchField/faPatchFieldNew.C | 44 +++++++++---------- .../calculated/calculatedFaePatchField.C | 8 ++-- .../faePatchField/faePatchFieldNew.C | 40 ++++++++--------- .../faConvectionScheme/faConvectionScheme.C | 8 ++-- .../faD2dt2Scheme/faD2dt2Scheme.C | 8 ++-- .../ddtSchemes/faDdtScheme/faDdtScheme.C | 8 ++-- .../divSchemes/faDivScheme/faDivScheme.C | 8 ++-- .../gradSchemes/faGradScheme/faGradScheme.C | 8 ++-- .../faLaplacianScheme/faLaplacianScheme.C | 8 ++-- .../lnGradSchemes/lnGradScheme/lnGradScheme.C | 8 ++-- .../edgeInterpolationScheme.C | 14 +++--- .../SRF/SRFModel/SRFModel/SRFModelNew.C | 8 ++-- .../cfdTools/general/fvOptions/fvOption.C | 6 +-- .../porosityModel/porosityModelNew.C | 8 ++-- .../expressions/base/fvExprDriverNew.C | 14 +++--- .../basic/calculated/calculatedFvPatchField.C | 7 +-- .../fvPatchField/fvPatchFieldNew.C | 39 ++++++++-------- .../calculated/calculatedFvsPatchField.C | 7 +-- .../fvsPatchField/fvsPatchFieldNew.C | 41 +++++++++-------- .../convectionScheme/convectionScheme.C | 14 +++--- .../d2dt2Schemes/d2dt2Scheme/d2dt2Scheme.C | 8 ++-- .../ddtSchemes/ddtScheme/ddtScheme.C | 8 ++-- .../divSchemes/divScheme/divScheme.C | 7 +-- .../gradSchemes/gradScheme/gradScheme.C | 8 ++-- .../laplacianScheme/laplacianScheme.C | 8 ++-- .../snGradSchemes/snGradScheme/snGradScheme.C | 8 ++-- .../multiDimPolyFunctions.C | 7 +-- .../fvGeometryScheme/fvGeometryScheme.C | 8 ++-- .../fvMesh/fvPatches/fvPatch/fvPatch.C | 18 +++++--- .../fvMesh/fvPatches/fvPatch/fvPatchNew.C | 8 ++-- .../simplifiedFvMesh/simplifiedFvMesh.C | 17 +++---- .../patchDistMethod/patchDistMethod.C | 6 +-- .../interpolation/interpolationNew.C | 8 ++-- .../limitedSurfaceInterpolationScheme.C | 14 +++--- .../multivariateSurfaceInterpolationScheme.C | 8 ++-- .../surfaceInterpolationScheme.C | 14 +++--- .../DMD/DMDModels/DMDModel/DMDModelNew.C | 6 +-- .../fieldValues/fieldValue/fieldValueNew.C | 8 ++-- .../heatTransferCoeffModelNew.C | 8 ++-- .../runTimeCondition/runTimeConditionNew.C | 8 ++-- .../motionDiffusivity/motionDiffusivity.C | 8 ++-- .../motionInterpolation/motionInterpolation.C | 8 ++-- .../profileModel/profileModel.C | 6 +-- .../trimModel/trimModel/trimModelNew.C | 8 ++-- .../BinaryCollisionModelNew.C | 8 ++-- .../InflowBoundaryModelNew.C | 8 ++-- .../WallInteractionModelNew.C | 8 ++-- .../distributionModel/distributionModelNew.C | 8 ++-- .../integrationScheme/integrationSchemeNew.C | 8 ++-- .../CloudFunctionObjectNew.C | 8 ++-- .../HeterogeneousReactingModelNew.C | 8 ++-- .../CollisionModel/CollisionModelNew.C | 8 ++-- .../PairModel/PairModel/PairModelNew.C | 8 ++-- .../WallModel/WallModel/WallModelNew.C | 8 ++-- .../DispersionModel/DispersionModelNew.C | 8 ++-- .../InjectionModel/InjectionModelNew.C | 14 +++--- .../ParticleForce/ParticleForceNew.C | 8 ++-- .../PatchInteractionModelNew.C | 8 ++-- .../StochasticCollisionModelNew.C | 9 ++-- .../SurfaceFilmModel/SurfaceFilmModelNew.C | 8 ++-- .../AveragingMethod/AveragingMethod.C | 8 ++-- .../CorrectionLimitingMethod.C | 8 ++-- .../DampingModels/DampingModel/DampingModel.C | 8 ++-- .../IsotropyModel/IsotropyModel.C | 8 ++-- .../PackingModels/PackingModel/PackingModel.C | 8 ++-- .../ParticleStressModel/ParticleStressModel.C | 8 ++-- .../TimeScaleModel/TimeScaleModel.C | 8 ++-- .../CompositionModel/CompositionModelNew.C | 8 ++-- .../PhaseChangeModel/PhaseChangeModelNew.C | 8 ++-- .../DevolatilisationModelNew.C | 8 ++-- .../SurfaceReactionModelNew.C | 8 ++-- .../HeatTransferModel/HeatTransferModelNew.C | 8 ++-- .../basic/energyScalingFunctionNew.C | 8 ++-- .../pairPotential/basic/pairPotentialNew.C | 8 ++-- .../basic/tetherPotentialNew.C | 8 ++-- .../AtomizationModel/AtomizationModelNew.C | 8 ++-- .../BreakupModel/BreakupModelNew.C | 8 ++-- .../blockEdges/blockEdge/blockEdge.C | 8 ++-- .../blockFaces/blockFace/blockFace.C | 8 ++-- .../blockVertices/blockVertex/blockVertex.C | 6 +-- src/mesh/blockMesh/blocks/block/block.C | 8 ++-- .../extrudeModel/extrudeModelNew.C | 8 ++-- .../externalDisplacementMeshMover.C | 8 ++-- .../AMIInterpolation/AMIInterpolationNew.C | 14 +++--- .../faceAreaWeightAMI/faceAreaWeightAMI.C | 10 +++-- .../PatchFunction1/PatchFunction1New.C | 6 +-- .../PatchFunction1/makePatchFunction1s.C | 6 +-- .../coordinate/rotation/coordinateRotation.C | 6 +-- .../coordinate/systems/coordinateSystemNew.C | 21 ++++----- src/meshTools/edgeMesh/edgeMesh.C | 2 +- src/meshTools/edgeMesh/edgeMeshIO.C | 6 +-- src/meshTools/edgeMesh/edgeMeshNew.C | 8 ++-- .../extendedEdgeMesh/extendedEdgeMesh.C | 2 +- .../extendedEdgeMesh/extendedEdgeMeshNew.C | 8 ++-- .../searchableSurface/searchableSurface.C | 8 ++-- .../topoSetCellSource/topoSetCellSource.C | 12 ++--- .../topoSetCellZoneSource.C | 12 ++--- .../topoSetFaceSource/topoSetFaceSource.C | 12 ++--- .../topoSetFaceZoneSource.C | 12 ++--- .../topoSetPointSource/topoSetPointSource.C | 12 ++--- .../topoSetPointZoneSource.C | 12 ++--- .../sets/topoSetSource/topoSetSource.C | 12 ++--- src/meshTools/sets/topoSets/topoSet.C | 18 ++++---- .../adjoint/ATCModel/ATCModel/ATCModel.C | 8 ++-- .../zeroATCcells/zeroATCcells/zeroATCcells.C | 8 ++-- .../boundaryAdjointContribution.C | 8 ++-- .../displacementMethod/displacementMethod.C | 8 ++-- .../objectiveManager/objectiveManager.C | 8 ++-- .../objectiveIncompressible.C | 8 ++-- .../adjoint/objectives/objective/objective.C | 8 ++-- .../adjointSensitivityIncompressible.C | 8 ++-- .../lineSearch/lineSearch/lineSearch.C | 8 ++-- .../stepUpdate/stepUpdate/stepUpdate.C | 8 ++-- .../optMeshMovement/optMeshMovement.C | 8 ++-- .../optimisationManager/optimisationManager.C | 8 ++-- .../optimisationTypeIncompressible.C | 8 ++-- .../updateMethod/updateMethod/updateMethod.C | 8 ++-- .../NURBS3DVolume/NURBS3DVolume.C | 8 ++-- .../controlPointsDefinition.C | 7 +-- .../adjointSolver/adjointSolver.C | 8 ++-- .../incompressibleAdjointSolver.C | 8 ++-- .../incompressiblePrimalSolver.C | 8 ++-- .../primalSolvers/primalSolver/primalSolver.C | 8 ++-- .../SIMPLEControl/SIMPLEControl.C | 8 ++-- .../adjointRASModel/adjointRASModel.C | 8 ++-- .../adjointTurbulenceModel.C | 9 ++-- .../RAS/RASModelVariables/RASModelVariables.C | 8 ++-- .../cellCellStencil/cellCellStencil.C | 8 ++-- .../decompositionConstraint.C | 6 +-- .../decompositionMethod/decompositionMethod.C | 6 +-- .../diameterModel/diameterModel.C | 8 ++-- .../dragModels/dragModel/dragModel.C | 8 ++-- .../heatTransferModel/heatTransferModel.C | 8 ++-- .../interfaceCompositionModel.C | 8 ++-- .../porousModels/porousModel/porousModel.C | 8 ++-- .../surfaceTensionModel/surfaceTensionModel.C | 8 ++-- .../multiphaseSystem/multiphaseSystemNew.C | 8 ++-- .../phaseModel/phaseModel/phaseModel.C | 8 ++-- .../blendingMethod/blendingMethod.C | 8 ++-- .../CHFModels/CHFModel/CHFModel.C | 8 ++-- .../CHFSubCoolModel/CHFSubCoolModel.C | 8 ++-- .../LeidenfrostModel/LeidenfrostModel.C | 8 ++-- .../MHFModels/MHFModel/MHFModel.C | 8 ++-- .../TDNBModels/TDNBModel/TDNBModel.C | 8 ++-- .../departureDiameterModel.C | 8 ++-- .../departureFrequencyModel.C | 8 ++-- .../filmBoilingModel/filmBoilingModel.C | 8 ++-- .../nucleationSiteModel/nucleationSiteModel.C | 8 ++-- .../partitioningModel/partitioningModel.C | 8 ++-- .../diameterModel/diameterModel.C | 9 ++-- .../interfaceCompositionModel.C | 7 +-- .../massTransferModel/massTransferModel.C | 8 ++-- .../saturationModel/saturationModel.C | 8 ++-- .../surfaceTensionModel/surfaceTensionModel.C | 8 ++-- .../aspectRatioModel/aspectRatioModel.C | 8 ++-- .../dragModels/dragModel/dragModel.C | 8 ++-- .../heatTransferModel/heatTransferModel.C | 8 ++-- .../liftModels/liftModel/liftModel.C | 8 ++-- .../phaseTransferModel/phaseTransferModel.C | 8 ++-- .../swarmCorrection/swarmCorrection.C | 8 ++-- .../turbulentDispersionModel.C | 8 ++-- .../virtualMassModel/virtualMassModel.C | 8 ++-- .../wallDampingModel/wallDampingModel.C | 8 ++-- .../wallLubricationModel.C | 8 ++-- .../multiphaseSystem/multiphaseSystemNew.C | 8 ++-- .../phaseModel/phaseModel/phaseModel.C | 8 ++-- .../binaryBreakupModel/binaryBreakupModel.C | 8 ++-- .../breakupModels/breakupModel/breakupModel.C | 8 ++-- .../coalescenceModel/coalescenceModel.C | 8 ++-- .../daughterSizeDistributionModel.C | 8 ++-- .../driftModels/driftModel/driftModel.C | 8 ++-- .../nucleationModel/nucleationModel.C | 8 ++-- .../conductivityModel/conductivityModel.C | 8 ++-- .../frictionalStressModel.C | 8 ++-- .../granularPressureModel.C | 8 ++-- .../radialModel/radialModel/radialModel.C | 8 ++-- .../viscosityModel/viscosityModel.C | 8 ++-- .../IATE/IATEsources/IATEsource/IATEsource.C | 8 ++-- .../twoPhaseSystem/twoPhaseSystemNew.C | 8 ++-- .../conductivityModel/conductivityModel.C | 8 ++-- .../frictionalStressModel.C | 8 ++-- .../granularPressureModel.C | 8 ++-- .../radialModel/radialModel/radialModel.C | 8 ++-- .../viscosityModel/viscosityModel.C | 8 ++-- .../blendingMethod/blendingMethod.C | 8 ++-- .../IATE/IATEsources/IATEsource/IATEsource.C | 8 ++-- .../diameterModel/diameterModel.C | 8 ++-- .../aspectRatioModel/aspectRatioModel.C | 8 ++-- .../dragModels/dragModel/dragModel.C | 8 ++-- .../heatTransferModel/heatTransferModel.C | 8 ++-- .../liftModels/liftModel/liftModel.C | 8 ++-- .../swarmCorrection/swarmCorrection.C | 8 ++-- .../turbulentDispersionModel.C | 8 ++-- .../virtualMassModel/virtualMassModel.C | 8 ++-- .../wallLubricationModel.C | 8 ++-- .../noiseModels/noiseModel/noiseModelNew.C | 8 ++-- .../windowModels/windowModel/windowModelNew.C | 8 ++-- .../liquidFilm/liquidFilmBaseNew.C | 23 +++++----- .../filmTurbulenceModelNew.C | 8 ++-- .../kinematic/force/force/forceNew.C | 8 ++-- .../injectionModel/injectionModelNew.C | 6 +-- .../thermalShellModel/thermalShellModelNew.C | 8 ++-- .../vibrationShellModelNew.C | 8 ++-- .../pyrolysisModel/pyrolysisModelNew.C | 14 +++--- .../regionModelFunctionObjectNew.C | 8 ++-- .../filmThermoModel/filmThermoModelNew.C | 9 ++-- .../filmTurbulenceModelNew.C | 8 ++-- .../kinematic/force/force/forceNew.C | 8 ++-- .../injectionModel/injectionModelNew.C | 8 ++-- .../transferModel/transferModelNew.C | 8 ++-- .../filmRadiationModelNew.C | 8 ++-- .../filmViscosityModelNew.C | 8 ++-- .../heatTransferModel/heatTransferModelNew.C | 8 ++-- .../phaseChangeModel/phaseChangeModelNew.C | 8 ++-- .../surfaceFilmModel/surfaceFilmModelNew.C | 8 ++-- .../thermalBaffleModelNew.C | 14 +++--- .../renumberMethod/renumberMethod.C | 8 ++-- .../bodies/rigidBody/rigidBody.C | 8 ++-- src/rigidBodyDynamics/joints/joint/joint.C | 8 ++-- .../restraint/rigidBodyRestraintNew.C | 8 ++-- .../rigidBodySolver/rigidBodySolverNew.C | 8 ++-- .../meshToMeshMethod/meshToMeshMethodNew.C | 8 ++-- .../sampledSet/sampledSet/sampledSet.C | 8 ++-- .../sampledSurface/readers/surfaceReaderNew.C | 8 ++-- .../sampledSurface/sampledSurface.C | 6 +-- .../sixDoFRigidBodyMotionConstraintNew.C | 8 ++-- .../sixDoFRigidBodyMotionRestraintNew.C | 8 ++-- .../sixDoFSolver/sixDoFSolverNew.C | 8 ++-- src/surfMesh/MeshedSurface/MeshedSurface.C | 6 +-- src/surfMesh/MeshedSurface/MeshedSurfaceNew.C | 8 ++-- .../MeshedSurfaceProxy/MeshedSurfaceProxy.C | 8 ++-- .../UnsortedMeshedSurface.C | 8 ++-- .../UnsortedMeshedSurfaceNew.C | 8 ++-- src/surfMesh/writers/surfaceWriter.C | 25 ++++++----- .../barotropicCompressibilityModelNew.C | 8 ++-- .../chemistryReductionMethodNew.C | 6 +-- .../chemistryTabulationMethodNew.C | 6 +-- .../basicChemistryModelTemplates.C | 6 +-- .../laminarFlameSpeed/laminarFlameSpeedNew.C | 8 ++-- .../radiationModel/radiationModelNew.C | 14 +++--- .../absorptionEmissionModelNew.C | 8 ++-- .../boundaryRadiationPropertiesPatch.C | 8 ++-- .../scatterModel/scatterModelNew.C | 8 ++-- .../sootModel/sootModel/sootModelNew.C | 8 ++-- .../wallAbsorptionEmissionModelNew.C | 8 ++-- .../wallTransmissivityModelNew.C | 8 ++-- .../chemistryReader/chemistryReader.C | 8 ++-- .../basicSolidChemistryModelNew.C | 6 +-- .../reaction/Reactions/Reaction/Reaction.C | 8 ++-- .../liquidProperties/liquidProperties.C | 23 +++++----- .../solidProperties/solidPropertiesNew.C | 14 +++--- .../thermophysicalFunction.C | 14 +++--- .../thermophysicalProperties.C | 14 +++--- .../reconstructionSchemesNew.C | 7 +-- .../viscosityModel/viscosityModelNew.C | 8 ++-- .../surfaceTensionModelNew.C | 8 ++-- src/waveModels/waveModel/waveModelNew.C | 8 ++-- 337 files changed, 1555 insertions(+), 1542 deletions(-) diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C index b7bfbd08ae..80c429419d 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::autoPtr Foam::PDRDragModel::New Info<< "Selecting drag model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -57,7 +57,9 @@ Foam::autoPtr Foam::PDRDragModel::New } return autoPtr - (cstrIter()(dict, turbulence, rho, U, phi)); + ( + ctorPtr(dict, turbulence, rho, U, phi) + ); } diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C index ff1f3ccbdf..3cb2daa4b8 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,9 +42,9 @@ Foam::autoPtr Foam::XiEqModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -55,7 +55,7 @@ Foam::autoPtr Foam::XiEqModel::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict, thermo, turbulence, Su)); + return autoPtr(ctorPtr(dict, thermo, turbulence, Su)); } diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C index 1061ae392a..f8f6d355d8 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,9 +42,9 @@ Foam::autoPtr Foam::XiGModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -55,7 +55,7 @@ Foam::autoPtr Foam::XiGModel::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict, thermo, turbulence, Su)); + return autoPtr(ctorPtr(dict, thermo, turbulence, Su)); } diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C b/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C index eb2d92eebc..46a23d41fd 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,9 +45,9 @@ Foam::autoPtr Foam::XiModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -59,7 +59,9 @@ Foam::autoPtr Foam::XiModel::New } return autoPtr - (cstrIter()(dict, thermo, turbulence, Su, rho, b, phi)); + ( + ctorPtr(dict, thermo, turbulence, Su, rho, b, phi) + ); } diff --git a/applications/solvers/multiphase/driftFluxFoam/mixtureViscosityModels/mixtureViscosityModel/mixtureViscosityModelNew.C b/applications/solvers/multiphase/driftFluxFoam/mixtureViscosityModels/mixtureViscosityModel/mixtureViscosityModelNew.C index 40fb18ef6c..6fc82c54bb 100644 --- a/applications/solvers/multiphase/driftFluxFoam/mixtureViscosityModels/mixtureViscosityModel/mixtureViscosityModelNew.C +++ b/applications/solvers/multiphase/driftFluxFoam/mixtureViscosityModels/mixtureViscosityModel/mixtureViscosityModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,9 +44,9 @@ Foam::autoPtr Foam::mixtureViscosityModel::New Info<< "Selecting incompressible transport model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -58,7 +58,9 @@ Foam::autoPtr Foam::mixtureViscosityModel::New } return autoPtr - (cstrIter()(name, dict, U, phi)); + ( + ctorPtr(name, dict, U, phi) + ); } diff --git a/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C b/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C index 13ac5c1d7d..2cdf9d7626 100644 --- a/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C +++ b/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -111,9 +111,9 @@ Foam::autoPtr Foam::relativeVelocityModel::New Info<< "Selecting relative velocity model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -127,7 +127,7 @@ Foam::autoPtr Foam::relativeVelocityModel::New return autoPtr ( - cstrIter() + ctorPtr ( dict.optionalSubDict(modelType + "Coeffs"), mixture diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/reflectionModel/reflectionModel/reflectionModelNew.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/reflectionModel/reflectionModel/reflectionModelNew.C index 62bc964218..ae30ffd4b1 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/reflectionModel/reflectionModel/reflectionModelNew.C +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/reflectionModel/reflectionModel/reflectionModelNew.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,9 +41,9 @@ Foam::radiation::reflectionModel::New Info<< "Selecting reflectionModel " << modelType << endl; - const auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -54,7 +54,7 @@ Foam::radiation::reflectionModel::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict, mesh)); + return autoPtr(ctorPtr(dict, mesh)); } diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtureNew.C b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtureNew.C index 02bb89045a..0de3d22ae3 100644 --- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtureNew.C +++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtures/temperaturePhaseChangeTwoPhaseMixtureNew.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,9 +54,9 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New Info<< "Selecting phaseChange model " << modelType << endl; - auto cstrIter = componentsConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = componentsConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -70,7 +70,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New return autoPtr ( - cstrIter()(thermo, mesh) + ctorPtr(thermo, mesh) ); } diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/phaseChangeTwoPhaseMixture/phaseChangeTwoPhaseMixtureNew.C b/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/phaseChangeTwoPhaseMixture/phaseChangeTwoPhaseMixtureNew.C index eb7b80d04d..db6564ffa1 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/phaseChangeTwoPhaseMixture/phaseChangeTwoPhaseMixtureNew.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/phaseChangeTwoPhaseMixtures/phaseChangeTwoPhaseMixture/phaseChangeTwoPhaseMixtureNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,9 +56,9 @@ Foam::phaseChangeTwoPhaseMixture::New Info<< "Selecting phaseChange model " << modelType << endl; - auto cstrIter = componentsConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = componentsConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -69,7 +69,7 @@ Foam::phaseChangeTwoPhaseMixture::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(U, phi)); + return autoPtr(ctorPtr(U, phi)); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C index 441f5391d5..150135ba9a 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,9 +80,9 @@ Foam::cellSizeAndAlignmentControl::New Info<< indent << "Selecting cellSizeAndAlignmentControl " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -95,7 +95,7 @@ Foam::cellSizeAndAlignmentControl::New return autoPtr ( - cstrIter() + ctorPtr ( runTime, name, diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C index a7a4e673f1..7d0aa35585 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -134,9 +134,9 @@ Foam::autoPtr Foam::cellSizeFunction::New Info<< indent << "Selecting cellSizeFunction " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -149,7 +149,7 @@ Foam::autoPtr Foam::cellSizeFunction::New return autoPtr ( - cstrIter() + ctorPtr ( dict, surface, diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/cellSizeCalculationType/cellSizeCalculationType.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/cellSizeCalculationType/cellSizeCalculationType.C index 322c0f19b5..0435c3fc43 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/cellSizeCalculationType/cellSizeCalculationType.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/cellSizeCalculationType/cellSizeCalculationType.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,9 +67,9 @@ Foam::autoPtr Foam::cellSizeCalculationType::New Info<< indent << "Selecting cellSizeCalculationType " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -82,7 +82,7 @@ Foam::autoPtr Foam::cellSizeCalculationType::New return autoPtr ( - cstrIter()(dict, surface, defaultCellSize) + ctorPtr(dict, surface, defaultCellSize) ); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/surfaceCellSizeFunction/surfaceCellSizeFunction.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/surfaceCellSizeFunction/surfaceCellSizeFunction.C index da5e87dda5..905739ea93 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/surfaceCellSizeFunction/surfaceCellSizeFunction.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/surfaceCellSizeFunction/surfaceCellSizeFunction.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,9 +72,9 @@ Foam::autoPtr Foam::surfaceCellSizeFunction::New Info<< indent << "Selecting surfaceCellSizeFunction " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -87,7 +87,7 @@ Foam::autoPtr Foam::surfaceCellSizeFunction::New return autoPtr ( - cstrIter()(dict, surface, defaultCellSize) + ctorPtr(dict, surface, defaultCellSize) ); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C index a3da8a6c8c..6ca72fdce8 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,9 +61,9 @@ Foam::autoPtr Foam::faceAreaWeightModel::New Info<< nl << "Selecting faceAreaWeightModel " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -74,7 +74,7 @@ Foam::autoPtr Foam::faceAreaWeightModel::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict)); + return autoPtr(ctorPtr(dict)); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C index 7c16c948bc..1ed3f52e01 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -84,9 +84,9 @@ Foam::autoPtr Foam::initialPointsMethod::New Info<< nl << "Selecting initialPointsMethod " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -100,7 +100,7 @@ Foam::autoPtr Foam::initialPointsMethod::New return autoPtr ( - cstrIter() + ctorPtr ( dict, runTime, diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/relaxationModel/relaxationModel/relaxationModel.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/relaxationModel/relaxationModel/relaxationModel.C index 9121d9792f..fa9ac3b124 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/relaxationModel/relaxationModel/relaxationModel.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/relaxationModel/relaxationModel/relaxationModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,9 +65,9 @@ Foam::autoPtr Foam::relaxationModel::New Info<< nl << "Selecting relaxationModel " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -78,7 +78,7 @@ Foam::autoPtr Foam::relaxationModel::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict, runTime)); + return autoPtr(ctorPtr(dict, runTime)); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.C index 17b7cb14c4..c26412f069 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/searchableSurfaceFeatures/searchableSurfaceFeatures.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,9 +48,9 @@ Foam::searchableSurfaceFeatures::New { const word modelType(surface.type() + "Features"); - auto cstrIter = dictConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -61,7 +61,7 @@ Foam::searchableSurfaceFeatures::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(surface, dict)); + return autoPtr(ctorPtr(surface, dict)); } diff --git a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.C b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.C index bc30bb2c8a..015be95822 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.C +++ b/applications/utilities/mesh/manipulation/createBaffles/faceSelection/faceSelection.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,9 +71,9 @@ Foam::autoPtr Foam::faceSelection::New { const word modelType(dict.get("type")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -84,7 +84,7 @@ Foam::autoPtr Foam::faceSelection::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(name, mesh, dict)); + return autoPtr(ctorPtr(name, mesh, dict)); } diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C index 43fa15d792..9e2faa1794 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundaryTemplates.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C index c6c65b47b4..59a8851c40 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpType/helpTypeNew.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,9 +35,9 @@ Foam::autoPtr Foam::helpType::New const word& helpTypeName ) { - auto cstrIter = dictionaryConstructorTablePtr_->cfind(helpTypeName); + auto* ctorPtr = dictionaryConstructorTable(helpTypeName); - if (!cstrIter.found()) + if (!ctorPtr) { // special treatment for -help // exit without stack trace @@ -61,7 +62,7 @@ Foam::autoPtr Foam::helpType::New Info<< "Selecting helpType '" << helpTypeName << "'" << endl; - return autoPtr(cstrIter()()); + return autoPtr(ctorPtr()); } diff --git a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C index a13bba92bc..1625ad1d3f 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C +++ b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,7 +40,7 @@ using namespace Foam::constant; namespace Foam { - defineMemberFunctionSelectionTable(PDRobstacle, read, dictRead); + defineMemberFunctionSelectionTable(PDRobstacle, read, dictionary); } diff --git a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.H b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.H index 7328b7ecb0..d0dede5418 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.H +++ b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 Shell Research Ltd. - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -178,7 +178,7 @@ public: void, PDRobstacle, read, - dictRead, + dictionary, ( PDRobstacle& obs, const dictionary& dict diff --git a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleIO.C b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleIO.C index 342a3175cf..dfd1bcd39a 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleIO.C +++ b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleIO.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,18 +41,20 @@ bool Foam::PDRobstacle::read(Istream& is) const word obsType(is); const dictionary dict(is); - const auto mfIter = readdictReadMemberFunctionTablePtr_->cfind(obsType); + auto* mfuncPtr = readdictionaryMemberFunctionTable(obsType); - if (!mfIter.good()) + if (!mfuncPtr) { - FatalIOErrorInFunction(is) - << "Unknown obstacle type: " << obsType << nl - << "Valid types:" << nl - << readdictReadMemberFunctionTablePtr_->sortedToc() << nl - << exit(FatalIOError); + FatalIOErrorInLookup + ( + is, + "obstacle", + obsType, + *readdictionaryMemberFunctionTablePtr_ + ) << exit(FatalIOError); } - mfIter()(*this, dict); + mfuncPtr(*this, dict); return true; } diff --git a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C index 3fc8275f46..078b5a7df0 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C +++ b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacleTypes.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ using namespace Foam::constant; PDRobstacle, \ obsType, \ read, \ - dictRead, \ + dictionary, \ obsName \ ); \ } \ diff --git a/applications/utilities/preProcessing/setAlphaField/alphaFieldFunctions/implicitFunctions/implicitFunction.C b/applications/utilities/preProcessing/setAlphaField/alphaFieldFunctions/implicitFunctions/implicitFunction.C index fb5e1220f6..bc6b33f426 100644 --- a/applications/utilities/preProcessing/setAlphaField/alphaFieldFunctions/implicitFunctions/implicitFunction.C +++ b/applications/utilities/preProcessing/setAlphaField/alphaFieldFunctions/implicitFunctions/implicitFunction.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2020 DLR ------------------------------------------------------------------------------- License @@ -46,9 +46,9 @@ Foam::autoPtr Foam::implicitFunction::New const dictionary& dict ) { - auto cstrIter = dictConstructorTablePtr_->cfind(implicitFunctionType); + auto* ctorPtr = dictConstructorTable(implicitFunctionType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -59,7 +59,7 @@ Foam::autoPtr Foam::implicitFunction::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict)); + return autoPtr(ctorPtr(dict)); } diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionNew.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionNew.C index cb862e61c0..5ee26060e3 100644 --- a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionNew.C +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,9 +41,9 @@ Foam::tabulatedWallFunctions::tabulatedWallFunction::New Info<< "Selecting tabulatedWallFunction " << functionName << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(functionName); + auto* ctorPtr = dictionaryConstructorTable(functionName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -54,7 +54,7 @@ Foam::tabulatedWallFunctions::tabulatedWallFunction::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict, mesh)); + return autoPtr(ctorPtr(dict, mesh)); } diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C index 3e924b4e00..b5723df239 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,9 +72,9 @@ Foam::surfaceFeaturesExtraction::method::New { const word modelType(dict.get("extractionMethod")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -85,7 +85,7 @@ Foam::surfaceFeaturesExtraction::method::New ) << exit(FatalIOError); } - return autoPtr(cstrIter.val()(dict)); + return autoPtr(ctorPtr(dict)); } diff --git a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.C b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.C index dcd295f001..0b3b028fe1 100644 --- a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.C +++ b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/searchableSurfaceModifier.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,9 +67,9 @@ Foam::searchableSurfaceModifier::New const dictionary& dict ) { - auto cstrIter = dictionaryConstructorTablePtr_->cfind(type); + auto* ctorPtr = dictionaryConstructorTable(type); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -80,7 +80,7 @@ Foam::searchableSurfaceModifier::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(geometry, dict)); + return autoPtr(ctorPtr(geometry, dict)); } diff --git a/src/ODE/ODESolvers/ODESolver/ODESolverNew.C b/src/ODE/ODESolvers/ODESolver/ODESolverNew.C index 1ed2d81c87..b9a88f2aeb 100644 --- a/src/ODE/ODESolvers/ODESolver/ODESolverNew.C +++ b/src/ODE/ODESolvers/ODESolver/ODESolverNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,9 +39,9 @@ Foam::autoPtr Foam::ODESolver::New const word solverType(dict.get("solver")); Info<< "Selecting ODE solver " << solverType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(solverType); + auto* ctorPtr = dictionaryConstructorTable(solverType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -52,7 +52,7 @@ Foam::autoPtr Foam::ODESolver::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(odes, dict)); + return autoPtr(ctorPtr(odes, dict)); } diff --git a/src/OpenFOAM/db/IOstreams/token/token.C b/src/OpenFOAM/db/IOstreams/token/token.C index 313ca75fd1..5cfbdfb8fd 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.C +++ b/src/OpenFOAM/db/IOstreams/token/token.C @@ -58,9 +58,9 @@ Foam::autoPtr Foam::token::compound::New Istream& is ) { - auto cstrIter = IstreamConstructorTablePtr_->cfind(compoundType); + auto* ctorPtr = IstreamConstructorTable(compoundType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -71,7 +71,7 @@ Foam::autoPtr Foam::token::compound::New ) << abort(FatalIOError); } - return autoPtr(cstrIter()(is)); + return autoPtr(ctorPtr(is)); } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 62664f00df..c363b63f87 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -100,10 +100,10 @@ bool Foam::functionEntry::execute return true; } - auto mfIter = - executedictionaryIstreamMemberFunctionTablePtr_->cfind(functionName); + auto* mfuncPtr = + executedictionaryIstreamMemberFunctionTable(functionName); - if (!mfIter.found()) + if (!mfuncPtr) { FatalErrorInFunction << "Unknown functionEntry '" << functionName @@ -114,7 +114,7 @@ bool Foam::functionEntry::execute << exit(FatalError); } - return mfIter()(parentDict, is); + return mfuncPtr(parentDict, is); } @@ -139,13 +139,10 @@ bool Foam::functionEntry::execute return true; } - auto mfIter = - executeprimitiveEntryIstreamMemberFunctionTablePtr_->cfind - ( - functionName - ); + auto* mfuncPtr = + executeprimitiveEntryIstreamMemberFunctionTable(functionName); - if (!mfIter.found()) + if (!mfuncPtr) { FatalErrorInFunction << "Unknown functionEntry '" << functionName @@ -156,7 +153,7 @@ bool Foam::functionEntry::execute << exit(FatalError); } - return mfIter()(parentDict, entry, is); + return mfuncPtr(parentDict, entry, is); } diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index edabdf8d0a..2229135ae3 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -108,9 +108,9 @@ Foam::autoPtr Foam::functionObject::New << exit(FatalError); } - auto cstrIter = dictionaryConstructorTablePtr_->cfind(functionType); + auto* ctorPtr = dictionaryConstructorTable(functionType); - if (!cstrIter.found()) + if (!ctorPtr) { // FatalError (not FatalIOError) to ensure it can be caught // as an exception and ignored @@ -122,7 +122,7 @@ Foam::autoPtr Foam::functionObject::New ) << exit(FatalError); } - return autoPtr(cstrIter()(name, runTime, dict)); + return autoPtr(ctorPtr(name, runTime, dict)); } diff --git a/src/OpenFOAM/expressions/exprEntry/expressionEntry.C b/src/OpenFOAM/expressions/exprEntry/expressionEntry.C index 6e83f0b738..652572b5ed 100644 --- a/src/OpenFOAM/expressions/exprEntry/expressionEntry.C +++ b/src/OpenFOAM/expressions/exprEntry/expressionEntry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Original code Copyright (C) 2014-2018 Bernhard Gschaider - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -119,9 +119,9 @@ Foam::exprTools::expressionEntry::New const word& name ) { - auto cstrIter = emptyConstructorTablePtr_->cfind(name); + auto* ctorPtr = emptyConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -131,7 +131,7 @@ Foam::exprTools::expressionEntry::New ) << exit(FatalError); } - return autoPtr(cstrIter()()); + return autoPtr(ctorPtr()); } diff --git a/src/OpenFOAM/expressions/exprResult/exprResult.C b/src/OpenFOAM/expressions/exprResult/exprResult.C index 2b43da245f..a208502198 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResult.C +++ b/src/OpenFOAM/expressions/exprResult/exprResult.C @@ -314,9 +314,9 @@ Foam::expressions::exprResult::New if (dict.getOrDefault("unsetValue", false)) { - auto cstrIter = emptyConstructorTablePtr_->cfind(resultType); + auto* ctorPtr = emptyConstructorTable(resultType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -330,13 +330,13 @@ Foam::expressions::exprResult::New DebugInfo << "Creating unset result of type " << resultType << nl; - return autoPtr(cstrIter()()); + return autoPtr(ctorPtr()); } - auto cstrIter = dictionaryConstructorTablePtr_->cfind(resultType); + auto* ctorPtr = dictionaryConstructorTable(resultType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -350,7 +350,7 @@ Foam::expressions::exprResult::New DebugInfo << "Creating result of type " << resultType << nl; - return autoPtr(cstrIter()(dict)); + return autoPtr(ctorPtr(dict)); } diff --git a/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C index 60a2a4b7eb..34002cc383 100644 --- a/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/basic/calculated/calculatedPointPatchField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -93,14 +94,13 @@ Foam::pointPatchField::NewCalculatedType const pointPatchField& pf ) { - auto patchTypeCstrIter = - pointPatchConstructorTablePtr_->cfind(pf.patch().type()); + auto* patchTypeCtor = pointPatchConstructorTable(pf.patch().type()); - if (patchTypeCstrIter.found()) + if (patchTypeCtor) { return autoPtr> ( - patchTypeCstrIter() + patchTypeCtor ( pf.patch(), Field::null() diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C index 42dafa6419..38efd74909 100644 --- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldNew.C @@ -39,9 +39,9 @@ Foam::autoPtr> Foam::pointPatchField::New { DebugInFunction << "Constructing pointPatchField" << endl; - auto cstrIter = pointPatchConstructorTablePtr_->cfind(patchFieldType); + auto* ctorPtr = pointPatchConstructorTable(patchFieldType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -51,7 +51,7 @@ Foam::autoPtr> Foam::pointPatchField::New ) << exit(FatalError); } - autoPtr> pfPtr(cstrIter()(p, iF)); + autoPtr> pfPtr(ctorPtr(p, iF)); if ( @@ -64,10 +64,9 @@ Foam::autoPtr> Foam::pointPatchField::New // Incompatible (constraint-wise) with the patch type // - use default constraint type - auto patchTypeCstrIter = - pointPatchConstructorTablePtr_->cfind(p.type()); + auto* patchTypeCtor = pointPatchConstructorTable(p.type()); - if (!patchTypeCstrIter.found()) + if (!patchTypeCtor) { FatalErrorInFunction << "Inconsistent patch and patchField types for\n" @@ -76,7 +75,7 @@ Foam::autoPtr> Foam::pointPatchField::New << exit(FatalError); } - return patchTypeCstrIter()(p, iF); + return patchTypeCtor(p, iF); } } else @@ -115,16 +114,16 @@ Foam::autoPtr> Foam::pointPatchField::New const word patchFieldType(dict.get("type")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchFieldType); + auto* ctorPtr = dictionaryConstructorTable(patchFieldType); - if (!cstrIter.found()) + if (!ctorPtr) { if (!disallowGenericPointPatchField) { - cstrIter = dictionaryConstructorTablePtr_->cfind("generic"); + ctorPtr = dictionaryConstructorTable("generic"); } - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInFunction(dict) << "Unknown patchField type " << patchFieldType @@ -136,7 +135,7 @@ Foam::autoPtr> Foam::pointPatchField::New } // Construct (but not necessarily returned) - autoPtr> pfPtr(cstrIter()(p, iF, dict)); + autoPtr> pfPtr(ctorPtr(p, iF, dict)); if ( @@ -149,10 +148,9 @@ Foam::autoPtr> Foam::pointPatchField::New // Incompatible (constraint-wise) with the patch type // - use default constraint type - auto patchTypeCstrIter = - dictionaryConstructorTablePtr_->cfind(p.type()); + auto* patchTypeCtor = dictionaryConstructorTable(p.type()); - if (!patchTypeCstrIter.found()) + if (!patchTypeCtor) { FatalIOErrorInFunction(dict) << "Inconsistent patch and patchField types for\n" @@ -161,7 +159,7 @@ Foam::autoPtr> Foam::pointPatchField::New << exit(FatalIOError); } - return patchTypeCstrIter()(p, iF, dict); + return patchTypeCtor(p, iF, dict); } } @@ -180,9 +178,9 @@ Foam::autoPtr> Foam::pointPatchField::New { DebugInFunction << "Constructing pointPatchField" << endl; - auto cstrIter = patchMapperConstructorTablePtr_->cfind(ptf.type()); + auto* ctorPtr = patchMapperConstructorTable(ptf.type()); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -192,7 +190,7 @@ Foam::autoPtr> Foam::pointPatchField::New ) << exit(FatalError); } - return cstrIter()(ptf, p, iF, pfMapper); + return ctorPtr(ptf, p, iF, pfMapper); } diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C index 3919c92f96..94d9adf1b1 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C +++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C @@ -711,9 +711,9 @@ Foam::fileOperation::New DebugInFunction << "Constructing fileHandler" << endl; - auto cstrIter = wordConstructorTablePtr_->cfind(handlerType); + auto* ctorPtr = wordConstructorTable(handlerType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -723,7 +723,7 @@ Foam::fileOperation::New ) << abort(FatalError); } - return autoPtr(cstrIter()(verbose)); + return autoPtr(ctorPtr(verbose)); } diff --git a/src/OpenFOAM/global/fileOperations/fileOperationInitialise/fileOperationInitialise.C b/src/OpenFOAM/global/fileOperations/fileOperationInitialise/fileOperationInitialise.C index ff83c57845..562fc7c266 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperationInitialise/fileOperationInitialise.C +++ b/src/OpenFOAM/global/fileOperations/fileOperationInitialise/fileOperationInitialise.C @@ -85,9 +85,9 @@ Foam::fileOperations::fileOperationInitialise::New { DebugInFunction << "Constructing fileOperationInitialise" << endl; - auto cstrIter = wordConstructorTablePtr_->cfind(type); + auto* ctorPtr = wordConstructorTable(type); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -97,7 +97,7 @@ Foam::fileOperations::fileOperationInitialise::New ) << abort(FatalError); } - return autoPtr(cstrIter()(argc, argv)); + return autoPtr(ctorPtr(argc, argv)); } diff --git a/src/OpenFOAM/graph/graph.C b/src/OpenFOAM/graph/graph.C index 0e0f18dac5..eaa4a7b1cd 100644 --- a/src/OpenFOAM/graph/graph.C +++ b/src/OpenFOAM/graph/graph.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -219,9 +219,9 @@ Foam::autoPtr Foam::graph::writer::New << exit(FatalError); } - auto cstrIter = wordConstructorTablePtr_->cfind(graphFormat); + auto* ctorPtr = wordConstructorTable(graphFormat); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -231,7 +231,7 @@ Foam::autoPtr Foam::graph::writer::New ) << exit(FatalError); } - return autoPtr(cstrIter()()); + return autoPtr(ctorPtr()); } diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C index c3d2423de6..c11f5df271 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C +++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,9 +42,9 @@ Foam::autoPtr> Foam::tableReader::New "openFoam" ); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(readerType); + auto* ctorPtr = dictionaryConstructorTable(readerType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -55,7 +55,7 @@ Foam::autoPtr> Foam::tableReader::New ) << exit(FatalIOError); } - return autoPtr>(cstrIter()(spec)); + return autoPtr>(ctorPtr(spec)); } diff --git a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C index 540fa01f79..c64c815d88 100644 --- a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C +++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,9 +57,9 @@ Foam::autoPtr Foam::interpolationWeights::New { DebugInFunction << "Selecting interpolationWeights " << type << endl; - auto cstrIter = wordConstructorTablePtr_->cfind(type); + auto* ctorPtr = wordConstructorTable(type); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -69,7 +69,7 @@ Foam::autoPtr Foam::interpolationWeights::New ) << exit(FatalError); } - return autoPtr(cstrIter()(samples)); + return autoPtr(ctorPtr(samples)); } diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C index 31a359ee07..c61d8b6a76 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,10 +45,9 @@ Foam::LduMatrix::preconditioner::New if (sol.matrix().symmetric()) { - auto cstrIter = - symMatrixConstructorTablePtr_->cfind(preconditionerName); + auto* ctorPtr = symMatrixConstructorTable(preconditionerName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -61,7 +60,7 @@ Foam::LduMatrix::preconditioner::New return autoPtr::preconditioner> ( - cstrIter() + ctorPtr ( sol, preconditionerDict @@ -70,10 +69,9 @@ Foam::LduMatrix::preconditioner::New } else if (sol.matrix().asymmetric()) { - auto cstrIter = - asymMatrixConstructorTablePtr_->cfind(preconditionerName); + auto* ctorPtr = asymMatrixConstructorTable(preconditionerName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -86,7 +84,7 @@ Foam::LduMatrix::preconditioner::New return autoPtr::preconditioner> ( - cstrIter() + ctorPtr ( sol, preconditionerDict diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C index 7796bfea81..69f5073f09 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::LduMatrix::smoother::New if (matrix.symmetric()) { - auto cstrIter = symMatrixConstructorTablePtr_->cfind(smootherName); + auto* ctorPtr = symMatrixConstructorTable(smootherName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -58,7 +58,7 @@ Foam::LduMatrix::smoother::New return autoPtr::smoother> ( - cstrIter() + ctorPtr ( fieldName, matrix @@ -67,9 +67,9 @@ Foam::LduMatrix::smoother::New } else if (matrix.asymmetric()) { - auto cstrIter = asymMatrixConstructorTablePtr_->cfind(smootherName); + auto* ctorPtr = asymMatrixConstructorTable(smootherName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -82,7 +82,7 @@ Foam::LduMatrix::smoother::New return autoPtr::smoother> ( - cstrIter() + ctorPtr ( fieldName, matrix diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C index f8d88c2c4b..59d117381e 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C @@ -56,9 +56,9 @@ Foam::LduMatrix::solver::New } else if (matrix.symmetric()) { - auto cstrIter = symMatrixConstructorTablePtr_->cfind(solverName); + auto* ctorPtr = symMatrixConstructorTable(solverName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -71,7 +71,7 @@ Foam::LduMatrix::solver::New return autoPtr::solver> ( - cstrIter() + ctorPtr ( fieldName, matrix, @@ -81,9 +81,9 @@ Foam::LduMatrix::solver::New } else if (matrix.asymmetric()) { - auto cstrIter = asymMatrixConstructorTablePtr_->cfind(solverName); + auto* ctorPtr = asymMatrixConstructorTable(solverName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -96,7 +96,7 @@ Foam::LduMatrix::solver::New return autoPtr::solver> ( - cstrIter() + ctorPtr ( fieldName, matrix, diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C index fe87a93f41..8cf8789338 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,9 +90,9 @@ Foam::lduMatrix::preconditioner::New if (sol.matrix().symmetric()) { - auto cstrIter = symMatrixConstructorTablePtr_->cfind(name); + auto* ctorPtr = symMatrixConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -105,7 +105,7 @@ Foam::lduMatrix::preconditioner::New return autoPtr ( - cstrIter() + ctorPtr ( sol, controls @@ -114,9 +114,9 @@ Foam::lduMatrix::preconditioner::New } else if (sol.matrix().asymmetric()) { - auto cstrIter = asymMatrixConstructorTablePtr_->cfind(name); + auto* ctorPtr = asymMatrixConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -129,7 +129,7 @@ Foam::lduMatrix::preconditioner::New return autoPtr ( - cstrIter() + ctorPtr ( sol, controls diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C index a66348f245..901d4ea880 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -93,9 +93,9 @@ Foam::autoPtr Foam::lduMatrix::smoother::New if (matrix.symmetric()) { - auto cstrIter = symMatrixConstructorTablePtr_->cfind(name); + auto* ctorPtr = symMatrixConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -108,7 +108,7 @@ Foam::autoPtr Foam::lduMatrix::smoother::New return autoPtr ( - cstrIter() + ctorPtr ( fieldName, matrix, @@ -120,9 +120,9 @@ Foam::autoPtr Foam::lduMatrix::smoother::New } else if (matrix.asymmetric()) { - auto cstrIter = asymMatrixConstructorTablePtr_->cfind(name); + auto* ctorPtr = asymMatrixConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -135,7 +135,7 @@ Foam::autoPtr Foam::lduMatrix::smoother::New return autoPtr ( - cstrIter() + ctorPtr ( fieldName, matrix, diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 2a7bb5ec6e..bae0f3d9e7 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C @@ -70,9 +70,9 @@ Foam::autoPtr Foam::lduMatrix::solver::New } else if (matrix.symmetric()) { - auto cstrIter = symMatrixConstructorTablePtr_->cfind(name); + auto* ctorPtr = symMatrixConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -85,7 +85,7 @@ Foam::autoPtr Foam::lduMatrix::solver::New return autoPtr ( - cstrIter() + ctorPtr ( fieldName, matrix, @@ -98,9 +98,9 @@ Foam::autoPtr Foam::lduMatrix::solver::New } else if (matrix.asymmetric()) { - auto cstrIter = asymMatrixConstructorTablePtr_->cfind(name); + auto* ctorPtr = asymMatrixConstructorTable(name); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -113,7 +113,7 @@ Foam::autoPtr Foam::lduMatrix::solver::New return autoPtr ( - cstrIter() + ctorPtr ( fieldName, matrix, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C index 645cfaa152..4a5ffe33fe 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C @@ -319,9 +319,9 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New lduMeshConstructorTablePtr_ ); - auto cstrIter = lduMeshConstructorTablePtr_->cfind(agglomeratorType); + auto* ctorPtr = lduMeshConstructorTable(agglomeratorType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInFunction << "Unknown GAMGAgglomeration type " @@ -333,7 +333,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New << exit(FatalError); } - return store(cstrIter()(mesh, controlDict).ptr()); + return store(ctorPtr(mesh, controlDict).ptr()); } } @@ -370,20 +370,15 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New lduMatrixConstructorTablePtr_ ); - if - ( - !lduMatrixConstructorTablePtr_ - || !lduMatrixConstructorTablePtr_->found(agglomeratorType) - ) + auto* ctorPtr = lduMatrixConstructorTable(agglomeratorType); + + if (!ctorPtr) { return New(mesh, controlDict); } else { - auto cstrIter = - lduMatrixConstructorTablePtr_->cfind(agglomeratorType); - - return store(cstrIter()(matrix, controlDict).ptr()); + return store(ctorPtr(matrix, controlDict).ptr()); } } } @@ -422,9 +417,9 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New geometryConstructorTablePtr_ ); - auto cstrIter = geometryConstructorTablePtr_->cfind(agglomeratorType); + auto* ctorPtr = geometryConstructorTable(agglomeratorType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInFunction << "Unknown GAMGAgglomeration type " @@ -436,7 +431,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New return store ( - cstrIter() + ctorPtr ( mesh, cellVolumes, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C index 7fb23ff19c..47681853c0 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -364,9 +365,9 @@ Foam::autoPtr Foam::GAMGProcAgglomeration::New { DebugInFunction << "Constructing GAMGProcAgglomeration" << endl; - auto cstrIter = GAMGAgglomerationConstructorTablePtr_->cfind(type); + auto* ctorPtr = GAMGAgglomerationConstructorTable(type); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInFunction << "Unknown GAMGProcAgglomeration type " @@ -376,7 +377,7 @@ Foam::autoPtr Foam::GAMGProcAgglomeration::New << exit(FatalError); } - return autoPtr(cstrIter()(agglom, controlDict)); + return autoPtr(ctorPtr(agglom, controlDict)); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/GAMGInterfaceField/GAMGInterfaceFieldNew.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/GAMGInterfaceField/GAMGInterfaceFieldNew.C index 7655843781..59ffcde856 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/GAMGInterfaceField/GAMGInterfaceFieldNew.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/GAMGInterfaceField/GAMGInterfaceFieldNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,9 +38,9 @@ Foam::autoPtr Foam::GAMGInterfaceField::New { const word coupleType(fineInterface.interfaceFieldType()); - auto cstrIter = lduInterfaceFieldConstructorTablePtr_->cfind(coupleType); + auto* ctorPtr = lduInterfaceFieldConstructorTable(coupleType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -50,7 +50,7 @@ Foam::autoPtr Foam::GAMGInterfaceField::New ) << exit(FatalError); } - return autoPtr(cstrIter()(GAMGCp, fineInterface)); + return autoPtr(ctorPtr(GAMGCp, fineInterface)); } @@ -63,9 +63,9 @@ Foam::autoPtr Foam::GAMGInterfaceField::New { const word coupleType(GAMGCp.type()); - auto cstrIter = lduInterfaceConstructorTablePtr_->cfind(coupleType); + auto* ctorPtr = lduInterfaceConstructorTable(coupleType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -75,7 +75,7 @@ Foam::autoPtr Foam::GAMGInterfaceField::New ) << exit(FatalError); } - return autoPtr(cstrIter()(GAMGCp, doTransform, rank)); + return autoPtr(ctorPtr(GAMGCp, doTransform, rank)); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/GAMGInterface/GAMGInterfaceNew.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/GAMGInterface/GAMGInterfaceNew.C index 5cae89551b..7d8b855eda 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/GAMGInterface/GAMGInterfaceNew.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaces/GAMGInterface/GAMGInterfaceNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,9 +46,9 @@ Foam::autoPtr Foam::GAMGInterface::New { const word coupleType(fineInterface.type()); - auto cstrIter = lduInterfaceConstructorTablePtr_->cfind(coupleType); + auto* ctorPtr = lduInterfaceConstructorTable(coupleType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -60,7 +60,7 @@ Foam::autoPtr Foam::GAMGInterface::New return autoPtr ( - cstrIter() + ctorPtr ( index, coarseInterfaces, @@ -82,9 +82,9 @@ Foam::autoPtr Foam::GAMGInterface::New Istream& is ) { - auto cstrIter = IstreamConstructorTablePtr_->cfind(coupleType); + auto* ctorPtr = IstreamConstructorTable(coupleType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -94,7 +94,7 @@ Foam::autoPtr Foam::GAMGInterface::New ) << exit(FatalError); } - return autoPtr(cstrIter()(index, coarseInterfaces, is)); + return autoPtr(ctorPtr(index, coarseInterfaces, is)); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatchNew.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatchNew.C index 02640b4179..21261cfe56 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatchNew.C +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatchNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,9 +38,9 @@ Foam::autoPtr Foam::facePointPatch::New { DebugInFunction << "Constructing facePointPatch" << endl; - auto cstrIter = polyPatchConstructorTablePtr_->cfind(patch.type()); + auto* ctorPtr = polyPatchConstructorTable(patch.type()); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -50,7 +50,7 @@ Foam::autoPtr Foam::facePointPatch::New ) << exit(FatalError); } - return autoPtr(cstrIter()(patch, bm)); + return autoPtr(ctorPtr(patch, bm)); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index d466d6f174..61be272817 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -276,21 +276,27 @@ Foam::polyPatch::~polyPatch() bool Foam::polyPatch::constraintType(const word& pt) { - return pointPatchField::pointPatchConstructorTablePtr_->found(pt); + return + ( + pointPatchField::pointPatchConstructorTablePtr_ + && pointPatchField::pointPatchConstructorTablePtr_->found(pt) + ); } Foam::wordList Foam::polyPatch::constraintTypes() { - wordList cTypes(dictionaryConstructorTablePtr_->size()); + const auto& cnstrTable = *dictionaryConstructorTablePtr_; + + wordList cTypes(cnstrTable.size()); label i = 0; - forAllConstIters(*dictionaryConstructorTablePtr_, cstrIter) + forAllConstIters(cnstrTable, iter) { - if (constraintType(cstrIter.key())) + if (constraintType(iter.key())) { - cTypes[i++] = cstrIter.key(); + cTypes[i++] = iter.key(); } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchNew.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchNew.C index 4d9b0a18b2..cf1bfde74b 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchNew.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatchNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::autoPtr Foam::polyPatch::New { DebugInFunction << "Constructing polyPatch" << endl; - auto cstrIter = wordConstructorTablePtr_->cfind(patchType); + auto* ctorPtr = wordConstructorTable(patchType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -57,7 +57,7 @@ Foam::autoPtr Foam::polyPatch::New return autoPtr ( - cstrIter() + ctorPtr ( name, size, @@ -98,16 +98,16 @@ Foam::autoPtr Foam::polyPatch::New { DebugInFunction << "Constructing polyPatch" << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchType); + auto* ctorPtr = dictionaryConstructorTable(patchType); - if (!cstrIter.found()) + if (!ctorPtr) { if (!disallowGenericPolyPatch) { - cstrIter = dictionaryConstructorTablePtr_->cfind("genericPatch"); + ctorPtr = dictionaryConstructorTable("genericPatch"); } - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -119,7 +119,7 @@ Foam::autoPtr Foam::polyPatch::New } } - return autoPtr(cstrIter()(name, dict, index, bm, patchType)); + return autoPtr(ctorPtr(name, dict, index, bm, patchType)); } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneNew.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneNew.C index 6e48eb2a7e..d3106b938e 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneNew.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::autoPtr Foam::cellZone::New const word zoneType(dict.get("type")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(zoneType); + auto* ctorPtr = dictionaryConstructorTable(zoneType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -56,7 +56,7 @@ Foam::autoPtr Foam::cellZone::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(name, dict, index, zm)); + return autoPtr(ctorPtr(name, dict, index, zm)); } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneNew.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneNew.C index 14ff989c76..05725ffe6a 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneNew.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::autoPtr Foam::faceZone::New const word zoneType(dict.get("type")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(zoneType); + auto* ctorPtr = dictionaryConstructorTable(zoneType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -56,7 +56,7 @@ Foam::autoPtr Foam::faceZone::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(name, dict, index, zm)); + return autoPtr(ctorPtr(name, dict, index, zm)); } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneNew.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneNew.C index f8cbf189fb..97c5da6bd3 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneNew.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::autoPtr Foam::pointZone::New const word zoneType(dict.get("type")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(zoneType); + auto* ctorPtr = dictionaryConstructorTable(zoneType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -56,7 +56,7 @@ Foam::autoPtr Foam::pointZone::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(name, dict, index, zm)); + return autoPtr(ctorPtr(name, dict, index, zm)); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C index ae20893b4a..3e8727606a 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C @@ -123,9 +123,9 @@ Foam::Function1::New } - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInFunction(dict) << "Unknown Function1 type " @@ -135,7 +135,7 @@ Foam::Function1::New << exit(FatalIOError); } - return cstrIter()(entryName, *coeffs); + return ctorPtr(entryName, *coeffs); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C index d93635c97a..1608a5682a 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESModel/LESModel.C @@ -163,9 +163,9 @@ Foam::LESModel::New Info<< "Selecting LES turbulence model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -178,7 +178,7 @@ Foam::LESModel::New return autoPtr ( - cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) + ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) ); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C index 554def6e99..168c538e66 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/LESdelta/LESdelta.C @@ -77,9 +77,9 @@ Foam::autoPtr Foam::LESdelta::New Info<< "Selecting LES " << lookupName << " type " << deltaType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType); + auto* ctorPtr = dictionaryConstructorTable(deltaType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -90,7 +90,7 @@ Foam::autoPtr Foam::LESdelta::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(name, turbulence, dict)); + return autoPtr(ctorPtr(name, turbulence, dict)); } @@ -107,16 +107,19 @@ Foam::autoPtr Foam::LESdelta::New Info<< "Selecting LES " << lookupName << " type " << deltaType << endl; - // Additional ones first - auto cstrIter = additionalConstructors.cfind(deltaType); - - // Regular ones - if (!cstrIter.found()) + // First any additional ones { - cstrIter = dictionaryConstructorTablePtr_->cfind(deltaType); + auto ctorIter = additionalConstructors.cfind(deltaType); + + if (ctorIter.found()) + { + return autoPtr(ctorIter.val()(name, turbulence, dict)); + } } - if (!cstrIter.found()) + auto* ctorPtr = dictionaryConstructorTable(deltaType); + + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -126,7 +129,7 @@ Foam::autoPtr Foam::LESdelta::New *dictionaryConstructorTablePtr_ ); - if (additionalConstructors.size()) + if (!additionalConstructors.empty()) { FatalIOError << " and " << additionalConstructors.sortedToc() << nl; @@ -136,7 +139,7 @@ Foam::autoPtr Foam::LESdelta::New << exit(FatalIOError); } - return autoPtr(cstrIter()(name, turbulence, dict)); + return autoPtr(ctorPtr(name, turbulence, dict)); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/LESfilter/LESfilter.C b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/LESfilter/LESfilter.C index 51811d6f2c..87b5232ea0 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/LESfilter/LESfilter.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/LESfilter/LESfilter.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,9 +49,9 @@ Foam::autoPtr Foam::LESfilter::New { const word filterType(dict.get(filterDictName)); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(filterType); + auto* ctorPtr = dictionaryConstructorTable(filterType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -62,7 +62,7 @@ Foam::autoPtr Foam::LESfilter::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(mesh, dict)); + return autoPtr(ctorPtr(mesh, dict)); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C index 90f9a15d6b..43b5745d88 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C @@ -145,9 +145,9 @@ Foam::RASModel::New Info<< "Selecting RAS turbulence model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -160,7 +160,7 @@ Foam::RASModel::New return autoPtr ( - cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) + ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) ); } diff --git a/src/TurbulenceModels/turbulenceModels/TurbulenceModel/TurbulenceModel.C b/src/TurbulenceModels/turbulenceModels/TurbulenceModel/TurbulenceModel.C index 7eaf600c9f..8400b981c8 100644 --- a/src/TurbulenceModels/turbulenceModels/TurbulenceModel/TurbulenceModel.C +++ b/src/TurbulenceModels/turbulenceModels/TurbulenceModel/TurbulenceModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -105,9 +105,9 @@ Foam::TurbulenceModel::New Info<< "Selecting turbulence model type " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -120,7 +120,7 @@ Foam::TurbulenceModel::New return autoPtr ( - cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) + ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) ); } diff --git a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C index 17ff06d370..6d6a218093 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/generalizedNewtonian/generalizedNewtonianViscosityModels/generalizedNewtonianViscosityModel/generalizedNewtonianViscosityModelNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018-2020 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,9 +40,9 @@ Foam::laminarModels::generalizedNewtonianViscosityModel::New Info<< "Selecting generalized Newtonian model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->find(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -53,7 +53,7 @@ Foam::laminarModels::generalizedNewtonianViscosityModel::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict)); + return autoPtr(ctorPtr(dict)); } diff --git a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C index 3b2b179b36..3e9eba5d0f 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -120,9 +120,9 @@ Foam::laminarModel::New Info<< "Selecting laminar stress model " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -135,7 +135,7 @@ Foam::laminarModel::New return autoPtr ( - cstrIter() + ctorPtr ( alpha, rho, diff --git a/src/combustionModels/FSD/reactionRateFlameAreaModels/reactionRateFlameArea/reactionRateFlameAreaNew.C b/src/combustionModels/FSD/reactionRateFlameAreaModels/reactionRateFlameArea/reactionRateFlameAreaNew.C index a9f404289b..c70d377a15 100644 --- a/src/combustionModels/FSD/reactionRateFlameAreaModels/reactionRateFlameArea/reactionRateFlameAreaNew.C +++ b/src/combustionModels/FSD/reactionRateFlameAreaModels/reactionRateFlameArea/reactionRateFlameAreaNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,9 +45,9 @@ Foam::autoPtr Foam::reactionRateFlameArea::New Info<< "Selecting reaction rate flame area correlation " << modelType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -61,7 +61,7 @@ Foam::autoPtr Foam::reactionRateFlameArea::New const word className = modelType.substr(0, modelType.find('<')); return autoPtr - (cstrIter()(className, dict, mesh, combModel)); + (ctorPtr(className, dict, mesh, combModel)); } diff --git a/src/combustionModels/combustionModel/combustionModelTemplates.C b/src/combustionModels/combustionModel/combustionModelTemplates.C index fcf4d4a059..7473db0270 100644 --- a/src/combustionModels/combustionModel/combustionModelTemplates.C +++ b/src/combustionModels/combustionModel/combustionModelTemplates.C @@ -186,7 +186,7 @@ Foam::autoPtr Foam::combustionModel::New return autoPtr ( - ctorIter()(combModelName, thermo, turb, combustionProperties) + ctorIter.val()(combModelName, thermo, turb, combustionProperties) ); } diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C index 0ae2fd5c1f..ea6a5d9a02 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C @@ -72,9 +72,8 @@ Foam::autoPtr Foam::dynamicFvMesh::New(const IOobject& io) << exit(FatalError); } - auto doInitCstrIter = doInitConstructorTablePtr_->cfind(modelType); - - if (doInitCstrIter.found()) + auto* doInitCtor = doInitConstructorTable(modelType); + if (doInitCtor) { DebugInfo << "Constructing dynamicFvMesh with explicit initialisation" @@ -82,7 +81,7 @@ Foam::autoPtr Foam::dynamicFvMesh::New(const IOobject& io) // Two-step constructor // 1. Construct mesh, do not initialise - autoPtr meshPtr(doInitCstrIter()(io, false)); + autoPtr meshPtr(doInitCtor(io, false)); // 2. Initialise parents and itself meshPtr().init(true); @@ -90,9 +89,9 @@ Foam::autoPtr Foam::dynamicFvMesh::New(const IOobject& io) return meshPtr; } - auto cstrIter = IOobjectConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = IOobjectConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -103,7 +102,7 @@ Foam::autoPtr Foam::dynamicFvMesh::New(const IOobject& io) ) << exit(FatalIOError); } - return autoPtr(cstrIter()(io)); + return autoPtr(ctorPtr(io)); } DebugInfo diff --git a/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C b/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C index 7bc324253a..92403dedf1 100644 --- a/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C +++ b/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,12 +64,12 @@ Foam::simplifiedMeshes::simplifiedDynamicFvMeshBase::New const word modelType(dict.get("dynamicFvMesh")); - auto cstrIter = timeConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = timeConstructorTable(modelType); - if (cstrIter.found()) + if (ctorPtr) { Info<< "Selecting simplified mesh model " << modelType << endl; - return autoPtr(cstrIter()(io.time(), io.name())); + return autoPtr(ctorPtr(io.time(), io.name())); } } diff --git a/src/dynamicMesh/meshCut/cellLooper/cellLooper.C b/src/dynamicMesh/meshCut/cellLooper/cellLooper.C index e96bd7d725..457ffc491f 100644 --- a/src/dynamicMesh/meshCut/cellLooper/cellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/cellLooper.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,9 +48,9 @@ Foam::autoPtr Foam::cellLooper::New const polyMesh& mesh ) { - auto cstrIter = wordConstructorTablePtr_->cfind(type); + auto* ctorPtr = wordConstructorTable(type); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInLookup ( @@ -60,7 +60,7 @@ Foam::autoPtr Foam::cellLooper::New ) << exit(FatalError); } - return autoPtr(cstrIter()(mesh)); + return autoPtr(ctorPtr(mesh)); } diff --git a/src/dynamicMesh/motionSolvers/displacement/displacement/displacementMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/displacement/displacementMotionSolver.C index 3217fff6a1..39d2654685 100644 --- a/src/dynamicMesh/motionSolvers/displacement/displacement/displacementMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/displacement/displacementMotionSolver.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -108,9 +108,9 @@ Foam::displacementMotionSolver::New << exit(FatalError); } - auto cstrIter = displacementConstructorTablePtr_->cfind(solverTypeName); + auto* ctorPtr = displacementConstructorTable(solverTypeName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -123,7 +123,7 @@ Foam::displacementMotionSolver::New return autoPtr ( - cstrIter() + ctorPtr ( mesh, solverDict, diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunctionNew.C b/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunctionNew.C index 7fb8dae315..41f59990b3 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunctionNew.C +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/solidBodyMotionFunction/solidBodyMotionFunctionNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,9 +40,9 @@ Foam::autoPtr Foam::solidBodyMotionFunction::New Info<< "Selecting solid-body motion function " << motionType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(motionType); + auto* ctorPtr = dictionaryConstructorTable(motionType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -53,7 +53,7 @@ Foam::autoPtr Foam::solidBodyMotionFunction::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(dict, runTime)); + return autoPtr(ctorPtr(dict, runTime)); } diff --git a/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C b/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C index d8952dd77e..8ec0424182 100644 --- a/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C +++ b/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.C @@ -130,9 +130,9 @@ Foam::autoPtr Foam::motionSolver::New << exit(FatalError); } - auto cstrIter = dictionaryConstructorTablePtr_->cfind(solverName); + auto* ctorPtr = dictionaryConstructorTable(solverName); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -143,7 +143,7 @@ Foam::autoPtr Foam::motionSolver::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(mesh, solverDict)); + return autoPtr(ctorPtr(mesh, solverDict)); } diff --git a/src/dynamicMesh/polyTopoChange/polyMeshModifier/polyMeshModifierNew.C b/src/dynamicMesh/polyTopoChange/polyMeshModifier/polyMeshModifierNew.C index c0407cc7b6..4cfafc59be 100644 --- a/src/dynamicMesh/polyTopoChange/polyMeshModifier/polyMeshModifierNew.C +++ b/src/dynamicMesh/polyTopoChange/polyMeshModifier/polyMeshModifierNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,9 +43,9 @@ Foam::autoPtr Foam::polyMeshModifier::New const word modelType(dict.get("type")); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -56,7 +56,7 @@ Foam::autoPtr Foam::polyMeshModifier::New ) << exit(FatalIOError); } - return autoPtr(cstrIter()(name, dict, index, mme)); + return autoPtr(ctorPtr(name, dict, index, mme)); } diff --git a/src/engine/engineMesh/engineMesh/engineMeshNew.C b/src/engine/engineMesh/engineMesh/engineMeshNew.C index aa7cbedf12..9cb427c8da 100644 --- a/src/engine/engineMesh/engineMesh/engineMeshNew.C +++ b/src/engine/engineMesh/engineMesh/engineMeshNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,9 +50,9 @@ Foam::autoPtr Foam::engineMesh::New(const IOobject& io) Info<< "Selecting engineMesh " << modelType << endl; - auto cstrIter = IOobjectConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = IOobjectConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -63,7 +63,7 @@ Foam::autoPtr Foam::engineMesh::New(const IOobject& io) ) << exit(FatalIOError); } - return autoPtr(cstrIter()(io)); + return autoPtr(ctorPtr(io)); } diff --git a/src/engine/engineTime/engineTime/engineTimeNew.C b/src/engine/engineTime/engineTime/engineTimeNew.C index 66a3355383..2d4cba2a65 100644 --- a/src/engine/engineTime/engineTime/engineTimeNew.C +++ b/src/engine/engineTime/engineTime/engineTimeNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,9 +52,9 @@ Foam::autoPtr Foam::engineTime::New Info<< "Selecting engine type " << engineType << endl; - auto cstrIter = dictionaryConstructorTablePtr_->cfind(engineType); + auto* ctorPtr = dictionaryConstructorTable(engineType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalIOErrorInLookup ( @@ -67,7 +67,7 @@ Foam::autoPtr Foam::engineTime::New return autoPtr ( - cstrIter() + ctorPtr ( name, rootPath, diff --git a/src/faOptions/faOption/faOption.C b/src/faOptions/faOption/faOption.C index b043867f81..89632a88c0 100644 --- a/src/faOptions/faOption/faOption.C +++ b/src/faOptions/faOption/faOption.C @@ -98,9 +98,9 @@ Foam::autoPtr Foam::fa::option::New dictionaryConstructorTablePtr_ ); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); + auto* ctorPtr = dictionaryConstructorTable(modelType); - if (!cstrIter.found()) + if (!ctorPtr) { FatalErrorInFunction << "Unknown faOption model type " @@ -110,7 +110,7 @@ Foam::autoPtr Foam::fa::option::New << exit(FatalError); } - return autoPtr