decomposePar, reconstructPar: Rationalized the handling of the allRegions option
This commit is contained in:
@ -218,11 +218,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
argList::noParallel();
|
||||
#include "addRegionOption.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
"allRegions",
|
||||
"operate on all regions in regionProperties"
|
||||
);
|
||||
#include "addAllRegionsOption.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
"cellDist",
|
||||
@ -273,7 +269,6 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
|
||||
bool region = args.optionFound("region");
|
||||
bool allRegions = args.optionFound("allRegions");
|
||||
bool writeCellDist = args.optionFound("cellDist");
|
||||
bool copyZero = args.optionFound("copyZero");
|
||||
bool copyUniform = args.optionFound("copyUniform");
|
||||
@ -310,40 +305,7 @@ int main(int argc, char *argv[])
|
||||
// Allow override of time
|
||||
instantList times = timeSelector::selectIfPresent(runTime, args);
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
if (allRegions)
|
||||
{
|
||||
Info<< "Decomposing all regions in regionProperties" << nl << endl;
|
||||
regionProperties rp(runTime);
|
||||
forAllConstIter(HashTable<wordList>, rp, iter)
|
||||
{
|
||||
const wordList& regions = iter();
|
||||
forAll(regions, i)
|
||||
{
|
||||
if (findIndex(regionNames, regions[i]) == -1)
|
||||
{
|
||||
regionNames.append(regions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames = wordList(1, fvMesh::defaultRegion);
|
||||
regionDirs = wordList(1, word::null);
|
||||
}
|
||||
}
|
||||
|
||||
const wordList regionNames(selectRegionNames(args, runTime));
|
||||
|
||||
{
|
||||
// Determine the existing processor count directly
|
||||
@ -416,7 +378,7 @@ int main(int argc, char *argv[])
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
const word& regionDir = regionDirs[regioni];
|
||||
const word& regionDir = Foam::regionDir(regionName);
|
||||
|
||||
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
|
||||
|
||||
|
||||
@ -49,12 +49,14 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool haveAllTimes
|
||||
(
|
||||
namespace Foam
|
||||
{
|
||||
bool haveAllTimes
|
||||
(
|
||||
const HashSet<word>& masterTimeDirSet,
|
||||
const instantList& timeDirs
|
||||
)
|
||||
{
|
||||
)
|
||||
{
|
||||
// Loop over all times
|
||||
forAll(timeDirs, timei)
|
||||
{
|
||||
@ -64,6 +66,7 @@ bool haveAllTimes
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,11 +82,7 @@ int main(int argc, char *argv[])
|
||||
timeSelector::addOptions(true, true);
|
||||
argList::noParallel();
|
||||
#include "addRegionOption.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
"allRegions",
|
||||
"operate on all regions in regionProperties"
|
||||
);
|
||||
#include "addAllRegionsOption.H"
|
||||
argList::addOption
|
||||
(
|
||||
"fields",
|
||||
@ -169,48 +168,11 @@ int main(int argc, char *argv[])
|
||||
args.optionLookup("lagrangianFields")() >> selectedLagrangianFields;
|
||||
}
|
||||
|
||||
|
||||
const bool newTimes = args.optionFound("newTimes");
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
|
||||
|
||||
wordList regionNames;
|
||||
wordList regionDirs;
|
||||
if (allRegions)
|
||||
{
|
||||
Info<< "Reconstructing for all regions in regionProperties" << nl
|
||||
<< endl;
|
||||
regionProperties rp(runTime);
|
||||
forAllConstIter(HashTable<wordList>, rp, iter)
|
||||
{
|
||||
const wordList& regions = iter();
|
||||
forAll(regions, i)
|
||||
{
|
||||
if (findIndex(regionNames, regions[i]) == -1)
|
||||
{
|
||||
regionNames.append(regions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
regionDirs = regionNames;
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames = wordList(1, fvMesh::defaultRegion);
|
||||
regionDirs = wordList(1, word::null);
|
||||
}
|
||||
}
|
||||
const wordList regionNames(selectRegionNames(args, runTime));
|
||||
|
||||
// Determine the processor count
|
||||
label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]);
|
||||
const label nProcs =
|
||||
fileHandler().nProcs(args.path(), regionDir(regionNames[0]));
|
||||
|
||||
if (!nProcs)
|
||||
{
|
||||
@ -253,26 +215,37 @@ int main(int argc, char *argv[])
|
||||
// - can be illogical
|
||||
// + any point motion handled through mesh.readUpdate
|
||||
|
||||
|
||||
if (timeDirs.empty())
|
||||
{
|
||||
WarningInFunction << "No times selected";
|
||||
WarningInFunction << "No times selected" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
// Get current times if -newTimes
|
||||
const bool newTimes = args.optionFound("newTimes");
|
||||
instantList masterTimeDirs;
|
||||
if (newTimes)
|
||||
{
|
||||
masterTimeDirs = runTime.times();
|
||||
}
|
||||
|
||||
HashSet<word> masterTimeDirSet(2*masterTimeDirs.size());
|
||||
forAll(masterTimeDirs, i)
|
||||
{
|
||||
masterTimeDirSet.insert(masterTimeDirs[i].name());
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
newTimes
|
||||
&& regionNames.size() == 1
|
||||
&& regionNames[0] == fvMesh::defaultRegion
|
||||
&& haveAllTimes(masterTimeDirSet, timeDirs)
|
||||
)
|
||||
{
|
||||
Info<< "All times already reconstructed.\n\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set all times on processor meshes equal to reconstructed mesh
|
||||
forAll(databases, proci)
|
||||
@ -280,30 +253,14 @@ int main(int argc, char *argv[])
|
||||
databases[proci].setTime(runTime);
|
||||
}
|
||||
|
||||
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
const word& regionDir = regionDirs[regioni];
|
||||
const word& regionDir = Foam::regionDir(regionName);
|
||||
|
||||
Info<< "\n\nReconstructing fields for mesh " << regionName << nl
|
||||
<< endl;
|
||||
|
||||
if
|
||||
(
|
||||
newTimes
|
||||
&& regionNames.size() == 1
|
||||
&& regionDirs[0].empty()
|
||||
&& haveAllTimes(masterTimeDirSet, timeDirs)
|
||||
)
|
||||
{
|
||||
Info<< "Skipping region " << regionName
|
||||
<< " since already have all times"
|
||||
<< endl << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
fvMesh mesh
|
||||
(
|
||||
IOobject
|
||||
@ -311,7 +268,7 @@ int main(int argc, char *argv[])
|
||||
regionName,
|
||||
runTime.timeName(),
|
||||
runTime,
|
||||
Foam::IOobject::MUST_READ
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
5
src/OpenFOAM/include/addAllRegionsOption.H
Normal file
5
src/OpenFOAM/include/addAllRegionsOption.H
Normal file
@ -0,0 +1,5 @@
|
||||
Foam::argList::addBoolOption
|
||||
(
|
||||
"allRegions",
|
||||
"operate on all regions in regionProperties"
|
||||
);
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,8 @@ License
|
||||
|
||||
#include "regionProperties.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "argList.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -53,4 +55,53 @@ Foam::regionProperties::~regionProperties()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::regionDir(const word& regionName)
|
||||
{
|
||||
return
|
||||
regionName == polyMesh::defaultRegion
|
||||
? word::null
|
||||
: regionName;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::selectRegionNames(const argList& args, const Time& runTime)
|
||||
{
|
||||
const bool allRegions = args.optionFound("allRegions");
|
||||
|
||||
wordList regionNames;
|
||||
|
||||
if (allRegions)
|
||||
{
|
||||
const regionProperties rp(runTime);
|
||||
forAllConstIter(HashTable<wordList>, rp, iter)
|
||||
{
|
||||
const wordList& regions = iter();
|
||||
forAll(regions, i)
|
||||
{
|
||||
if (findIndex(regionNames, regions[i]) == -1)
|
||||
{
|
||||
regionNames.append(regions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
word regionName;
|
||||
if (args.optionReadIfPresent("region", regionName))
|
||||
{
|
||||
regionNames = wordList(1, regionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
regionNames = wordList(1, polyMesh::defaultRegion);
|
||||
}
|
||||
}
|
||||
|
||||
return regionNames;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -76,6 +76,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
const word& regionDir(const word& regionName);
|
||||
|
||||
wordList selectRegionNames(const argList& args, const Time& runTime);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
Reference in New Issue
Block a user