mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: centralized handling of -allRegions, -regions, -region (#2072)
Step 1.
include "addAllRegionOptions.H"
Adds the -allRegions, -regions and -region options to argList.
Step 2.
include "getAllRegionOptions.H"
Processes the options with -allRegions selecting everything
from the regionProperties.
OR use -regions to specify multiple regions (from
regionProperties), and can also contain regular expressions
OR use the -region option
Specifying a single -regions NAME (not a regular expresssion)
is the same as -region NAME and doesn't use regionProperties
Creates a `wordList regionNames`
Step 3.
Do something with the region names.
Either directly, or quite commonly with the following
include "createNamedMeshes.H"
Creates a `PtrList<fvMesh> meshes`
STYLE: add description to some central include files
This commit is contained in:
@ -55,12 +55,8 @@ int main(int argc, char *argv[])
|
||||
argList::noParallel();
|
||||
argList::noBanner();
|
||||
|
||||
#include "addRegionOption.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
"allRegions",
|
||||
"operate on all regions in regionProperties"
|
||||
);
|
||||
#include "addAllRegionOptions.H"
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"verbose",
|
||||
@ -76,11 +72,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
const auto decompFile = args.get<fileName>(1);
|
||||
const bool region = args.found("region");
|
||||
const bool allRegions = args.found("allRegions");
|
||||
const bool verbose = args.found("verbose");
|
||||
|
||||
// Set time from database
|
||||
#include "createTime.H"
|
||||
|
||||
// Allow override of time
|
||||
instantList times = timeSelector::selectIfPresent(runTime, args);
|
||||
|
||||
@ -88,31 +84,18 @@ int main(int argc, char *argv[])
|
||||
const fileName decompDictFile =
|
||||
args.getOrDefault<fileName>("decomposeParDict", "");
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
if (allRegions)
|
||||
// Get region names
|
||||
#include "getAllRegionOptions.H"
|
||||
|
||||
wordList regionDirs(regionNames);
|
||||
if (regionDirs.size() == 1 && regionDirs[0] == polyMesh::defaultRegion)
|
||||
{
|
||||
Info<< "Decomposing all regions in regionProperties" << nl << endl;
|
||||
regionProperties rp(runTime);
|
||||
forAllConstIters(rp, iter)
|
||||
{
|
||||
const wordList& regions = iter();
|
||||
forAll(regions, i)
|
||||
{
|
||||
regionNames.appendUniq(regions[i]);
|
||||
}
|
||||
}
|
||||
regionDirs = regionNames;
|
||||
regionDirs[0].clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames.resize(1, fvMesh::defaultRegion);
|
||||
regionDirs.resize(1, word::null);
|
||||
|
||||
if (args.readIfPresent("region", regionNames.first()))
|
||||
{
|
||||
regionDirs.first() = regionNames.first();
|
||||
}
|
||||
Info<< "Decomposing regions: "
|
||||
<< flatOutput(regionNames) << nl << endl;
|
||||
}
|
||||
|
||||
labelList cellToProc;
|
||||
|
||||
Reference in New Issue
Block a user