mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge commit 'd7b321bf864eb8ac0b771c4a5d94121470d46f9f' into olesenm
Conflicts: src/OpenFOAM/db/Time/findInstance.C
This commit is contained in:
@ -283,10 +283,11 @@ public:
|
|||||||
|
|
||||||
//- Return the location of "dir" containing the file "name".
|
//- Return the location of "dir" containing the file "name".
|
||||||
// (Used in reading mesh data)
|
// (Used in reading mesh data)
|
||||||
|
// If name is null search for the directory "dir" only
|
||||||
word findInstance
|
word findInstance
|
||||||
(
|
(
|
||||||
const fileName& dir,
|
const fileName& dir,
|
||||||
const word& name,
|
const word& name = word::null,
|
||||||
const IOobject::readOption rOpt = IOobject::MUST_READ
|
const IOobject::readOption rOpt = IOobject::MUST_READ
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,9 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Return the location of "directory" containing the file "name".
|
If "name" is empty: return the location of "directory"
|
||||||
|
If "name" is not empty: return the location of "directory" containing the
|
||||||
|
file "name".
|
||||||
Used in reading mesh data.
|
Used in reading mesh data.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -40,85 +42,96 @@ Foam::word Foam::Time::findInstance
|
|||||||
const IOobject::readOption rOpt
|
const IOobject::readOption rOpt
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Is the mesh data in the current time directory ?
|
// Note: if name is empty, just check the directory itself
|
||||||
|
|
||||||
|
// check the current time directory
|
||||||
if
|
if
|
||||||
|
(
|
||||||
|
name.empty()
|
||||||
|
? isDir(path()/timeName()/dir)
|
||||||
|
:
|
||||||
(
|
(
|
||||||
isFile(path()/timeName()/dir/name)
|
isFile(path()/timeName()/dir/name)
|
||||||
&& IOobject(name, timeName(), dir, *this).headerOk()
|
&& IOobject(name, timeName(), dir, *this).headerOk()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Time::findInstance(const word& dir, const word& name) : "
|
Info<< "Time::findInstance(const fileName&, const word&) : "
|
||||||
<< "reading " << name
|
<< "found \"" << name
|
||||||
<< " from " << timeName()/dir
|
<< "\" in " << timeName()/dir
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return timeName();
|
return timeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search back through the time directories list to find the time
|
// Search back through the time directories to find the time
|
||||||
// closest to and lower than current time
|
// closest to and lower than current time
|
||||||
|
|
||||||
instantList ts = times();
|
instantList ts = times();
|
||||||
label i;
|
label instanceI;
|
||||||
|
|
||||||
for (i=ts.size()-1; i>=0; i--)
|
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
|
||||||
{
|
{
|
||||||
if (ts[i].value() <= timeOutputValue())
|
if (ts[instanceI].value() <= timeOutputValue())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Noting that the current directory has already been searched
|
// continue searching from here
|
||||||
// for mesh data, start searching from the previously stored time directory
|
for (; instanceI >= 0; --instanceI)
|
||||||
|
|
||||||
if (i>=0)
|
|
||||||
{
|
|
||||||
for (label j=i; j>=0; j--)
|
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
isFile(path()/ts[j].name()/dir/name)
|
name.empty()
|
||||||
&& IOobject(name, ts[j].name(), dir, *this).headerOk()
|
? isDir(path()/ts[instanceI].name()/dir)
|
||||||
|
:
|
||||||
|
(
|
||||||
|
isFile(path()/ts[instanceI].name()/dir/name)
|
||||||
|
&& IOobject(name, ts[instanceI].name(), dir, *this).headerOk()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Time::findInstance(const word& dir, "
|
Info<< "Time::findInstance"
|
||||||
<< "const word& name) : "
|
"(const fileName&,const word&) : "
|
||||||
<< "reading " << name
|
<< "found \"" << name
|
||||||
<< " from " << ts[j].name()/dir
|
<< "\" in " << ts[instanceI].name()/dir
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ts[j].name();
|
return ts[instanceI].name();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the mesh data is not in any of the time directories
|
// not in any of the time directories, try constant
|
||||||
// Try in constant
|
|
||||||
|
|
||||||
// Note. This needs to be a hard-coded constant, rather than the
|
// Note. This needs to be a hard-coded constant, rather than the
|
||||||
// constant function of the time, because the latter points to
|
// constant function of the time, because the latter points to
|
||||||
// the case constant directory in parallel cases
|
// the case constant directory in parallel cases
|
||||||
|
|
||||||
if
|
if
|
||||||
|
(
|
||||||
|
name.empty()
|
||||||
|
? isDir(path()/constant()/dir)
|
||||||
|
:
|
||||||
(
|
(
|
||||||
isFile(path()/constant()/dir/name)
|
isFile(path()/constant()/dir/name)
|
||||||
&& IOobject(name, constant(), dir, *this).headerOk()
|
&& IOobject(name, constant(), dir, *this).headerOk()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Time::findInstance(const word& dir, "
|
Info<< "Time::findInstance"
|
||||||
<< "const word& name) : "
|
"(const fileName&,const word&) : "
|
||||||
<< "reading " << name
|
<< "found \"" << name
|
||||||
<< " from " << constant()/dir
|
<< "\" in " << constant()/dir
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +140,10 @@ Foam::word Foam::Time::findInstance
|
|||||||
|
|
||||||
if (rOpt == IOobject::MUST_READ)
|
if (rOpt == IOobject::MUST_READ)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Time::findInstance(const word& dir, const word& name)")
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Time::findInstance(const fileName&,const word&)"
|
||||||
|
)
|
||||||
<< "Cannot find file \"" << name << "\" in directory "
|
<< "Cannot find file \"" << name << "\" in directory "
|
||||||
<< constant()/dir
|
<< constant()/dir
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -136,4 +152,5 @@ Foam::word Foam::Time::findInstance
|
|||||||
return constant();
|
return constant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user