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_;
71 const word& systemName,
72 const word& constantName
75 processorCase_(
args.runControl().parRun()),
76 distributed_(
args.runControl().distributed()),
77 rootPath_(
args.rootPath()),
78 globalCaseName_(
args.globalCaseName()),
79 case_(
args.caseName()),
81 constant_(constantName)
86 detectProcessorCase();
94 const word& systemName,
95 const word& constantName
98 processorCase_(false),
101 globalCaseName_(caseName),
104 constant_(constantName)
107 detectProcessorCase();
113 const bool processorCase,
115 const bool distributed,
118 const word& systemName,
119 const word& constantName
122 processorCase_(processorCase),
123 distributed_(distributed),
125 globalCaseName_(globalCaseName),
128 constant_(constantName)
133 detectProcessorCase();
145 return fileHandler().findTimes(directory, constantName);
151 return findTimes(
path(), constant());
159 const word& constantName
162 const label nTimes = timeDirs.
size();
164 label nearestIndex = -1;
165 scalar deltaT = GREAT;
167 for (label timei=0; timei < nTimes; ++timei)
169 if (timeDirs[timei].
name() == constantName)
continue;
171 const scalar
diff =
mag(timeDirs[timei].value() - t);
175 nearestIndex = timei;
187 const label nTimes = timeDirs.size();
192 return timeDirs.first();
195 if (t < timeDirs[1].value())
199 else if (t > timeDirs.last().value())
201 return timeDirs.last();
204 label nearestIndex = -1;
205 scalar deltaT = GREAT;
207 for (label timei=1; timei < nTimes; ++timei)
209 const scalar
diff =
mag(timeDirs[timei].value() - t);
213 nearestIndex = timei;
217 return timeDirs[nearestIndex];
List< instant > instantList
List of instants.
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.
A class for handling file names.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static label findClosestTimeIndex(const instantList &timeDirs, const scalar t, const word &constantName="constant")
Search instantList for the time index closest to the specified time.
autoPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
TimePaths(const argList &args, const word &systemName="system", const word &constantName="constant")
Construct using characteristics given by the argList.
dimensionedScalar pos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
static instantList findTimes(const fileName &directory, const word &constantName="constant")
Search a given directory for valid time directories.
instantList times() const
Search the case for valid time directories.
instant findClosestTime(const scalar t) const
Search the case for the time closest to the given time.
Foam::argList args(argc, argv)