From 5a121119e61dd504d561a145835367c692384dc6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 5 Nov 2021 21:02:21 +0100 Subject: [PATCH] ENH: add -verbose support into argList - similar to -dry-run handling, can be interrogated from argList, which makes it simpler to add into utilities. - support multiple uses of -dry-run and -verbose to increase the level. For example, could have someApplication -verbose -verbose and inside of the application: if (args.verbose() > 2) ... BUG: error with empty distributed roots specification (fixes #2196) - previously used the size of distributed roots to transmit if the case was running in distributed mode, but this behaves rather poorly with bad input. Specifically, the following questionable setup: distributed true; roots ( /*none*/ ); Now transmit the ParRunControl distributed() value instead, and also emit a gentle warning for the user: WARNING: running distributed but did not specify roots! --- applications/test/argList/Test-argList.C | 7 + .../Test-checkDecomposePar.C | 6 +- .../test/labelRanges/Test-labelRanges.C | 6 +- .../test/quaternion/Test-quaternion.C | 11 +- applications/test/tokenize/Test-tokenize.C | 10 +- .../foamHasLibrary/foamHasLibrary.C | 6 +- .../foamListTimes/foamListTimes.C | 7 +- .../foamRestoreFields/foamRestoreFields.C | 5 +- .../decomposePar/decomposePar.C | 11 +- .../lumpedPointZones/lumpedPointZones.C | 9 +- .../setExprFields/setExprFields.C | 12 +- .../surface/surfaceCheck/surfaceCheck.C | 3 +- src/OpenFOAM/global/argList/argList.C | 144 ++++++++++++++---- src/OpenFOAM/global/argList/argList.H | 30 +++- src/OpenFOAM/global/argList/argListI.H | 22 ++- src/OpenFOAM/global/argList/parRun.H | 95 +++++++----- 16 files changed, 249 insertions(+), 135 deletions(-) diff --git a/applications/test/argList/Test-argList.C b/applications/test/argList/Test-argList.C index bab0297500..44edb17aad 100644 --- a/applications/test/argList/Test-argList.C +++ b/applications/test/argList/Test-argList.C @@ -121,6 +121,9 @@ int main(int argc, char *argv[]) argList::addArgument("label"); argList::noMandatoryArgs(); + argList::addDryRunOption("Just for testing"); + argList::addVerboseOption("Increase verbosity"); + #include "setRootCase.H" Pout<< "command-line (" @@ -133,6 +136,10 @@ int main(int argc, char *argv[]) << "globalPath: " << args.globalPath() << nl << nl; + Pout<< "dry-run: " << args.dryRun() + << " verbose: " << args.verbose() << nl; + + if (args.found("relative")) { Pout<< "input path: " << args["relative"] << nl diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C index 3445b3b309..3987a7d21e 100644 --- a/applications/test/checkDecomposePar/Test-checkDecomposePar.C +++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C @@ -57,9 +57,8 @@ int main(int argc, char *argv[]) #include "addAllRegionOptions.H" - argList::addBoolOption + argList::addVerboseOption ( - "verbose", "more information about decomposition" ); @@ -71,7 +70,6 @@ int main(int argc, char *argv[]) #include "setRootCase.H" const auto decompFile = args.get(1); - const bool verbose = args.found("verbose"); // Set time from database #include "createTime.H" @@ -146,7 +144,7 @@ int main(int argc, char *argv[]) nDomains ); - if (verbose) + if (args.verbose()) { info.printDetails(Info); Info<< nl; diff --git a/applications/test/labelRanges/Test-labelRanges.C b/applications/test/labelRanges/Test-labelRanges.C index 48acf4b532..f19fd00c18 100644 --- a/applications/test/labelRanges/Test-labelRanges.C +++ b/applications/test/labelRanges/Test-labelRanges.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::noFunctionObjects(); argList::addArgument("start size .. startN sizeN"); - argList::addOption("verbose"); + argList::addVerbose("enable labelRange::debug"); argList::addNote ( "The default is to add ranges, use 'add' and 'del' to toggle\n\n" @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) argList args(argc, argv, false, true); - if (args.found("verbose")) + if (args.verbose()) { labelRange::debug = 1; } diff --git a/applications/test/quaternion/Test-quaternion.C b/applications/test/quaternion/Test-quaternion.C index c667892a10..51b1a80946 100644 --- a/applications/test/quaternion/Test-quaternion.C +++ b/applications/test/quaternion/Test-quaternion.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. @@ -124,16 +124,13 @@ int main(int argc, char *argv[]) "(vector angle)", "Rotate about the by degrees - eg, '((1 0 0) 45)'" ); - argList::addBoolOption + argList::addVerboseOption ( - "verbose", - "Additional verbosity" + "Report euler angles" ); argList args(argc, argv); - const bool verbose = args.found("verbose"); - vector rotVector; @@ -327,7 +324,7 @@ int main(int argc, char *argv[]) tensor rotQ(quaternion(order, angles).R()); tensor rotE(euler::rotation(order, angles, false)); - if (verbose) + if (args.verbose()) { Info<< "euler " << orderName << angles << nl; printRotation(rotE); diff --git a/applications/test/tokenize/Test-tokenize.C b/applications/test/tokenize/Test-tokenize.C index d3c6eb1637..38f07d6822 100644 --- a/applications/test/tokenize/Test-tokenize.C +++ b/applications/test/tokenize/Test-tokenize.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,18 +50,16 @@ int main(int argc, char *argv[]) argList::addArgument("string .. stringN"); argList::addOption("file", "name"); argList::addOption("repeat", "count"); - argList::addBoolOption("verbose", "report for each repeat"); + argList::addVerboseOption("report each repeat"); argList args(argc, argv, false, true); const label repeat = args.getOrDefault