mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve check for decomposedBlock and simpler startup
This commit is contained in:
@ -30,6 +30,7 @@ License
|
|||||||
#include "faMesh.H"
|
#include "faMesh.H"
|
||||||
#include "Pstream.H"
|
#include "Pstream.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
#include "decomposedBlockData.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -47,7 +48,6 @@ bool Foam::checkFileExistence(const fileName& fName)
|
|||||||
// (in collated format). Use file-based searching instead
|
// (in collated format). Use file-based searching instead
|
||||||
|
|
||||||
const auto& handler = Foam::fileHandler();
|
const auto& handler = Foam::fileHandler();
|
||||||
|
|
||||||
typedef fileOperation::procRangeType procRangeType;
|
typedef fileOperation::procRangeType procRangeType;
|
||||||
|
|
||||||
fileName path, pDir, local;
|
fileName path, pDir, local;
|
||||||
@ -136,8 +136,80 @@ Foam::boolList Foam::haveMeshFile
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
// Simple directory scanning - too fragile
|
||||||
bool found = checkFileExistence(runTime.path()/meshPath/meshFile);
|
bool found = checkFileExistence(runTime.path()/meshPath/meshFile);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Trimmed-down version of lookupAndCacheProcessorsPath
|
||||||
|
// with Foam::exists() check. No caching.
|
||||||
|
|
||||||
|
// Check for two conditions:
|
||||||
|
// - file has to exist
|
||||||
|
// - if collated the entry has to exist inside the file
|
||||||
|
|
||||||
|
// Note: bypass fileOperation::filePath(IOobject&) since has problems
|
||||||
|
// with going to a different number of processors
|
||||||
|
// (in collated format). Use file-based searching instead
|
||||||
|
|
||||||
|
const auto& handler = Foam::fileHandler();
|
||||||
|
typedef fileOperation::procRangeType procRangeType;
|
||||||
|
|
||||||
|
const fileName fName
|
||||||
|
(
|
||||||
|
handler.filePath(runTime.path()/meshPath/meshFile)
|
||||||
|
);
|
||||||
|
|
||||||
|
bool found = (!fName.empty() && handler.isFile(fName));
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(fName));
|
||||||
|
if (isPtr && isPtr->good())
|
||||||
|
{
|
||||||
|
auto& is = *isPtr;
|
||||||
|
|
||||||
|
IOobject io(meshFile, meshPath, runTime);
|
||||||
|
io.readHeader(is);
|
||||||
|
|
||||||
|
if (decomposedBlockData::isCollatedType(io))
|
||||||
|
{
|
||||||
|
fileName path, pDir, local;
|
||||||
|
procRangeType group;
|
||||||
|
label numProcs;
|
||||||
|
label proci = fileOperation::splitProcessorPath
|
||||||
|
(
|
||||||
|
fName,
|
||||||
|
path,
|
||||||
|
pDir,
|
||||||
|
local,
|
||||||
|
group,
|
||||||
|
numProcs
|
||||||
|
);
|
||||||
|
|
||||||
|
label myBlockNumber = 0;
|
||||||
|
if (proci == -1 && group.empty())
|
||||||
|
{
|
||||||
|
// 'processorsXXX' format so contains all ranks
|
||||||
|
// according to worldComm
|
||||||
|
myBlockNumber = UPstream::myProcNo(UPstream::worldComm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 'processorsXXX_n-m' format so check for the
|
||||||
|
// relative rank
|
||||||
|
myBlockNumber = UPstream::myProcNo(fileHandler().comm());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if block for the local rank is inside file
|
||||||
|
found = decomposedBlockData::hasBlock(is, myBlockNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Globally consistent information about who has a mesh
|
// Globally consistent information about who has a mesh
|
||||||
boolList haveFileOnProc
|
boolList haveFileOnProc
|
||||||
(
|
(
|
||||||
|
|||||||
@ -1451,10 +1451,6 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Disabling uncollated master reading" << nl << endl;
|
Info<< "Disabling uncollated master reading" << nl << endl;
|
||||||
IOobject::fileModificationChecking = IOobject::timeStamp;
|
IOobject::fileModificationChecking = IOobject::timeStamp;
|
||||||
|
|
||||||
// Set up uncollated file handler (still over all processors)
|
|
||||||
refPtr<fileOperation> basicHandler(fileOperation::NewUncollated());
|
|
||||||
auto oldHandler = fileOperation::fileHandler(basicHandler);
|
|
||||||
|
|
||||||
// Replace #include "createTime.H" with our own version
|
// Replace #include "createTime.H" with our own version
|
||||||
// that has MUST_READ instead of READ_MODIFIED
|
// that has MUST_READ instead of READ_MODIFIED
|
||||||
|
|
||||||
@ -1468,8 +1464,6 @@ int main(int argc, char *argv[])
|
|||||||
IOobjectOption::MUST_READ // Without watching
|
IOobjectOption::MUST_READ // Without watching
|
||||||
);
|
);
|
||||||
|
|
||||||
// Restore file handler
|
|
||||||
(void) fileOperation::fileHandler(oldHandler);
|
|
||||||
|
|
||||||
refPtr<fileOperation> writeHandler;
|
refPtr<fileOperation> writeHandler;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user