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());
135 const word& constantDirName
138 const label nTimes = timeDirs.
size();
140 label nearestIndex = -1;
141 scalar deltaT = GREAT;
143 for (label timei=0; timei < nTimes; ++timei)
145 if (timeDirs[timei].
name() == constantDirName)
continue;
147 const scalar
diff =
mag(timeDirs[timei].value() - t);
151 nearestIndex = timei;
163 const label nTimes = timeDirs.size();
168 return instant(0, constant());
170 else if (nTimes == 1)
173 return timeDirs.front();
175 else if (t < timeDirs[1].value())
179 else if (t > timeDirs.back().value())
181 return timeDirs.back();
184 label nearestIndex = 0;
185 scalar deltaT = GREAT;
187 for (label timei=1; timei < nTimes; ++timei)
189 const scalar
diff =
mag(timeDirs[timei].value() - t);
193 nearestIndex = timei;
197 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()
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 label findClosestTimeIndex(const instantList &timeDirs, const scalar t, const word &constantDirName="constant")
Search instantList for the time index closest to the specified time.
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.
List< instant > instantList
List of instants.
Foam::argList args(argc, argv)