Go to the documentation of this file.
101 std::string::npos == dash
102 || std::string::npos !=
outputName.find(
'/', dash)
111 if (std::string::npos ==
dot)
126 const auto dash = file.rfind(sep);
131 std::string::npos == dash
132 || std::string::npos != file.find(
'/', dash)
139 const auto dot = file.find(
'.', dash);
141 if (std::string::npos ==
dot)
143 return file.substr(dash);
146 return file.substr(dash, (
dot-dash));
166 const word ext =
"." + base.
ext();
169 os <<
"{\n \"file-series-version\" : \"1.0\",\n \"files\" : [\n";
173 label nremain = series.
size();
178 for (
const instant& inst : series)
180 os <<
" { \"name\" : \""
181 << stem << sep << inst.name() << ext
182 <<
"\", \"time\" : " << inst.value() <<
" }";
204 os <<
"{\n \"file-series-version\" : \"1.0\",\n \"files\" : [\n";
208 label nremain = series.
size();
215 os <<
" { \"name\" : \""
216 << inst.name().name()
217 <<
"\", \"time\" : " << inst.value() <<
" }";
243 seriesName.
hasExt(
"series")
248 print(*osPtr, seriesName, series, sep);
263 seriesName.
hasExt(
"series")
268 print(*osPtr, series);
276 if (inst.
name().empty())
281 const auto iter = existing_.find(inst.
name());
287 if (dst.name() == inst.
name())
290 dst.value() = inst.
value();
296 entries_.append(inst);
297 existing_.insert(inst.
name());
303 bool Foam::vtk::seriesWriter::removeDuplicates()
305 const label nElem = entries_.size();
307 HashTable<label, fileName> filesSeen(2*nElem);
309 bool changed =
false;
311 for (label elemi=0; elemi < nElem; ++elemi)
315 if (inst.name().empty())
321 auto iter = filesSeen.find(inst.name());
326 entries_[*iter].
name().clear();
333 filesSeen.insert(inst.name(), elemi);
342 for (label elemi=0; elemi < nElem; ++elemi)
346 if (!src.name().empty())
350 entries_[dsti] = std::move(src);
356 entries_.resize(dsti);
359 return (nElem != entries_.size());
368 const bool checkFiles,
369 const scalar restartTime
375 if (!seriesFile.
hasExt(
"series"))
377 seriesFile.
ext(
"series");
414 unsigned instStatus = 0;
423 parse state = parse::NONE;
424 (state != parse::DONE && state != parse::FAIL)
444 state = parse::FILES_ARRAY;
455 case parse::FILES_ARRAY :
467 state = parse::ENTRY;
511 ? filesOnDisk.found(inst.
name())
519 state = parse::FILES_ARRAY;
549 else if (
"time" ==
key)
586 const scalar restartTime
600 if (seriesName.
hasExt(
"series"))
606 const word ext = seriesFile.
ext();
609 const auto minLen = stem.length() + ext.length() + 1;
611 const auto acceptName =
616 minLen < file.length()
632 bool warnings =
false;
636 std::ifstream is(
path/file);
647 is.read(&(header.front()), header.size());
648 header.resize(is.gcount());
656 auto begAttr = header.find(
"time=");
658 if (string::npos == begAttr)
662 Info<<
"No 'time=' comment attribute found:\n(" <<
nl;
671 const char quote = header[begAttr];
677 (quote ==
'"' || quote ==
'\'')
680 header.find(quote, ++begAttr)
683 header.find_first_of(
"\t\n\v\f\r ", begAttr)
689 string::npos != endAttr && begAttr < endAttr
692 header.substr(begAttr, endAttr-begAttr),
722 const label nElem = entries_.size();
724 for (label elemi=0; elemi < nElem; ++elemi)
732 entries_[dsti] = std::move(src);
733 existing_.insert(entries_[dsti].
name());
739 entries_.resize(dsti);
741 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.
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,.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
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.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
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.
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
word outputName("finiteArea-edges.obj")
scalar number() const
Return label, float or double value.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
bool hasExt() const
Various checks for extensions.
Begin dimensions [isseparator].
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool removeExt()
Remove extension, returning true if string changed.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
static Ostream & print(Ostream &os, const fileName &seriesName, const UList< instant > &series, const char sep='_')
Print file series (JSON format) for specified time instances.
label load(const fileName &seriesName, const bool checkFiles=false, const scalar restartTime=ROOTVGREAT)
Clear contents and reload by parsing the specified file.
End dimensions [isseparator].
OBJstream os(runTime.globalPath()/outputName)
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.
bool bad() const noexcept
True if stream is corrupted.
static bool getToken(ISstream &is, token &tok)
Begin block [isseparator].
const T & name() const
The name/key (const access)
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
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
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())
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
virtual Istream & read(token &t)
Return next token from stream.
Encapsulation of natural order sorting for algorithms.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void sort()
Sort by time value and by file name.
Various functions to operate on Lists.
An instant of time. Contains the time value and name.
void size(const label n)
Older name for setAddressableSize.
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 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.