Go to the documentation of this file.
81 static inline bool lessThan(
const scalar& val,
const scalar&
upper)
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");
385 HashSet<fileName> filesOnDisk;
414 unsigned instStatus = 0;
419 IFstream is(seriesFile);
423 parse state = parse::NONE;
424 (state != parse::DONE && state != parse::FAIL)
434 if (tok.isString() && tok.stringToken() ==
"files")
444 state = parse::FILES_ARRAY;
455 case parse::FILES_ARRAY :
457 if (tok.isPunctuation())
459 switch (tok.pToken())
467 state = parse::ENTRY;
491 if (tok.isPunctuation())
493 switch (tok.pToken())
507 &&
lessThan(inst.value(), restartTime)
511 ? filesOnDisk.found(inst.name())
519 state = parse::FILES_ARRAY;
529 else if (tok.isString())
533 const string key(tok.stringToken());
541 inst.name() = tok.stringToken();
549 else if (
"time" ==
key)
553 inst.value() = tok.number();
586 const scalar restartTime
598 fileName seriesFile(seriesName);
600 if (seriesName.
hasExt(
"series"))
606 const word ext = seriesFile.
ext();
609 const auto minLen = stem.length() + ext.length() + 1;
611 const auto acceptName =
612 [=](
const fileName& file) ->
bool
616 minLen < file.length()
632 bool warnings =
false;
634 for (
const fileName& file : files)
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());
static autoPtr< T > New(Args &&... args)
@ COMMA
Comma [isseparator].
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
@ NONE
No type, or default initialized type.
static std::string nameLessExt(const std::string &str)
A class for handling words, derived from Foam::string.
A class for handling file names.
static fileName base(const fileName &outputName, char sep='_')
Specialized string sorting.
static std::string path(const std::string &str)
Input from file stream, using an ISstream.
const string & stringToken() const
bool starts_with(const std::string &s) const
bool removeNewer(const scalar timeValue)
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
Generic input stream using a standard (STL) stream.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
A token holds an item read from Istream.
const Type & value() const
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='_')
punctuationToken pToken() const
bool isNumber() const noexcept
word outputName("finiteArea-edges.obj")
const dimensionedScalar b
@ BEGIN_SQR
Begin dimensions [isseparator].
bool isPunctuation() const noexcept
static Ostream & print(Ostream &os, const fileName &seriesName, const UList< instant > &series, const char sep='_')
label load(const fileName &seriesName, const bool checkFiles=false, const scalar restartTime=ROOTVGREAT)
@ END_BLOCK
End block [isseparator].
@ END_SQR
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='_')
static int compare(const std::string &s1, const std::string &s2)
bool bad() const noexcept
static bool getToken(ISstream &is, token &tok)
@ BEGIN_BLOCK
Begin block [isseparator].
Output to file stream, using an OSstream.
List< fileName > fileNameList
A List of fileNames.
bool good() const noexcept
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
@ COLON
Colon [isseparator].
bool operator()(const fileNameInstant a, const fileNameInstant b) const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static bool getValueToken(ISstream &is, token &tok)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
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)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
bool isString() const noexcept
virtual Istream & read(token &t)
word name(const expressions::valueTypeCode typeCode)
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)
bool mkDir(const fileName &pathName, mode_t mode=0777)
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
label scan(const fileName &seriesName, const scalar restartTime=ROOTVGREAT)
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)
static bool lessThan(const scalar &val, const scalar &upper)
List< T > subsetList(const UList< T > &input, const UnaryPredicate &pred, const bool invert=false)