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!
This commit is contained in:
Mark Olesen
2021-11-05 21:02:21 +01:00
parent c45c649d15
commit 5a121119e6
16 changed files with 249 additions and 135 deletions

View File

@ -78,9 +78,8 @@ int main(int argc, char *argv[])
"detail",
"Additional detail"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
@ -94,7 +93,6 @@ int main(int argc, char *argv[])
const bool testOr = args.found("or");
const bool detail = args.found("detail");
const bool verbose = args.found("verbose");
label ngood = 0;
label nbad = 0;
@ -127,7 +125,7 @@ int main(int argc, char *argv[])
{
++ngood;
if (verbose)
if (args.verbose())
{
const word addr(Foam::name(ptr));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,9 +101,8 @@ int main(int argc, char *argv[])
"rm",
"Remove selected time directories"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Report progress of -rm option"
);
profiling::disable(); // Disable profiling (and its output)
@ -111,7 +110,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool removeFiles(args.found("rm"));
bool verbose(args.found("verbose"));
bool verbose(args.verbose());
// Get times list from the master processor and subset based on

View File

@ -232,9 +232,8 @@ int main(int argc, char *argv[])
(
"Report action without moving/renaming"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
@ -247,7 +246,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
dryrun = args.dryRun();
verbose = args.found("verbose");
verbose = args.verbose();
// Construct time

View File

@ -330,9 +330,8 @@ int main(int argc, char *argv[])
"Test without writing the decomposition. "
"Changes -cellDist to only write VTK output."
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
argList::addOption
@ -409,9 +408,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool dryrun = args.dryRun();
const bool writeCellDist = args.found("cellDist");
const bool verbose = args.found("verbose");
// Most of these are ignored for dry-run (not triggered anywhere)
const bool copyZero = args.found("copyZero");
@ -432,7 +429,7 @@ int main(int argc, char *argv[])
// Allow override of time (unless dry-run)
instantList times;
if (dryrun)
if (args.dryRun())
{
Info<< "\ndry-run: ignoring -copy*, -fields, -force, time selection"
<< nl;
@ -477,7 +474,7 @@ int main(int argc, char *argv[])
regionName == polyMesh::defaultRegion ? word::null : regionName
);
if (dryrun)
if (args.dryRun())
{
Info<< "dry-run: decomposing mesh " << regionName << nl << nl
<< "Create mesh..." << flush;
@ -498,7 +495,7 @@ int main(int argc, char *argv[])
args.getOrDefault<word>("method", word::null)
);
decompTest.execute(writeCellDist, verbose);
decompTest.execute(writeCellDist, args.verbose());
continue;
}

View File

@ -72,24 +72,19 @@ int main(int argc, char *argv[])
"Suppress calculation/display of point interpolators"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
const bool noInterpolate = args.found("no-interpolate");
// const bool verbose = args.found("verbose");
args.readIfPresent("visual-length", lumpedPointState::visLength);
#include "createTime.H"
if (args.dryRun())
{
// Create without a mesh

View File

@ -553,9 +553,8 @@ int main(int argc, char *argv[])
(
"Evaluate but do not write"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity",
true // Advanced option
);
@ -662,9 +661,6 @@ int main(int argc, char *argv[])
#include "createTime.H"
const bool dryrun = args.dryRun();
const bool verbose = args.found("verbose");
const word dictName("setExprFieldsDict");
instantList times = timeSelector::select0(runTime, args);
@ -797,7 +793,7 @@ int main(int argc, char *argv[])
setExprFieldsControl ctrl;
ctrl.dryRun = dryrun;
ctrl.dryRun = args.dryRun();
ctrl.debugParsing = args.found("debug-parser");
ctrl.cacheVariables = !args.found("no-variable-caching");
@ -869,7 +865,7 @@ int main(int argc, char *argv[])
setExprFieldsControl ctrl;
ctrl.dryRun = dryrun;
ctrl.dryRun = args.dryRun();
ctrl.debugParsing = args.found("debug-parser");
ctrl.cacheVariables = !args.found("no-variable-caching");
@ -934,7 +930,7 @@ int main(int argc, char *argv[])
ctrl.useDimensions = bool(dimPtr);
}
if (verbose && !timei)
if (args.verbose() && !timei)
{
// Report once
Info<< "Processing" << dict << nl;

View File

@ -308,9 +308,8 @@ int main(int argc, char *argv[])
"Split surface along non-manifold edges "
"(default split is fully disconnected)"
);
argList::addBoolOption
argList::addVerboseOption
(
"verbose",
"Additional verbosity"
);
argList::addBoolOption