Skip to content
Snippets Groups Projects
Commit e6717b6e authored by Henry Weller's avatar Henry Weller Committed by Andrew Heather
Browse files

triSurfaceMesh: corrected parallel operation of 'file' specification

Patch contributed by Mattijs Janssens
Resolves bug-report https://bugs.openfoam.org/view.php?id=2614
parent d7ff97f4
Branches
Tags
No related merge requests found
......@@ -65,9 +65,34 @@ Foam::fileName Foam::triSurfaceMesh::checkFile
}
Foam::fileName Foam::triSurfaceMesh::relativeFilePath
(
const regIOobject& io,
const fileName& f,
const bool isGlobal
)
{
fileName fName(f);
fName.expand();
if (!fName.isAbsolute())
{
// Is the specified file:
// - local to the cwd?
// - local to the case dir?
// - or just another name?
fName = fileHandler().filePath
(
isGlobal,
IOobject(io, fName),
word::null
);
}
return fName;
}
Foam::fileName Foam::triSurfaceMesh::checkFile
(
const IOobject& io,
const regIOobject& io,
const dictionary& dict,
const bool isGlobal
)
......@@ -75,11 +100,8 @@ Foam::fileName Foam::triSurfaceMesh::checkFile
fileName fName;
if (dict.readIfPresent("file", fName, false, false))
{
fName.expand();
if (!fName.isAbsolute())
{
fName = io.objectPath().path()/fName;
}
fName = relativeFilePath(io, fName, isGlobal);
if (!exists(fName))
{
FatalErrorInFunction
......@@ -299,7 +321,15 @@ Foam::triSurfaceMesh::triSurfaceMesh
outsideVolType_(volumeType::UNKNOWN)
{
// Reading from supplied file name instead of objectPath/filePath
dict.readIfPresent("file", fName_, false, false);
if (dict.readIfPresent("file", fName_, false, false))
{
fName_ = relativeFilePath
(
static_cast<const searchableSurface&>(*this),
fName_,
true
);
}
scalar scaleFactor = 0;
......@@ -391,7 +421,15 @@ Foam::triSurfaceMesh::triSurfaceMesh
outsideVolType_(volumeType::UNKNOWN)
{
// Reading from supplied file name instead of objectPath/filePath
dict.readIfPresent("file", fName_, false, false);
if (dict.readIfPresent("file", fName_, false, false))
{
fName_ = relativeFilePath
(
static_cast<const searchableSurface&>(*this),
fName_,
isGlobal
);
}
scalar scaleFactor = 0;
......
......@@ -95,10 +95,19 @@ class triSurfaceMesh
//- Return fileName to load IOobject from
static fileName checkFile(const IOobject& io, const bool isGlobal);
//- Return fileName. If fileName is relative gets treated local to
// IOobject
static fileName relativeFilePath
(
const regIOobject&,
const fileName&,
const bool isGlobal
);
//- Return fileName to load IOobject from. Optional override of fileName
static fileName checkFile
(
const IOobject&,
const regIOobject&,
const dictionary&,
const bool isGlobal
);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment