Go to the documentation of this file.
35 static const equalOp<scalar>
equalTimes(ROOTSMALL);
48 [](
const scalar a,
const scalar
b)
67 Foam::label Foam::surfaceWriters::ensightWriter::readPreviousTimes
69 const fileName& baseDir,
71 const scalar& timeValue
91 const fileName dictFile(baseDir/
dictName);
95 IFstream is(dictFile);
97 if (is.good() && cache_.
read(is))
107 meshes_.
set(geomIndices);
113 <<
"Setting geometry timeset information from time values"
114 <<
" (fieldsDict from an older OpenFOAM version)." <<
nl
115 <<
"This may not be fully reliable." <<
nl
118 for (
const scalar& meshTime : meshTimes)
121 meshes_.
set(meshIndex);
128 meshes_.
resize(times_.size());
136 int Foam::surfaceWriters::ensightWriter::geometryTimeset()
const
138 if (meshes_.count() <= 1)
144 if (meshes_.size() == times_.size() && meshes_.all())
157 Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated()
172 const word& fieldName,
195 const char* fmt =
"%08d";
196 const char* mask =
"data/********/";
200 const fileName baseDir = outputPath_;
203 const scalar timeValue = currTime_.value();
205 const fileName outputFile = baseDir / surfName +
".case";
209 Info<<
"Writing case file to " << outputFile <<
endl;
214 const bool meshChanged = (!upToDate_);
229 bool stateChanged = meshChanged;
234 ? readPreviousTimes(baseDir,
"fieldsDict", timeValue)
264 const label geomIndex(
max(0, meshes_.find_last()));
278 cache_.set(
"geometry", meshes_.sortedToc());
279 cache_.set(
"times", times_);
292 if (fieldDict.empty())
295 fieldDict.
set(
"name", varName);
304 Info<<
"Writing state file to fieldsDict" <<
endl;
308 os <<
"// Summary of Ensight fields, times" <<
nl <<
nl;
309 cache_.write(os,
false);
315 osCase.
setf(ios_base::left);
321 Info<<
"Writing case file to " << osCase.
name() <<
endl;
329 const label tsGeom = geometryTimeset();
333 <<
"type: ensight gold" <<
nl
342 <<
"model: " << tsGeom <<
" "
343 << mask << geometryName.
name() <<
nl;
350 << geometryName.c_str() <<
nl;
358 for (
const entry& dEntry : fieldsDict)
380 <<
setw(15) << varName <<
' '
381 << mask << varName <<
nl;
388 printTimeset(osCase, 1, times_);
391 printTimeset(osCase, 2, times_, meshes_);
394 osCase <<
"# end" <<
nl;
406 const fileName meshFile(baseDir/geometryName);
420 Info<<
"Writing mesh file to " << meshFile.
name() <<
endl;
442 Info<<
"Writing field file to " << osField.
name() <<
endl;
447 part.writeData(osField, tfield(), this->isPointData());
453 <<
"# timestep time" <<
nl
454 << dataDir.
name() <<
' ' << timeValue <<
nl;
A keyword and a list of tokens is an 'entry'.
List< label > labelList
A List of labels.
List< scalar > scalarList
A List of scalars.
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
scalar timeValue() const
The current time value/name.
A class for handling words, derived from Foam::string.
A class for handling file names.
virtual const fileName & name() const
Read/write access to the name of the stream.
static std::string path(const std::string &str)
Return directory path name (part before last /)
A class for managing temporary objects.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
virtual const faceList & faces() const =0
The faces used for the surface.
Abstract definition of a meshed surface defined by faces and points.
const word dictName("blockMeshDict")
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
void resize(const label nElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
virtual Ostream & writeKeyword(const keyType &key)
Conversion of OpenFOAM pTraits into the Ensight equivalent.
Specialized Ensight output with extra geometry file header.
Specification of a valid Ensight file-name.
Specification of a valid Ensight variable-name.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Generic templated field type.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
messageStream Info
Information stream (uses stdout - output is on the master only)
static const equalOp< scalar > equalTimes(ROOTSMALL)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
virtual const pointField & points() const =0
The points used for the surface.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool write(const token &)
Writing token does not make sense.
Ensight output with specialized write() for strings, integers and floats. Correctly handles binary wr...
Omanip< int > setw(const int i)
IOstream & scientific(IOstream &io)
static const fileName null
An empty fileName.
bool read(Istream &is)
Read dictionary from Istream.
Output to file stream, using an OSstream.
ios_base::fmtflags setf(const ios_base::fmtflags f)
Set flags of stream.
static bool master(const label communicator=0)
Am I the master process.
virtual int precision() const
Get precision of output field.
static label findTimeIndex(const UList< scalar > &list, const scalar val)
A variant of ensightFaces that holds references to contiguous points/faces with its own encapsulated ...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static word printf(const char *fmt, const PrimitiveType &val)
Use a printf-style formatter for a primitive.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
void clear()
Clear the dictionary.
#define WarningInFunction
Report a warning using Foam::Warning.
static const char * geometryName
The name for geometry files.
void clear()
Clear the list, i.e. set addressable size to zero.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?