diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index fc99cc81e5..5141980c3d 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -384,7 +384,7 @@ bool doCommand try { topoSetSource::setAction action = - topoSetSource::toAction(actionName); + topoSetSource::actionNames[actionName]; IOobject::readOption r; @@ -713,26 +713,11 @@ commandStatus parseType commandStatus parseAction(const word& actionName) { - commandStatus stat = INVALID; - - if (actionName.size()) - { - try - { - (void)topoSetSource::toAction(actionName); - - stat = VALIDSETCMD; - } - catch (Foam::IOerror& fIOErr) - { - stat = INVALID; - } - catch (Foam::error& fErr) - { - stat = INVALID; - } - } - return stat; + return + ( + actionName.size() && topoSetSource::actionNames.found(actionName) + ? VALIDSETCMD : INVALID + ); } diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index 04c54e2547..a0ad8a715f 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) const word dictName("topoSetDict"); #include "setSystemMeshDictionaryIO.H" - Info<< "Reading " << dictName << "\n" << endl; + Info<< "Reading " << dictName << nl << endl; IOdictionary topoSetDict(dictIO); @@ -238,19 +238,13 @@ int main(int argc, char *argv[]) meshReadUpdate(mesh); // Execute all actions - forAll(actions, i) + for (const dictionary& dict : actions) { - const dictionary& dict = actions[i]; + const word setName(dict.get("name")); + const word setType(dict.get("type")); - const word setName(dict.lookup("name")); - const word actionName(dict.lookup("action")); - const word setType(dict.lookup("type")); - - - topoSetSource::setAction action = topoSetSource::toAction - ( - actionName - ); + const topoSetSource::setAction action = + topoSetSource::actionNames.lookup("action", dict); autoPtr currentSet; if @@ -283,20 +277,20 @@ int main(int argc, char *argv[]) } - - // Handle special actions (clear, invert) locally, rest through - // sources. + // Handle special actions (clear, invert) locally, + // the other actions through sources. switch (action) { case topoSetSource::NEW: case topoSetSource::ADD: case topoSetSource::DELETE: { - Info<< " Applying source " << word(dict.lookup("source")) - << endl; + const word sourceName(dict.get("source")); + + Info<< " Applying source " << sourceName << endl; autoPtr source = topoSetSource::New ( - dict.lookup("source"), + sourceName, mesh, dict.subDict("sourceInfo") ); @@ -310,11 +304,12 @@ int main(int argc, char *argv[]) case topoSetSource::SUBSET: { - Info<< " Applying source " << word(dict.lookup("source")) - << endl; + const word sourceName(dict.get("source")); + + Info<< " Applying source " << sourceName << endl; autoPtr source = topoSetSource::New ( - dict.lookup("source"), + sourceName, mesh, dict.subDict("sourceInfo") ); @@ -359,7 +354,6 @@ int main(int argc, char *argv[]) removeSet(mesh, setType, setName); break; - default: WarningInFunction << "Unhandled action " << action << endl; @@ -368,16 +362,16 @@ int main(int argc, char *argv[]) if (currentSet.valid()) { - Info<< " " << currentSet().type() << " " - << currentSet().name() - << " now size " + Info<< " " + << currentSet().type() << " " + << currentSet().name() << " now size " << returnReduce(currentSet().size(), sumOp