1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 If "name" is empty: return the location of "directory"
26 If "name" is not empty: return the location of "directory" containing the
28 Used in reading mesh data.
30 \*---------------------------------------------------------------------------*/
32 #include "objectRegistry.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 Foam::word Foam::Time::findInstance
42 const IOobject::readOption rOpt
45 // Note: if name is empty, just check the directory itself
47 // check the current time directory
51 ? isDir(path()/timeName()/dir)
54 isFile(path()/timeName()/dir/name)
55 && IOobject(name, timeName(), dir, *this).headerOk()
61 Info<< "Time::findInstance"
62 "(const fileName&, const word&, const IOobject::readOption)"
63 << " : found \"" << name
64 << "\" in " << timeName()/dir
71 // Search back through the time directories to find the time
72 // closest to and lower than current time
74 instantList ts = times();
77 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
79 if (ts[instanceI].value() <= timeOutputValue())
85 // continue searching from here
86 for (; instanceI >= 0; --instanceI)
91 ? isDir(path()/ts[instanceI].name()/dir)
94 isFile(path()/ts[instanceI].name()/dir/name)
95 && IOobject(name, ts[instanceI].name(), dir, *this).headerOk()
101 Info<< "Time::findInstance"
102 "(const fileName&, const word&, const IOobject::readOption)"
103 << " : found \"" << name
104 << "\" in " << ts[instanceI].name()/dir
108 return ts[instanceI].name();
113 // not in any of the time directories, try constant
115 // Note. This needs to be a hard-coded constant, rather than the
116 // constant function of the time, because the latter points to
117 // the case constant directory in parallel cases
122 ? isDir(path()/constant()/dir)
125 isFile(path()/constant()/dir/name)
126 && IOobject(name, constant(), dir, *this).headerOk()
132 Info<< "Time::findInstance"
133 "(const fileName&, const word&, const IOobject::readOption)"
134 << " : found \"" << name
135 << "\" in " << constant()/dir
142 if (rOpt == IOobject::MUST_READ)
147 "(const fileName&, const word&, const IOobject::readOption)"
148 ) << "Cannot find file \"" << name << "\" in directory "
157 // ************************************************************************* //