diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index b799619562..af5db52e6f 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -450,7 +450,11 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const readAction r) // Check where surface was found const fileName localFile(io.localFilePath(typeName)); - if (r == masterOnly && (actualFile != localFile)) + if + ( + r == masterOnly + && ((actualFile.empty() || actualFile != localFile)) + ) { // Found undecomposed surface. Load on master only if (Pstream::master()) @@ -563,10 +567,18 @@ Foam::triSurfaceMesh::triSurfaceMesh if (searchGlobal && Pstream::parRun()) { - // Check where surface was found + // Check where surface was found. Bit tricky: + // - master will have actualFile (in parent directory) + // different from localFilePath (in processor0/) + // - slave might have actualFile empty and localFile empty + const fileName localFile(io.localFilePath(typeName)); - if (r == masterOnly && (actualFile != localFile)) + if + ( + r == masterOnly + && ((actualFile.empty() || actualFile != localFile)) + ) { // Surface not loaded from processor directories -> undecomposed // surface. Load on master only diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index adfbaa4854..cdb27f6f36 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -2642,11 +2642,16 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(const IOobject& io) bounds().reduce(); - const fileName actualFile(triSurfaceMesh::checkFile(io, true)); + // Try and find out where the triSurface was loaded from. On slave this + // might give empty filename. + const fileName actualFile(triSurfaceMesh::findFile(io, true)); if ( - actualFile != io.localFilePath(triSurfaceMesh::typeName) + ( + actualFile.empty() + || actualFile != io.localFilePath(triSurfaceMesh::typeName) + ) && (distType_ == INDEPENDENT || distType_ == DISTRIBUTED) ) { @@ -2779,11 +2784,16 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh bounds().reduce(); - const fileName actualFile(triSurfaceMesh::checkFile(io, dict, true)); + // Try and find out where the triSurface was loaded from. On slave this + // might give empty filename. + const fileName actualFile(triSurfaceMesh::findFile(io, dict, true)); if ( - actualFile != io.localFilePath(triSurfaceMesh::typeName) + ( + actualFile.empty() + || actualFile != io.localFilePath(triSurfaceMesh::typeName) + ) && (distType_ == INDEPENDENT || distType_ == DISTRIBUTED) ) {