55 iss.read(reinterpret_cast<char*>(&value),
sizeof(Type));
72 auto& iss = is.stdStream();
75 value.resize(80,
'\0');
76 iss.read(&value[0], 80);
77 const std::streamsize gcount = iss.gcount();
78 value.erase(gcount <= 0 ? 0 : gcount);
83 const auto endp = value.find(
'\0');
85 if (endp != std::string::npos)
98 while (value.empty() && !is.eof())
135 const auto curr_pos = iss.tellg();
146 const auto end_pos = iss.tellg();
170 int64_t footer_begin(0);
172 const auto endp = buffer.find(
"FILE_INDEX");
174 if (endp == std::string::npos)
199 footer_begin = getPrimitive<int64_t>(is);
208 iss.seekg(footer_begin);
209 nSteps = getPrimitive<int32_t>(is);
215 for (int32_t step = 0; step < nSteps; ++step)
217 offsets[step] = getPrimitive<int64_t>(is);
231 void Foam::ensightReadFile::readString(std::string& value)
237 void Foam::ensightReadFile::init(
bool detectFormat)
246 auto& iss = stdStream();
248 auto lineNum = lineNumber();
249 auto curr_pos = iss.tellg();
261 if (buffer.contains(
"Binary") || buffer.contains(
"binary"))
267 curr_pos = iss.tellg();
293 if (buffer.starts_with(
"BEGIN TIME STEP"))
298 curr_pos = iss.tellg();
300 timeStepFooterBegin_ = getTimeStepFooter(*
this, timeStepOffsets_);
302 if (timeStepOffsets_.empty())
305 timeStepOffsets_.resize(1, int64_t(curr_pos));
316 timeStepFooterBegin_ = -1;
317 timeStepOffsets_.clear();
320 DebugInfo<<
"Time-steps: " << timeStepOffsets_.size() <<
endl;
328 Foam::ensightReadFile::ensightReadFile
334 timeStepFooterBegin_(-1)
340 Foam::ensightReadFile::ensightReadFile
347 timeStepFooterBegin_(-1)
359 std::streamsize
count 386 value = getPrimitive<int>(*this);
393 value = getPrimitive<float>(*this);
400 value = getPrimitive<float>(*this);
438 List<doubleVector>&
points 462 auto& iss = stdStream();
471 <<
" offset:" << label(timeStepOffsets_[
timeIndex]) <<
nl;
static void readEnsightString(IFstream &is, std::string &value)
virtual Istream & read(char *buf, std::streamsize count) override
Binary read.
A class for handling file names.
bool seekTime(const label timeIndex)
Transient single-file: seek to the file position corresponding to the given time index.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void readPoints(const label nPoints, List< floatVector > &points)
Component-wise reading of points/coordinates. Read all x components, y components and z components...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
void syncState()
Set stream state to match that of the std::istream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
A simple container for options an IOstream can normally have.
static Type getPrimitive(IFstream &is)
bool read(const char *buf, int32_t &val)
Same as readInt32.
registerDebugSwitchWithName(Foam::ensightReadFile, ensight, "ensightReadFile")
int64_t readInt64(Istream &is)
Read int64_t from stream.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
virtual Istream & read(token &)=0
Return next token from stream.
void clear()
Clear the list, i.e. set size to zero.
A variant of IFstream with specialised handling for Ensight reading of strings, integers and floats (...
virtual const fileName & name() const override
The name of the input serial stream. (eg, the name of the Fstream file name)
#define DebugInfo
Report an information message using Foam::Info.
static int64_t getTimeStepFooter(IFstream &is, List< int64_t > &offsets)
Extract time step footer information (if any).
virtual std::istream & stdStream() override
Access to underlying std::istream.
int debug
Static debugging option.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
defineDebugSwitchWithName(Foam::ensightReadFile, "ensightReadFile", 0)
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
Istream & readKeyword(string &key)
Read element keyword. Currently the same as read(string)
label lineNumber() const noexcept
Const access to the current stream line number.
static bool split(const std::string &line, std::string &key, std::string &val)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Macro definitions for debug switches.
bool good() const noexcept
True if next operation might succeed.
streamFormat
Data format (ascii | binary)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::SubStrings< StringType > splitSpace(const StringType &str, std::string::size_type pos=0)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
streamFormat format() const noexcept
Get the current stream format.