47 const scalar timeValue
51 <<
"time set: " << ts <<
nl
52 <<
"number of steps: " << 1 <<
nl;
55 os <<
"filename start number: 0" <<
nl
56 <<
"filename increment: 1" <<
nl
57 <<
"time values:" <<
nl;
59 os <<
" " << timeValue
74 <<
"time set: " << ts <<
nl
75 <<
"number of steps: " << values.size() <<
nl;
78 os <<
"filename start number: 0" <<
nl
79 <<
"filename increment: 1" <<
nl;
82 os <<
"time values:" <<
nl;
84 for (
const scalar val : values)
93 os <<
' ' <<
setf(ios_base::right) <<
setw(12) << val;
113 || (indices.
size() == values.size() && indices.
all())
117 printTimeset(
os, ts, values);
124 <<
"time set: " << ts <<
nl
125 <<
"number of steps: " << indices.
count() <<
nl;
128 os <<
"filename numbers:" <<
nl;
130 for (
const label idx : indices)
139 os <<
' ' <<
setf(ios_base::right) <<
setw(8) << idx;
144 os <<
"time values:" <<
nl;
146 for (
const label idx : indices)
155 os <<
' ' <<
setf(ios_base::right) <<
setw(12) << values[idx];
165 return ensightDir_/dataDirName;
169void Foam::ensightCase::initialize()
179 if (
isDir(ensightDir_))
181 if (options_->overwrite())
188 <<
"Warning: re-using existing directory" <<
nl
189 <<
" " << ensightDir_ <<
endl;
200 os_->setf(ios_base::left);
201 os_->setf(ios_base::scientific, ios_base::floatfield);
209Foam::label Foam::ensightCase::checkTimeset(
const labelHashSet& lookup)
const
223 else if (tsTimes.size() == timesUsed_.size())
227 tsTimes.erase(iter.key());
243void Foam::ensightCase::writeHeader()
const
250 <<
"type: ensight gold" <<
nl;
255Foam::scalar Foam::ensightCase::writeTimeset()
const
259 const labelList indices(timesUsed_.sortedToc());
260 label
count = indices.size();
263 scalar timeCorrection = timesUsed_[indices[0]];
264 if (timeCorrection < 0)
266 timeCorrection = -timeCorrection;
267 Info<<
"Correcting time values. Adding " << timeCorrection <<
endl;
276 <<
"time set: " << ts <<
nl
277 <<
"number of steps: " <<
count <<
nl;
279 if (indices[0] == 0 && indices[count-1] == count-1)
283 <<
"filename start number: " << 0 <<
nl
284 <<
"filename increment: " << 1 <<
nl;
289 <<
"filename numbers:" <<
nl;
292 for (
const label idx : indices)
294 *os_ <<
' ' <<
setw(12) << idx;
296 if (++count % 6 == 0)
309 *os_ <<
"time values:" <<
nl;
312 for (
const label idx : indices)
314 *os_ <<
' ' <<
setw(12) << timesUsed_[idx] + timeCorrection;
316 if (++count % 6 == 0)
326 return timeCorrection;
330void Foam::ensightCase::writeTimeset
334 const scalar timeCorrection
341 const labelList indices(hashed.sortedToc());
342 label
count = indices.size();
345 <<
"time set: " << ts <<
nl
346 <<
"number of steps: " <<
count <<
nl
347 <<
"filename numbers:" <<
nl;
350 for (
const label idx : indices)
352 *os_ <<
' ' <<
setw(12) << idx;
354 if (++count % 6 == 0)
365 *os_ <<
"time values:" <<
nl;
368 for (
const label idx : indices)
370 *os_ <<
' ' <<
setw(12) << timesUsed_[idx] + timeCorrection;
372 if (++count % 6 == 0)
384void Foam::ensightCase::noteGeometry(
const bool moving)
const
388 geomTimes_.insert(timeIndex_);
392 geomTimes_.insert(-1);
399void Foam::ensightCase::noteCloud(
const word&
cloudName)
const
406 cloudTimes_.insert(timeIndex_);
412void Foam::ensightCase::noteCloud
416 const char* ensightType
429 <<
"Tried to add a cloud variable for writing"
430 <<
" - without having added a cloud"
436void Foam::ensightCase::noteVariable
439 const char* ensightType
442 if (variables_.insert(varName, ensightType))
450Foam::ensightCase::createDataFile
459 const fileName outdir = dataDir()/padded(timeIndex_);
470Foam::ensightCase::createCloudFile
482 const fileName outdir =
503 const word& caseName,
509 ensightDir_(ensightDir),
510 caseName_(caseName +
".case"),
528 const word& caseName,
534 ensightDir_(ensightDir),
535 caseName_(caseName +
".case"),
555 setTime(value, timesUsed_.size());
575 const fileName outdir = dataDir()/padded(timeIndex_);
581 <<
"# index time" <<
nl
582 << outdir.
name() <<
' ' << timeValue_ <<
nl;
586 timesUsed_.set(index, value);
601 const bool staticGeom = (geomTimes_.size() == 1 && geomTimes_.found(-1));
602 label tsGeom = staticGeom ? 0 : checkTimeset(geomTimes_);
605 label meshIndex = -1;
608 label tsCloud = checkTimeset(cloudTimes_);
616 if (geomTimes_.size() == 1)
619 meshIndex = *(geomTimes_.begin());
624 tsCloud = 1 + std::max(label(1), tsGeom);
631 const fileName dataMask = (dataDirName/mask());
636 if (!geomTimes_.empty() || !cloudTimes_.empty())
648 <<
setw(16) <<
"model:"
649 << (dataDirName/
word(
"constant")/geometryName).c_str()
652 else if (meshIndex >= 0)
656 <<
setw(16) <<
"model:"
657 << (dataDirName/padded(meshIndex)/geometryName).c_str()
660 else if (!geomTimes_.empty())
665 << (dataMask/geometryName).c_str()
670 const wordList cloudNames(cloudVars_.sortedToc());
683 << (masked/
"positions").c_str()
691 if (variables_.size() || cloudVars_.size())
701 const wordList varNames(variables_.sortedToc());
703 for (
const word& varName : varNames)
705 const string& ensType = variables_[varName];
711 (nodeVariables_.found(varName) || nodeValues())
715 <<
setw(15) << varName <<
' '
716 << (dataMask/varName).c_str() <<
nl;
739 const string& ensType = vars[varName];
743 << ensType.c_str() <<
" per "
746 << (
"c" +
Foam::name(cloudNo) + varName).c_str() <<
' '
747 << (masked/varName).c_str()
759 if (!timesUsed_.empty())
762 <<
nl <<
"TIME" <<
nl;
765 const scalar timeCorrection = writeTimeset();
770 writeTimeset(tsGeom, geomTimes_, timeCorrection);
776 writeTimeset(tsCloud, cloudTimes_, timeCorrection);
804 path = dataDir()/padded(timeIndex_);
813 noteGeometry(moving);
835 output().writeBinaryHeader();
852 os_->stdStream().seekp(0, std::ios_base::beg);
859 os <<
"Ensight case:" <<
nl
860 <<
" path: " << ensightDir_ <<
nl
861 <<
" name: " << caseName_ <<
nl
866 os <<
" values per node" <<
nl;
Istream and Ostream manipulators taking arguments.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
streamFormat
Data format (ascii | binary)
@ ASCII
"ascii" (normal default)
scalar value() const noexcept
The value (const access)
Output to file stream, using an OSstream.
Generic output stream using a standard (STL) stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
label size() const noexcept
Number of entries.
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...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
bool all() const
True if all bits in this bitset are set or if the set is empty.
void printInfo() const
Print general information about the mesh.
static const word prefix
The prefix to local: lagrangian.
Configuration options for the ensightCase.
Supports writing of ensight cases as well as providing common factory methods to open new files.
autoPtr< ensightFile > newCloud(const word &cloudName) const
Open stream for new cloud positions (on master).
static const char * dataDirName
The name for data subdirectory: "data".
void write() const
Write the case file.
autoPtr< ensightGeoFile > newGeometry(bool moving=false) const
Open stream for new geometry file (on master).
void setTime(const scalar t, const label index)
Set current index and time for time-set 1.
static const char * geometryName
The name for geometry files: "geometry".
void rewind() const
Rewind the output stream (master only).
void nextTime(const scalar t)
Set time for time-set 1, using next available index.
static void printTimeset(OSstream &os, const label ts, const scalar timeValue)
Print time-set for ensight case file with a single time.
A class for handling file names.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
splitCell * master() const
A class for handling words, derived from Foam::string.
static word printf(const char *fmt, const PrimitiveType &val)
Use a printf-style formatter for a primitive.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Smanip< ios_base::fmtflags > setf(const ios_base::fmtflags flags)
List< label > labelList
A List of labels.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static void writeHeader(Ostream &os, const word &fieldName)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
errorManip< error > abort(error &err)
static Ostream & output(Ostream &os, const IntRange< T > &range)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
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?
Ostream & flush(Ostream &os)
Flush stream.
constexpr char nl
The newline '\n' character (0x0a)
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
word format(conversionProperties.get< word >("format"))
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
const word cloudName(propsDict.get< word >("cloud"))