Go to the documentation of this file.
99 const auto dash = outputName.rfind(sep);
104 std::string::npos == dash
105 || std::string::npos != outputName.find(
'/', dash)
112 const auto dot = outputName.find(
'.', dash);
114 if (std::string::npos ==
dot)
116 return outputName.substr(0, dash);
119 return outputName.substr(0, dash) + outputName.substr(
dot);
129 const auto dash = file.rfind(sep);
134 std::string::npos == dash
135 || std::string::npos != file.find(
'/', dash)
142 const auto dot = file.find(
'.', dash);
144 if (std::string::npos ==
dot)
146 return file.substr(dash);
149 return file.substr(dash, (
dot-dash));
169 const word ext =
"." + base.
ext();
172 os <<
"{\n \"file-series-version\" : \"1.0\",\n \"files\" : [\n";
176 label nremain = series.
size();
181 for (
const instant& inst : series)
183 os <<
" { \"name\" : \""
184 << stem << sep << inst.name() << ext
185 <<
"\", \"time\" : " << inst.value() <<
" }";
207 os <<
"{\n \"file-series-version\" : \"1.0\",\n \"files\" : [\n";
211 label nremain = series.
size();
218 os <<
" { \"name\" : \""
220 <<
"\", \"time\" : " << inst.value() <<
" }";
246 seriesName.
hasExt(
"series")
251 print(*osPtr, seriesName, series, sep);
266 seriesName.
hasExt(
"series")
271 print(*osPtr, series);
279 if (inst.
name().empty())
284 const auto iter = existing_.find(inst.
name());
290 if (dst.name() == inst.
name())
293 dst.value() = inst.
value();
299 entries_.append(inst);
300 existing_.insert(inst.
name());
306 bool Foam::vtk::seriesWriter::removeDuplicates()
308 const label nElem = entries_.size();
310 HashTable<label, fileName> filesSeen(2*nElem);
312 bool changed =
false;
314 for (label elemi=0; elemi < nElem; ++elemi)
318 if (inst.name().empty())
324 auto iter = filesSeen.find(inst.name());
329 entries_[*iter].
name().clear();
336 filesSeen.insert(inst.name(), elemi);
345 for (label elemi=0; elemi < nElem; ++elemi)
349 if (!src.name().empty())
353 entries_[dsti] = std::move(src);
359 entries_.resize(dsti);
362 return (nElem != entries_.size());
371 const bool checkFiles,
372 const scalar restartTime
378 if (!seriesFile.
hasExt(
"series"))
380 seriesFile.
ext(
"series");
417 unsigned instStatus = 0;
426 parse state = parse::NONE;
427 (state != parse::DONE && state != parse::FAIL)
448 state = parse::FILES_ARRAY;
459 case parse::FILES_ARRAY :
471 state = parse::ENTRY;
523 state = parse::FILES_ARRAY;
553 else if (
"time" == key)
590 const scalar restartTime
604 if (seriesName.
hasExt(
"series"))
610 const word ext = seriesFile.
ext();
613 const auto minLen = stem.length() + ext.length() + 1;
615 const auto acceptName =
620 minLen < file.length()
636 bool warnings =
false;
640 std::ifstream is(
path/file);
651 is.read(&(header.front()), header.size());
652 header.resize(is.gcount());
660 auto begAttr = header.find(
"time=");
662 if (string::npos == begAttr)
666 Info<<
"No 'time=' comment attribute found:\n(" <<
nl;
675 const char quote = header[begAttr];
681 (quote ==
'"' || quote ==
'\'')
684 header.find(quote, ++begAttr)
687 header.find_first_of(
"\t\n\v\f\r ", begAttr)
693 string::npos != endAttr && begAttr < endAttr
696 header.substr(begAttr, endAttr-begAttr),
726 const label nElem = entries_.size();
728 for (label elemi=0; elemi < nElem; ++elemi)
736 entries_[dsti] = std::move(src);
737 existing_.insert(entries_[dsti].
name());
743 entries_.resize(dsti);
745 return (nElem != entries_.size());
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static std::string nameLessExt(const std::string &str)
Return basename, without extension.
A class for handling words, derived from Foam::string.
A class for handling file names.
static fileName base(const fileName &outputName, char sep='_')
Extract the base name for a file series.
Specialized string sorting.
bool isNumber() const
Token is LABEL, FLOAT or DOUBLE.
static std::string path(const std::string &str)
Return directory path name (part before last /)
Input from file stream, using an ISstream.
const string & stringToken() const
Return const reference to the string contents.
bool starts_with(const std::string &s) const
True if string starts with the given prefix (cf. C++20)
bool removeNewer(const scalar timeValue)
Remove entries that are greater_equal the time value.
Three-way comparison operation of two parameters,.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
bool isString() const
Token is STRING, VARIABLE or VERBATIM string.
const word & name() const
Return const reference to name.
Generic input stream using a standard (STL) stream.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
A token holds an item read from Istream.
const Type & value() const
Return const reference to value.
bool good() const
True if token is not UNDEFINED or ERROR.
A HashTable with keys but without contents that is similar to std::unordered_set.
static word suffix(const fileName &file, char sep='_')
Extract the time-varying ending of files.
punctuationToken pToken() const
Return punctuation character.
scalar number() const
Return label, float or double value.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
bool hasExt() const
Return true if it has an extension or simply ends with a '.'.
Begin dimensions [isseparator].
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
bool removeExt()
Remove extension, returning true if string changed.
static Ostream & print(Ostream &os, const fileName &seriesName, const UList< instant > &series, const char sep='_')
Print file series (JSON format) for specified time instances.
virtual const fileName & name() const
Return the name of the stream.
label load(const fileName &seriesName, const bool checkFiles=false, const scalar restartTime=ROOTVGREAT)
Clear contents and reload by parsing the specified file.
bool bad() const
Return true if stream is corrupted.
End dimensions [isseparator].
Instant< fileName > fileNameInstant
A tuple of value and fileName.
static void write(const fileName &base, const UList< instant > &series, const char sep='_')
Write file series (JSON format) to disk, for specified instances.
word ext() const
Return file name extension (part after last .)
static int compare(const std::string &s1, const std::string &s2)
Natural compare for std::string.
static bool getToken(ISstream &is, token &tok)
Begin block [isseparator].
const T & name() const
The name/key (const access)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
bool operator()(const fileNameInstant a, const fileNameInstant b) const
Input/output from file streams.
static bool getValueToken(ISstream &is, token &tok)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
scalar value() const
The value (const access)
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
virtual Istream & read(token &t)
Return next token from stream.
Encapsulation of natural order sorting for algorithms.
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
void sort()
Sort by time value and by file name.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
Various functions to operate on Lists.
An instant of time. Contains the time value and name.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
bool isPunctuation() const
Token is PUNCTUATION.
bool found(const Key &key) const
Return true if hashed entry is found in table.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
label scan(const fileName &seriesName, const scalar restartTime=ROOTVGREAT)
Clear contents and scan directory for files.
A tuple of value and key. The value often corresponds to a time value, thus the naming of the class....
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
static bool lessThan(const scalar &val, const scalar &upper)
List< T > subsetList(const UList< T > &input, const UnaryPredicate &pred, const bool invert=false)
Copy a subset of the input list when predicate is true.