81 static inline bool lessThan(
const scalar& val,
const scalar& upper)
83 return (val < upper &&
Foam::mag(val - upper) > ROOTVSMALL);
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());
303bool 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;
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()
617 && file.hasExt(ext) && file.starts_with(stem)
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=");
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)
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());
Various functions to operate on Lists.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A HashTable with keys but without contents that is similar to std::unordered_set.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
bool found(const Key &key) const
Return true if hashed entry is found in table.
Input from file stream, using an ISstream.
const word & name() const noexcept
Return the object name.
bool bad() const noexcept
True if stream is corrupted.
Generic input stream using a standard (STL) stream.
virtual Istream & read(token &t)
Return next token from stream.
A tuple of scalar value and key. The value often corresponds to a time value, thus the naming of the ...
scalar value() const noexcept
The value (const access)
const T & name() const noexcept
The name/key (const access)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
virtual tmp< triSurfacePointScalarField > load()
Load the cell size field.
Base functionality common to reader and writer classes.
A class for handling file names.
static std::string nameLessExt(const std::string &str)
Return basename, without extension.
bool removeExt()
Remove extension, returning true if string changed.
word ext() const
Return file name extension (part after last .)
static std::string path(const std::string &str)
Return directory path name (part before last /)
bool hasExt() const
Various checks for extensions.
virtual bool write()
Write the output fields.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
scalar print()
Print to screen.
A token holds an item read from Istream.
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ BEGIN_BLOCK
Begin block [isseparator].
@ BEGIN_SQR
Begin dimensions [isseparator].
@ COLON
Colon [isseparator].
@ END_BLOCK
End block [isseparator].
@ END_SQR
End dimensions [isseparator].
@ COMMA
Comma [isseparator].
const string & stringToken() const
Return const reference to the string contents.
punctuationToken pToken() const
Return punctuation character.
bool good() const noexcept
True if token is not UNDEFINED or ERROR.
bool isString() const noexcept
Token is string-variant (STRING, EXPRESSION, VARIABLE, VERBATIM)
scalar number() const
Return label, float or double value.
static word suffix(const fileName &file, char sep='_')
Extract the time-varying ending of files.
void sort()
Sort by time value and by file name.
bool removeNewer(const scalar timeValue)
Remove entries that are greater_equal the time value.
label scan(const fileName &seriesName, const scalar restartTime=ROOTVGREAT)
Clear contents and scan directory for files.
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
word outputName("finiteArea-edges.obj")
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static bool getValueToken(ISstream &is, token &tok)
static bool getToken(ISstream &is, token &tok)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Instant< fileName > fileNameInstant
A tuple of value and fileName.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
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.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void sort(UList< T > &list)
Sort the list.
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.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
static bool lessThan(const scalar &val, const scalar &upper)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
constexpr char nl
The newline '\n' character (0x0a)
Specialized string sorting.
Three-way comparison operation of two parameters,.
bool operator()(const fileNameInstant a, const fileNameInstant b) const
Encapsulation of natural order sorting for algorithms.
static int compare(const std::string &s1, const std::string &s2)
Natural compare for std::string.