36 bool Foam::TimePaths::detectProcessorCase()
40 return processorCase_;
44 const auto sep = globalCaseName_.rfind(
'/');
45 const auto pos = globalCaseName_.find
48 (sep == string::npos ? 0 : sep)
53 globalCaseName_ =
".";
54 processorCase_ =
true;
56 else if (
pos != string::npos && sep != string::npos && sep ==
pos-1)
58 globalCaseName_.resize(sep);
59 processorCase_ =
true;
62 return processorCase_;
70 const bool processorCase,
72 const bool distributed,
75 const word& systemDirName,
76 const word& constantDirName
79 processorCase_(processorCase),
80 distributed_(distributed),
82 globalCaseName_(globalCaseName),
84 system_(systemDirName),
85 constant_(constantDirName)
89 detectProcessorCase();
96 const word& systemDirName,
97 const word& constantDirName
102 args.runControl().parRun(),
104 args.runControl().distributed(),
105 args.globalCaseName(),
121 return fileHandler().findTimes(directory, constantDirName);
127 return findTimes(
path(), constant());
145 if (t.
equal(timeDirs[i].value()))
147 return timeDirs[i].name();
178 return findInstancePath(timeDirs, t);
186 const word& constantDirName
189 const label nTimes = timeDirs.
size();
191 label nearestIndex = -1;
192 scalar deltaT = GREAT;
194 for (label timei=0; timei < nTimes; ++timei)
196 if (timeDirs[timei].
name() == constantDirName)
continue;
198 const scalar
diff =
mag(timeDirs[timei].value() - t);
202 nearestIndex = timei;
214 const label nTimes = timeDirs.size();
219 return instant(0, constant());
221 else if (nTimes == 1)
224 return timeDirs.front();
226 else if (t < timeDirs[1].value())
230 else if (t > timeDirs.back().value())
232 return timeDirs.back();
235 label nearestIndex = 0;
236 scalar deltaT = GREAT;
238 for (label timei=1; timei < nTimes; ++timei)
240 const scalar
diff =
mag(timeDirs[timei].value() - t);
244 nearestIndex = timei;
248 return timeDirs[nearestIndex];
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
void size(const label n)
Older name for setAddressableSize.
Address the time paths without using the Time class.
A class for handling file names.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
static label findClosestTimeIndex(const UList< instant > &timeDirs, const scalar t, const word &constantDirName="constant")
Search instantList for the time index closest to the specified time.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
dimensionedScalar pos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
static word findInstancePath(const UList< instant > &timeDirs, const instant &t)
Search instantList for matching time value, return the instance name or word::null if nothing is equa...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
static instantList findTimes(const fileName &directory, const word &constantDirName="constant")
Search a given directory for valid time directories.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
instantList times() const
Search the case for valid time directories.
TimePaths(const bool processorCase, const fileName &rootPath, const bool distributed, const fileName &globalCaseName, const fileName &caseName, const word &systemDirName="system", const word &constantDirName="constant")
Construct from all components.
instant findClosestTime(const scalar t) const
Search the case for the time closest to the given time.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
List< instant > instantList
List of instants.
bool equal(scalar val) const noexcept
True if values are equal (includes SMALL for rounding)
Foam::argList args(argc, argv)