BUG: questionable findInstance handling of constant (related to #1112)

- when searching for a file that may not actually exist,
  the short-cut optimization could lead to the 'constant' directory
  being ignored.

STYLE: simplify logic in points0MotionSolver::points0IO
This commit is contained in:
Mark Olesen
2019-07-05 11:04:06 +02:00
committed by Andrew Heather
parent 79bf4fafb6
commit eaacf0a20a
2 changed files with 28 additions and 56 deletions

View File

@ -48,58 +48,29 @@ Foam::IOobject Foam::points0MotionSolver::points0IO(const polyMesh& mesh)
IOobject::READ_IF_PRESENT
);
if (instance != mesh.time().constant())
IOobject io
(
"points0",
instance,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
// If points0 are located in constant directory, verify their existence
// or fallback to a copy of the original mesh points
if
(
instance == mesh.time().constant()
&& !io.typeHeaderOk<pointIOField>()
)
{
// points0 written to a time folder
return
IOobject
(
"points0",
instance,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
io.rename("points");
}
else
{
// Check that points0 are actually in constant directory
IOobject io
(
"points0",
instance,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (io.typeHeaderOk<pointIOField>())
{
return io;
}
else
{
// Copy of original mesh points
return
IOobject
(
"points",
instance,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
}
}
return io;
}