mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fileOperation: fix fileOperation::nProcs to handle multiple candidates
This commit is contained in:
committed by
Andrew Heather
parent
577f584446
commit
d6ba54bfec
@ -1690,15 +1690,26 @@ void Foam::argList::parse
|
||||
)
|
||||
{
|
||||
label nProcDirs = 0;
|
||||
while
|
||||
(
|
||||
isDir
|
||||
{
|
||||
const bool oldParRun(UPstream::parRun(false));
|
||||
// Don't cache processor directories (probably not
|
||||
// needed since master-only
|
||||
const int oldCacheLevel(fileOperation::cacheLevel(0));
|
||||
// Accept any processorsXXX
|
||||
const int oldFilter(fileOperation::nProcsFilter(0));
|
||||
|
||||
nProcDirs = fileHandler().nProcs
|
||||
(
|
||||
rootPath_/globalCase_
|
||||
/ ("processor" + Foam::name(++nProcDirs))
|
||||
)
|
||||
)
|
||||
{}
|
||||
rootPath_/globalCase_,
|
||||
"",
|
||||
dictNProcs // expected nProcs
|
||||
);
|
||||
|
||||
fileOperation::nProcsFilter(oldFilter);
|
||||
fileOperation::cacheLevel(oldCacheLevel);
|
||||
UPstream::parRun(oldParRun);
|
||||
}
|
||||
|
||||
|
||||
if (nProcDirs != Pstream::nProcs())
|
||||
{
|
||||
|
||||
@ -1290,7 +1290,8 @@ Foam::fileNameList Foam::fileOperation::readObjects
|
||||
Foam::label Foam::fileOperation::nProcs
|
||||
(
|
||||
const fileName& dir,
|
||||
const fileName& local
|
||||
const fileName& local,
|
||||
const label wanted // expected nProcs. 0 if not supplied
|
||||
) const
|
||||
{
|
||||
label nProcs = 0;
|
||||
@ -1298,6 +1299,25 @@ Foam::label Foam::fileOperation::nProcs
|
||||
{
|
||||
fileNameList dirNames(Foam::readDir(dir, fileName::Type::DIRECTORY));
|
||||
|
||||
// E.g. (maybe left over)
|
||||
// processor0
|
||||
// processor1
|
||||
// processors5
|
||||
// processor90 // gap!
|
||||
// processors10
|
||||
//
|
||||
//- if wanted is 2 then processor0,1 is enough
|
||||
//- if wanted is not set then return highest valid range
|
||||
// (processors10 in above case)
|
||||
//- if wanted cannot be matched (e.g. 37) return 0
|
||||
|
||||
// For marking off contiguous ranges
|
||||
bitSet foundDirs;
|
||||
if (wanted > 0)
|
||||
{
|
||||
foundDirs.resize(wanted);
|
||||
}
|
||||
|
||||
// Detect any processorsDDD or processorDDD
|
||||
label maxProc = -1;
|
||||
for (const fileName& dirN : dirNames)
|
||||
@ -1310,15 +1330,38 @@ Foam::label Foam::fileOperation::nProcs
|
||||
splitProcessorPath(dirN, rp, rd, rl, group, rNum);
|
||||
|
||||
maxProc = max(maxProc, readProci);
|
||||
if (rNum != -1)
|
||||
|
||||
if (rNum > 0) // processorsDDD where DDD>0
|
||||
{
|
||||
// Direct detection of processorsDDD
|
||||
maxProc = rNum-1;
|
||||
break;
|
||||
// Use processors number
|
||||
maxProc = max(maxProc, rNum-1);
|
||||
// Mark in cache. TBD separate handling for groups?
|
||||
foundDirs.set(labelRange(0, rNum));
|
||||
|
||||
if (wanted == rNum)
|
||||
{
|
||||
// Exact match of processorsDDD. Direct exit.
|
||||
maxProc = rNum-1;
|
||||
foundDirs.resize(rNum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (readProci >= 0)
|
||||
{
|
||||
// Mark in cache
|
||||
foundDirs.set(readProci);
|
||||
}
|
||||
}
|
||||
nProcs = maxProc+1;
|
||||
|
||||
// Override with any gaps in processorDDD numbering (can never happen
|
||||
// with collated)
|
||||
const label gapIndex = foundDirs.find_first_not();
|
||||
if (gapIndex > 0)
|
||||
{
|
||||
nProcs = gapIndex-1;
|
||||
}
|
||||
|
||||
if (nProcs == 0 && Foam::isDir(dir/processorsBaseDir))
|
||||
{
|
||||
WarningInFunction
|
||||
|
||||
@ -862,7 +862,9 @@ public:
|
||||
virtual label nProcs
|
||||
(
|
||||
const fileName& dir,
|
||||
const fileName& local = ""
|
||||
const fileName& local = "",
|
||||
//! >0 if we know in advance what we're looking for
|
||||
const label wantedNProcs = 0
|
||||
) const;
|
||||
|
||||
//- Get sorted list of times
|
||||
|
||||
@ -1983,7 +1983,7 @@ bool Foam::fileOperations::masterUncollatedFileOperation::readHeader
|
||||
{
|
||||
Pout<< "masterUncollatedFileOperation::readHeader :" << " ok:" << ok
|
||||
<< " class:" << io.headerClassName()
|
||||
<< " for file:" << fName << endl;;
|
||||
<< " for file:" << fName << endl;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -8,18 +8,19 @@ restore0Dir
|
||||
runApplication blockMesh
|
||||
|
||||
decompDict5="-decomposeParDict system/decomposeParDict.5"
|
||||
fileHandler="-fileHandler uncollated"
|
||||
|
||||
# redistributePar to do decomposition
|
||||
runParallel -s decompose redistributePar -decompose
|
||||
runParallel -s decompose redistributePar -decompose $fileHandler
|
||||
|
||||
# Bit of renumbering and running
|
||||
runParallel -s CuthillMcKee renumberMesh -overwrite
|
||||
runParallel -s CuthillMcKee icoFoam
|
||||
runParallel -s CuthillMcKee renumberMesh -overwrite $fileHandler
|
||||
runParallel -s CuthillMcKee icoFoam $fileHandler
|
||||
|
||||
# Bit of bad renumbering and running
|
||||
runParallel -s random renumberMesh \
|
||||
-overwrite -dict system/renumberMeshDict-random
|
||||
runParallel -s random icoFoam
|
||||
-overwrite -dict system/renumberMeshDict-random $fileHandler
|
||||
runParallel -s random icoFoam $fileHandler
|
||||
|
||||
# Pick up last result
|
||||
cp system/controlDict-latestTime system/controlDict
|
||||
@ -27,13 +28,13 @@ cp system/controlDict-latestTime system/controlDict
|
||||
# Redistribute to 5 processors. Note that new processors only get written
|
||||
# a mesh to the current time (0.505). Use -overwrite instead to write the
|
||||
# mesh to constant.
|
||||
runParallel -s 5 $decompDict5 redistributePar -cellDist
|
||||
runParallel -s 5 $decompDict5 redistributePar -cellDist $fileHandler
|
||||
|
||||
# Run a bit more
|
||||
runParallel -s 5 $decompDict5 icoFoam
|
||||
runParallel -s 5 $decompDict5 icoFoam $fileHandler
|
||||
|
||||
# Reconstruct mesh and results. Note the time argument to make sure we
|
||||
# only pick up the new decomposition
|
||||
runParallel -s reconstruct -np 5 redistributePar -reconstruct -time 0.505:
|
||||
runParallel -s reconstruct -np 5 redistributePar -reconstruct -time 0.505: $fileHandler
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user