Go to the documentation of this file.
53 void Foam::ensightCase::initialize()
63 if (
isDir(ensightDir_))
65 if (options_->overwrite())
72 <<
"Warning: re-using existing directory" <<
nl
73 <<
" " << ensightDir_ <<
endl;
84 os_->setf(ios_base::left);
107 else if (tsTimes.size() == timesUsed_.size())
111 tsTimes.erase(iter.key());
127 void Foam::ensightCase::writeHeader()
const
134 <<
"type: ensight gold" <<
nl;
139 Foam::scalar Foam::ensightCase::writeTimeset()
const
143 const labelList indices(timesUsed_.sortedToc());
147 scalar timeCorrection = timesUsed_[indices[0]];
148 if (timeCorrection < 0)
150 timeCorrection = -timeCorrection;
151 Info<<
"Correcting time values. Adding " << timeCorrection <<
endl;
160 <<
"time set: " << ts <<
nl
161 <<
"number of steps: " <<
count <<
nl;
163 if (indices[0] == 0 && indices[
count-1] ==
count-1)
167 <<
"filename start number: " << 0 <<
nl
168 <<
"filename increment: " << 1 <<
nl;
173 <<
"filename numbers:" <<
nl;
176 for (
const label idx : indices)
178 *os_ <<
' ' <<
setw(12) << idx;
180 if (++
count % 6 == 0)
193 *os_ <<
"time values:" <<
nl;
196 for (
const label idx : indices)
198 *os_ <<
' ' <<
setw(12) << timesUsed_[idx] + timeCorrection;
200 if (++
count % 6 == 0)
210 return timeCorrection;
214 void Foam::ensightCase::writeTimeset
218 const scalar timeCorrection
225 const labelList indices(hashed.sortedToc());
229 <<
"time set: " << ts <<
nl
230 <<
"number of steps: " <<
count <<
nl
231 <<
"filename numbers:" <<
nl;
234 for (
const label idx : indices)
236 *os_ <<
' ' <<
setw(12) << idx;
238 if (++
count % 6 == 0)
249 *os_ <<
"time values:" <<
nl;
252 for (
const label idx : indices)
254 *os_ <<
' ' <<
setw(12) << timesUsed_[idx] + timeCorrection;
256 if (++
count % 6 == 0)
268 void Foam::ensightCase::noteGeometry(
const bool moving)
const
272 geomTimes_.insert(timeIndex_);
276 geomTimes_.insert(-1);
283 void Foam::ensightCase::noteCloud(
const word&
cloudName)
const
287 cloudVars_.insert(
cloudName, HashTable<string>());
289 cloudTimes_.insert(timeIndex_);
295 void Foam::ensightCase::noteCloud
299 const char* ensightType
312 <<
"Tried to add a cloud variable for writing"
313 <<
" - without having added a cloud"
319 void Foam::ensightCase::noteVariable
322 const char* ensightType
325 if (variables_.insert(varName, ensightType))
333 Foam::ensightCase::createDataFile
342 const fileName outdir = dataDir()/padded(timeIndex_);
353 Foam::ensightCase::createCloudFile
365 const fileName outdir =
383 Foam::ensightCase::ensightCase
386 const word& caseName,
391 ensightDir_(ensightDir),
392 caseName_(caseName +
".case"),
407 Foam::ensightCase::ensightCase
410 const word& caseName,
415 ensightDir_(ensightDir),
416 caseName_(caseName +
".case"),
445 setTime(value, timesUsed_.size());
465 const fileName outdir = dataDir()/padded(timeIndex_);
471 <<
"# index time" <<
nl
472 << outdir.
name() <<
' ' << timeValue_ <<
nl;
476 timesUsed_.set(index, value);
491 const bool staticGeom = (geomTimes_.size() == 1 && geomTimes_.found(-1));
492 label tsGeom = staticGeom ? 0 : checkTimeset(geomTimes_);
495 label meshIndex = -1;
498 label tsCloud = checkTimeset(cloudTimes_);
506 if (geomTimes_.size() == 1)
509 meshIndex = *(geomTimes_.begin());
521 const fileName dataMask = (dataDirName/mask());
526 if (!geomTimes_.empty() || !cloudTimes_.empty())
538 <<
setw(16) <<
"model:"
542 else if (meshIndex >= 0)
546 <<
setw(16) <<
"model:"
547 << (dataDirName/padded(meshIndex)/geometryName).c_str()
550 else if (!geomTimes_.empty())
555 << (dataMask/geometryName).c_str()
573 << (masked/
"positions").c_str()
581 if (variables_.size() || cloudVars_.size())
591 const wordList varNames(variables_.sortedToc());
593 for (
const word& varName : varNames)
595 const string& ensType = variables_[varName];
605 <<
setw(15) << varName <<
' '
606 << (dataMask/varName).c_str() <<
nl;
629 const string& ensType = vars[varName];
633 << ensType.c_str() <<
" per "
636 << (
"c" +
Foam::name(cloudNo) + varName).c_str() <<
' '
637 << (masked/varName).c_str()
649 if (!timesUsed_.empty())
652 <<
nl <<
"TIME" <<
nl;
655 const scalar timeCorrection = writeTimeset();
660 writeTimeset(tsGeom, geomTimes_, timeCorrection);
666 writeTimeset(tsCloud, cloudTimes_, timeCorrection);
694 path = dataDir()/padded(timeIndex_);
703 noteGeometry(moving);
722 output = createCloudFile(
cloudName,
"positions");
725 output().writeBinaryHeader();
742 os_->stdStream().seekp(0, std::ios_base::beg);
749 os <<
"Ensight case:" <<
nl
750 <<
" path: " << ensightDir_ <<
nl
751 <<
" name: " << caseName_ <<
nl
753 <<
" values per " << (nodeValues() ?
"node" :
"element") <<
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.
~ensightCase()
Destructor.
void nextTime(const scalar t)
Set time for time-set 1, using next available index.
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.
Template functions to aid in the implementation of demand driven data.
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).
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void writeHeader(Ostream &os, const word &fieldName)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
void deleteDemandDrivenData(DataPtr &dataPtr)
Ostream & flush(Ostream &os)
Flush stream.
word format(conversionProperties.get< word >("format"))
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
const cellModel * lookup(const word &modelName)
Deprecated(2017-11) equivalent to cellModel::ptr static method.
static const char * dataDirName
The name for "data" subdirectory.
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)
const wordList cloudNames(cloudFields.sortedToc())
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.
static bool master(const label communicator=0)
Am I the master process.
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 dirctory 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)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Configuration options for the ensightCase.
autoPtr< ensightGeoFile > newGeometry(const bool moving=false) const
Open stream for new geometry file (on master).
static word printf(const char *fmt, const PrimitiveType &val)
Use a printf-style formatter for a primitive.
Operations on lists of strings.
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 with label keys and 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.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?