38bool Foam::ensightFile::allowUndef_ =
false;
59 auto& oss =
os.stdStream();
63 oss.write(
reinterpret_cast<const char*
>(&value),
sizeof(Type));
67 oss.width(fieldWidth);
80 for (
const float val :
field)
94 for (
const double val :
field)
108void Foam::ensightFile::init()
113 std::ios_base::scientific,
114 std::ios_base::floatfield
124 oss.seekp(0, std::ios_base::end);
125 origFileSize_ = oss.tellp();
132 int64_t begin_footer(-1);
150 timeStepOffsets_ = std::move(offsets);
154 oss.seekp(begin_footer);
167Foam::ensightFile::ensightFile
198Foam::ensightFile::ensightFile
215Foam::ensightFile::ensightFile
257 bool old = allowUndef_;
268 float old = undefValue_;
280 if (len > 80) len = 80;
284 std::copy_n(str, len, buf);
285 std::fill_n(buf + len, (80 - len),
'\0');
287 auto& oss = stdStream();
345 std::streamsize count
429 writeString(key +
" undef");
448 writeString(
"C Binary");
472 if (timeStepOffsets_.empty())
480 const int64_t footer_begin(oss.tellp());
487 for (int64_t off : timeStepOffsets_)
509 oss.seekp(footer_begin);
521 writeString(
"BEGIN TIME STEP");
526 const int64_t curr_pos(oss.tellp());
527 timeStepOffsets_.push_back(curr_pos);
532 if (curr_pos >= 0 && curr_pos < origFileSize_)
534 const char fill[] =
"deadbeef";
538 int64_t
pos = curr_pos;
539 pos < origFileSize_ && bool(oss);
580 const std::string& description
591 writeString(
"coordinates");
610 for (
const label val : list)
620 for (
const label val :
field)
630 for (
const float val :
field)
647 for (
const double val :
field)
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
A simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
streamFormat
Data format (ascii | binary | coherent).
@ ASCII
"ascii" (normal default)
appendType
File appending (NO_APPEND | APPEND_APP | APPEND_ATE).
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
virtual const fileName & name() const override
Read/write access to the name of the stream.
bool is_appending() const noexcept
True if opened in append mode and file already existed.
virtual const std::ostream & stdStream() const override
Const access to underlying std::ostream.
virtual char fill() const override
Get the current padding character.
void syncState()
Set stream state to match that of the std::ostream.
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.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A variant of OFstream with specialised handling for Ensight writing of strings, integers and floats (...
void writeUndef()
Write undef value.
void writeString(const char *str, size_t len)
Write character/string content as "%79s" or as binary (max 80 chars).
int64_t writeTimeStepFooter()
Transient single-file: write the time-step file-offsets as footer information.
int64_t beginTimeStep()
Write "BEGIN TIME STEP" string and newline (for transient single-file format).
static bool allowUndef() noexcept
Return setting for whether 'undef' values are allowed in results.
static const char *const coordinates
The keyword "coordinates".
virtual bool write(const token &) override
Writing token does not make sense.
void writeBinaryHeader()
Write "C Binary" string for binary files (eg, geometry/measured).
void beginCoordinates(const label nparticles)
Begin a "coordinates" block. Only used for geometry files.
void beginPart(const label index)
Begin a part (0-based index internally).
int64_t endTimeStep()
Write "END TIME STEP" string and newline (for transient single-file format).
void writeList(const UList< label > &field)
Write a list of integers as float values.
void writeLabels(const UList< label > &list)
Write a list of integers.
static float undefValue(float value) noexcept
Assign the value to represent undef in the results.
void beginParticleCoordinates(const label nparticles)
Begin a "particle coordinates" block (measured data).
virtual Ostream & writeKeyword(const keyType &key) override
Write element keyword with trailing newline, optionally with undef and the value for undefined.
static bool hasUndef(const UList< float > &field)
Check for any NaN in the field.
void writeFloat(const float val, const int fieldWidth)
Write floating-point with specified width or as binary.
void newline()
Add carriage return to ascii stream.
void writeInt(const int32_t val, const int fieldWidth)
Write integer value with specified width or as binary.
~ensightFile()
Destructor. Commits the time-step footer information (if any).
static int64_t getTimeStepFooter(IFstream &is, List< int64_t > &offsets)
Extract time step footer information (if any).
A class for handling file names.
A class for handling keywords in dictionaries.
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
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))))
dimensionedScalar pos(const dimensionedScalar &ds)
constexpr floatScalar floatScalarVGREAT
Smanip< std::ios_base::fmtflags > setf(std::ios_base::fmtflags flags)
static void putPrimitive(const Type &value, OFstream &os, const int fieldWidth)
constexpr int32_t narrowInt32(const int64_t val) noexcept
Type narrowing from int64_t to int32_t.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
constexpr float narrowFloat(const double val) noexcept
Type narrowing from double to float.
word format(conversionProperties.get< word >("format"))