findTimes.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 #include "Time.H"
00033 #include "OSspecific.H"
00034 #include "IStringStream.H"
00035
00036
00037
00038 Foam::instantList Foam::Time::findTimes(const fileName& directory)
00039 {
00040 if (debug)
00041 {
00042 Info<< "Time::findTimes(const fileName&): finding times in directory "
00043 << directory << endl;
00044 }
00045
00046
00047 fileNameList dirEntries(readDir(directory, fileName::DIRECTORY));
00048
00049
00050 instantList Times(dirEntries.size() + 1);
00051 label nTimes = 0;
00052
00053
00054 bool haveConstant = false;
00055 forAll(dirEntries, i)
00056 {
00057 if (dirEntries[i] == "constant")
00058 {
00059 Times[nTimes].value() = 0;
00060 Times[nTimes].name() = dirEntries[i];
00061 nTimes++;
00062 haveConstant = true;
00063 break;
00064 }
00065 }
00066
00067
00068 forAll(dirEntries, i)
00069 {
00070 IStringStream timeStream(dirEntries[i]);
00071 token timeToken(timeStream);
00072
00073 if (timeToken.isNumber() && timeStream.eof())
00074 {
00075 Times[nTimes].value() = timeToken.number();
00076 Times[nTimes].name() = dirEntries[i];
00077 nTimes++;
00078 }
00079 }
00080
00081
00082 Times.setSize(nTimes);
00083
00084 if (haveConstant)
00085 {
00086 if (nTimes > 2)
00087 {
00088 std::sort(&Times[1], Times.end(), instant::less());
00089 }
00090 }
00091 else if (nTimes > 1)
00092 {
00093 std::sort(&Times[0], Times.end(), instant::less());
00094 }
00095
00096 return Times;
00097 }
00098
00099
Copyright © 2000-2009 OpenCFD Ltd