ENH: no implicit loading of controlDict libs for foamListRegions (#1713)

ENH: eliminate duplicate input region types
This commit is contained in:
Mark Olesen
2020-05-23 15:33:36 +02:00
parent a5a504693a
commit 02517e971a

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -68,8 +68,14 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
// As per "createTime.H", but quieter. // Silent version of "createTime.H", without libraries
Time runTime(Time::controlDictName, args); Time runTime
(
Time::controlDictName,
args,
false, // no enableFunctionObjects
false // no enableLibs
);
regionProperties rp(runTime); regionProperties rp(runTime);
@ -78,24 +84,32 @@ int main(int argc, char *argv[])
if (args.size() > 1) if (args.size() > 1)
{ {
regionTypes.setSize(args.size()-1); regionTypes.resize(args.size()-1);
// No duplicates
wordHashSet uniq;
label nTypes = 0; label nTypes = 0;
for (label argi = 1; argi < args.size(); ++argi) for (label argi = 1; argi < args.size(); ++argi)
{ {
regionTypes[nTypes] = args[argi]; regionTypes[nTypes] = args[argi];
if (rp.found(regionTypes[nTypes])) const word& regType = regionTypes[nTypes];
if (uniq.insert(regType))
{
if (rp.found(regType))
{ {
++nTypes; ++nTypes;
} }
else else
{ {
std::cerr<< "No region-type: " << regionTypes[nTypes] << nl; InfoErr<< "No region-type: " << regType << nl;
}
} }
} }
regionTypes.setSize(nTypes); regionTypes.resize(nTypes);
} }
else else
{ {