Go to the documentation of this file.
48 void Foam::ensightCase::initialize()
58 if (
isDir(ensightDir_))
60 if (options_->overwrite())
67 <<
"Warning: re-using existing directory" <<
nl
68 <<
" " << ensightDir_ <<
endl;
79 os_->setf(ios_base::left);
88 Foam::label Foam::ensightCase::checkTimeset(
const labelHashSet& lookup)
const
102 else if (tsTimes.size() == timesUsed_.size())
106 tsTimes.erase(iter.key());
122 void Foam::ensightCase::writeHeader()
const
129 <<
"type: ensight gold" <<
nl;
134 Foam::scalar Foam::ensightCase::writeTimeset()
const
138 const labelList indices(timesUsed_.sortedToc());
139 label
count = indices.size();
142 scalar timeCorrection = timesUsed_[indices[0]];
143 if (timeCorrection < 0)
145 timeCorrection = -timeCorrection;
146 Info<<
"Correcting time values. Adding " << timeCorrection <<
endl;
155 <<
"time set: " << ts <<
nl
156 <<
"number of steps: " <<
count <<
nl;
158 if (indices[0] == 0 && indices[
count-1] ==
count-1)
162 <<
"filename start number: " << 0 <<
nl
163 <<
"filename increment: " << 1 <<
nl;
168 <<
"filename numbers:" <<
nl;
171 for (
const label idx : indices)
173 *os_ <<
' ' <<
setw(12) << idx;
175 if (++
count % 6 == 0)
188 *os_ <<
"time values:" <<
nl;
191 for (
const label idx : indices)
193 *os_ <<
' ' <<
setw(12) << timesUsed_[idx] + timeCorrection;
195 if (++
count % 6 == 0)
205 return timeCorrection;
209 void Foam::ensightCase::writeTimeset
213 const scalar timeCorrection
220 const labelList indices(hashed.sortedToc());
221 label
count = indices.size();
224 <<
"time set: " << ts <<
nl
225 <<
"number of steps: " <<
count <<
nl
226 <<
"filename numbers:" <<
nl;
229 for (
const label idx : indices)
231 *os_ <<
' ' <<
setw(12) << idx;
233 if (++
count % 6 == 0)
244 *os_ <<
"time values:" <<
nl;
247 for (
const label idx : indices)
249 *os_ <<
' ' <<
setw(12) << timesUsed_[idx] + timeCorrection;
251 if (++
count % 6 == 0)
263 void Foam::ensightCase::noteGeometry(
const bool moving)
const
267 geomTimes_.insert(timeIndex_);
271 geomTimes_.insert(-1);
278 void Foam::ensightCase::noteCloud(
const word&
cloudName)
const
285 cloudTimes_.insert(timeIndex_);
291 void Foam::ensightCase::noteCloud
295 const char* ensightType
308 <<
"Tried to add a cloud variable for writing"
309 <<
" - without having added a cloud"
315 void Foam::ensightCase::noteVariable
318 const char* ensightType
321 if (variables_.insert(varName, ensightType))
329 Foam::ensightCase::createDataFile
338 const fileName outdir = dataDir()/padded(timeIndex_);
349 Foam::ensightCase::createCloudFile
361 const fileName outdir =
379 Foam::ensightCase::ensightCase
382 const word& caseName,
388 ensightDir_(ensightDir),
389 caseName_(caseName +
".case"),
404 Foam::ensightCase::ensightCase
407 const word& caseName,
413 ensightDir_(ensightDir),
414 caseName_(caseName +
".case"),
434 setTime(value, timesUsed_.size());
454 const fileName outdir = dataDir()/padded(timeIndex_);
460 <<
"# index time" <<
nl
461 << outdir.
name() <<
' ' << timeValue_ <<
nl;
465 timesUsed_.set(index, value);
480 const bool staticGeom = (geomTimes_.size() == 1 && geomTimes_.found(-1));
481 label tsGeom = staticGeom ? 0 : checkTimeset(geomTimes_);
484 label meshIndex = -1;
487 label tsCloud = checkTimeset(cloudTimes_);
495 if (geomTimes_.size() == 1)
498 meshIndex = *(geomTimes_.begin());
503 tsCloud = 1 +
std::max(label(1), tsGeom);
510 const fileName dataMask = (dataDirName/mask());
515 if (!geomTimes_.empty() || !cloudTimes_.empty())
527 <<
setw(16) <<
"model:"
528 << (dataDirName/
word(
"constant")/geometryName).c_str()
531 else if (meshIndex >= 0)
535 <<
setw(16) <<
"model:"
536 << (dataDirName/padded(meshIndex)/geometryName).c_str()
539 else if (!geomTimes_.empty())
544 << (dataMask/geometryName).c_str()
549 const wordList cloudNames(cloudVars_.sortedToc());
562 << (masked/
"positions").c_str()
570 if (variables_.size() || cloudVars_.size())
580 const wordList varNames(variables_.sortedToc());
582 for (
const word& varName : varNames)
584 const string& ensType = variables_[varName];
590 (nodeVariables_.found(varName) || nodeValues())
594 <<
setw(15) << varName <<
' '
595 << (dataMask/varName).c_str() <<
nl;
618 const string& ensType = vars[varName];
622 << ensType.c_str() <<
" per "
625 << (
"c" +
Foam::name(cloudNo) + varName).c_str() <<
' '
626 << (masked/varName).c_str()
638 if (!timesUsed_.empty())
641 <<
nl <<
"TIME" <<
nl;
644 const scalar timeCorrection = writeTimeset();
649 writeTimeset(tsGeom, geomTimes_, timeCorrection);
655 writeTimeset(tsCloud, cloudTimes_, timeCorrection);
683 path = dataDir()/padded(timeIndex_);
692 noteGeometry(moving);
714 output().writeBinaryHeader();
731 os_->stdStream().seekp(0, std::ios_base::beg);
738 os <<
"Ensight case:" <<
nl
739 <<
" path: " << ensightDir_ <<
nl
740 <<
" name: " << caseName_ <<
nl
745 os <<
" values per node" <<
nl;
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
List< label > labelList
A List of labels.
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
static const word prefix
The prefix to local: lagrangian.
void nextTime(const scalar t)
Set time for time-set 1, using next available index.
static Ostream & output(Ostream &os, const IntRange< T > &range)
A class for handling words, derived from Foam::string.
const word cloudName(propsDict.get< word >("cloud"))
A class for handling file names.
void setTime(const scalar t, const label index)
Set current index and time for time-set 1.
Ostream & printInfo(Ostream &os) const
Print some general information.
void write() const
Write the case file.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
void rewind() const
Rewind the output stream (master only).
static bool master(const label communicator=worldComm)
Am I the master process.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void writeHeader(Ostream &os, const word &fieldName)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
Ostream & flush(Ostream &os)
Flush stream.
word format(conversionProperties.get< word >("format"))
messageStream Info
Information stream (stdout output on master, null elsewhere)
static const char * dataDirName
The name for data subdirectory: "data".
Istream and Ostream manipulators taking arguments.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
streamFormat
Data format (ascii | binary)
OBJstream os(runTime.globalPath()/outputName)
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
Omanip< int > setw(const int i)
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
IOstream & scientific(IOstream &io)
Output to file stream, using an OSstream.
A HashTable similar to std::unordered_map.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
forAllConstIters(mixture.phases(), phase)
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
scalar value() const
The value (const access)
autoPtr< ensightGeoFile > newGeometry(bool moving=false) const
Open stream for new geometry file (on master).
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Configuration options for the ensightCase.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
static word printf(const char *fmt, const PrimitiveType &val)
Use a printf-style formatter for a primitive.
autoPtr< ensightFile > newCloud(const word &cloudName) const
Open stream for new cloud positions (on master).
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,...
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static const char * geometryName
The name for geometry files: "geometry".
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?