findInstance.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "Time.H"
00034 #include "IOobject.H"
00035
00036
00037
00038 Foam::word Foam::Time::findInstance
00039 (
00040 const fileName& dir,
00041 const word& name,
00042 const IOobject::readOption rOpt
00043 ) const
00044 {
00045
00046
00047
00048 if
00049 (
00050 name.empty()
00051 ? isDir(path()/timeName()/dir)
00052 :
00053 (
00054 isFile(path()/timeName()/dir/name)
00055 && IOobject(name, timeName(), dir, *this).headerOk()
00056 )
00057 )
00058 {
00059 if (debug)
00060 {
00061 Info<< "Time::findInstance"
00062 "(const fileName&, const word&, const IOobject::readOption)"
00063 << " : found \"" << name
00064 << "\" in " << timeName()/dir
00065 << endl;
00066 }
00067
00068 return timeName();
00069 }
00070
00071
00072
00073
00074 instantList ts = times();
00075 label instanceI;
00076
00077 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
00078 {
00079 if (ts[instanceI].value() <= timeOutputValue())
00080 {
00081 break;
00082 }
00083 }
00084
00085
00086 for (; instanceI >= 0; --instanceI)
00087 {
00088 if
00089 (
00090 name.empty()
00091 ? isDir(path()/ts[instanceI].name()/dir)
00092 :
00093 (
00094 isFile(path()/ts[instanceI].name()/dir/name)
00095 && IOobject(name, ts[instanceI].name(), dir, *this).headerOk()
00096 )
00097 )
00098 {
00099 if (debug)
00100 {
00101 Info<< "Time::findInstance"
00102 "(const fileName&, const word&, const IOobject::readOption)"
00103 << " : found \"" << name
00104 << "\" in " << ts[instanceI].name()/dir
00105 << endl;
00106 }
00107
00108 return ts[instanceI].name();
00109 }
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119 if
00120 (
00121 name.empty()
00122 ? isDir(path()/constant()/dir)
00123 :
00124 (
00125 isFile(path()/constant()/dir/name)
00126 && IOobject(name, constant(), dir, *this).headerOk()
00127 )
00128 )
00129 {
00130 if (debug)
00131 {
00132 Info<< "Time::findInstance"
00133 "(const fileName&, const word&, const IOobject::readOption)"
00134 << " : found \"" << name
00135 << "\" in " << constant()/dir
00136 << endl;
00137 }
00138
00139 return constant();
00140 }
00141
00142 if (rOpt == IOobject::MUST_READ)
00143 {
00144 FatalErrorIn
00145 (
00146 "Time::findInstance"
00147 "(const fileName&, const word&, const IOobject::readOption)"
00148 ) << "Cannot find file \"" << name << "\" in directory "
00149 << constant()/dir
00150 << exit(FatalError);
00151 }
00152
00153 return constant();
00154 }
00155
00156
00157
Copyright © 2000-2009 OpenCFD Ltd