68 while (is.
good() && (i <
n))
74 <<
"Skipping token " << tok <<
nl;
80 <<
"Requested to skip " <<
n <<
" tokens, but stream exited after "
81 << i <<
" tokens. Last token read: " << tok
94 const auto pos =
line.find(
'#');
95 if (
pos != std::string::npos)
107 const word& expected,
112 readLine(is, actual);
114 if (expected != actual)
117 <<
"Expected section header '" << expected
118 <<
"' but read " << actual <<
nl
123 <<
"Read section header: " << expected <<
nl;
142 std::ostringstream oss;
143 oss << std::setfill(
'0') << std::setw(nMask) <<
timeIndex;
145 const std::string maskStr(nMask,
'*');
146 const std::string indexStr = oss.str();
147 result.
replace(maskStr, indexStr);
166 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
170 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
174 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
176 if (buffer.find(
"ignore") != std::string::npos)
178 idHandling.
first() = idTypes::IGNORE;
180 else if (buffer.find(
"given") != std::string::npos)
182 idHandling.
first() = idTypes::GIVEN;
187 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
189 if (buffer.find(
"ignore") != std::string::npos)
191 idHandling.
second() = idTypes::IGNORE;
193 else if (buffer.find(
"given") != std::string::npos)
195 idHandling.
second() = idTypes::GIVEN;
201 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
203 if (buffer.find(
"extents") != std::string::npos)
208 discard<scalar>(6, is);
212 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
222 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
226 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
239 <<
"Cannot read file " << is.
name()
247 debugSection(
"FORMAT", is);
248 readLine(is, buffer);
250 debugSection(
"GEOMETRY", is);
251 readLine(is, buffer);
263 debugSection(
"VARIABLE", is);
271 readLine(is, buffer);
273 if (buffer ==
"TIME")
283 if (buffer.find(
':') ==
string::npos || parsed.size() < 4)
286 <<
"Error reading field file name. Current buffer: "
292 Info<<
"variable line: " << parsed.size();
293 for (
const auto&
s : parsed)
295 Info<<
" " <<
s.str();
300 fieldNames.
append(parsed[parsed.size()-2].str());
301 fieldFileNames.
append(parsed.last().str());
303 fieldNames_.transfer(fieldNames);
304 fieldFileNames_.transfer(fieldFileNames);
307 <<
"fieldNames: " << fieldNames_ <<
nl
308 <<
"fieldFileNames: " << fieldFileNames_ <<
nl;
311 readLine(is, buffer);
313 readLine(is, buffer);
314 readFromLine(3, buffer, nTimeSteps_);
315 readLine(is, buffer);
316 readFromLine(3, buffer, timeStartIndex_);
317 readLine(is, buffer);
318 readFromLine(2, buffer, timeIncrement_);
321 <<
"nTimeSteps: " << nTimeSteps_ <<
nl
322 <<
"timeStartIndex: " << timeStartIndex_ <<
nl
323 <<
"timeIncrement: " << timeIncrement_ <<
nl;
326 readLine(is, buffer);
327 timeValues_.setSize(nTimeSteps_);
328 for (label i = 0; i < nTimeSteps_; ++i)
330 scalar t(readScalar(is));
332 timeValues_[i].value() = t;
346 baseDir_(fName.
path()),
375 if (!isBinary.
good())
378 <<
"Cannot read file " << isBinary.
name()
387 string buf(
size_t(80),
'\0');
388 iss.read(&buf[0], 80);
393 buf.erase(iss.gcount());
397 const auto endp = buf.find(
'\0');
398 if (endp != std::string::npos)
406 (buf.find(
"binary") == std::string::npos)
407 && (buf.find(
"Binary") == std::string::npos)
416 Info<<
"stream format: ";
431 <<
"File: " << is.
name() <<
nl;
441 if (idHandling.
first() == idTypes::GIVEN)
444 <<
"Treating node id 'given' as being 'ignore'" <<
nl
445 <<
"If something fails, this could be the reason" <<
nl
448 idHandling.
first() = idTypes::IGNORE;
451 if (idHandling.
first() == idTypes::IGNORE)
454 <<
"Ignore " <<
nPoints <<
" node ids" <<
nl;
485 if (faceType ==
"tria3")
490 <<
"faceType <" << faceType.c_str() <<
"> count: "
495 idHandling.
second() == idTypes::IGNORE
496 || idHandling.
second() == idTypes::GIVEN
500 <<
"Ignore " << nFace <<
" element ids" <<
nl;
503 discard<label>(nFace, is);
507 for (label facei = 0; facei < nFace; ++facei)
517 else if (faceType ==
"quad4")
522 <<
"faceType <" << faceType.c_str() <<
"> count: "
527 idHandling.
second() == idTypes::IGNORE
528 || idHandling.
second() == idTypes::GIVEN
532 <<
"Ignore " << nFace <<
" element ids" <<
nl;
535 discard<label>(nFace, is);
539 for (label facei = 0; facei < nFace; ++facei)
549 else if (faceType ==
"nsided")
554 <<
"faceType <" << faceType.c_str() <<
"> count: "
559 idHandling.
second() == idTypes::IGNORE
560 || idHandling.
second() == idTypes::GIVEN
564 <<
"Ignore " << nFace <<
" element ids" <<
nl;
567 discard<label>(nFace, is);
571 for (label facei = 0; facei < nFace; ++facei)
575 for (label facei = 0; facei < nFace; ++facei)
591 <<
"Unknown face type: <" << faceType.c_str()
592 <<
">. Stopping read and continuing with current "
593 <<
"elements only" <<
endl;
600 schema_.transfer(schema);
603 <<
"read nFaces: " << faces.
size() <<
nl
604 <<
"file schema: " << schema_ <<
nl;
607 for (
face&
f : faces)
609 for (label& pointi :
f)
640 const label fieldIndex,
641 const scalar& refValue
644 return readField<scalar>(
timeIndex, fieldIndex);
651 const label fieldIndex,
655 return readField<vector>(
timeIndex, fieldIndex);
663 const label fieldIndex,
667 return readField<sphericalTensor>(
timeIndex, fieldIndex);
674 const label fieldIndex,
678 return readField<symmTensor>(
timeIndex, fieldIndex);
685 const label fieldIndex,
689 return readField<tensor>(
timeIndex, fieldIndex);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const Field< Type > & field() const
Return field.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
T & first() noexcept
The first element of the list, position [0].
Input from file stream, using an ISstream.
virtual const fileName & name() const
Read/write access to the name of the stream.
virtual std::istream & stdStream()
Access to underlying std::istream.
An IOstream is an abstract base class for all input/output systems; be they streams,...
bool good() const noexcept
True if next operation might succeed.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An ordered pair of two objects of type <T> with first() and second() elements.
const T & second() const noexcept
Return second element, which is also the last element.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
void size(const label n)
Older name for setAddressableSize.
Ensight output with specialized read() for strings, integers and floats. Correctly handles binary rea...
virtual Istream & read(char *buf, std::streamsize count)
Binary read.
Istream & readBinaryHeader()
Read "C Binary" for binary files (eg, geometry/measured)
Ensight format surface reader.
void debugSection(const word &expected, IFstream &is) const
Read and check a section header.
void skip(const label n, Istream &is) const
Helper function to skip forward n steps in stream.
static fileName replaceMask(const fileName &fName, const label timeIndex)
Replace the '*' mask chars with a 0 padded string.
virtual instantList times() const
Return a list of the available times.
Pair< idTypes > readGeometryHeader(ensightReadFile &is) const
Read (and discard) geometry file header.
void readCase(IFstream &is)
Read the case file.
void readLine(IFstream &is, string &buffer) const
Helper function to read an ascii line from file.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
static constexpr direction nComponents
Number of components in bool is 1.
virtual const wordRes & fieldNames() const noexcept
Return names of fields to probe.
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
virtual const fvGeometryScheme & geometry() const
Return reference to geometry calculation scheme.
Base class for surface readers.
A class for managing temporary objects.
A token holds an item read from Istream.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
Foam::SubStrings< StringType > splitSpace(const StringType &str)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
std::string::size_type count(const std::string &s, const char c)
Count the number of occurrences of the specified character.
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
dimensionedScalar pos(const dimensionedScalar &ds)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void discard(label n, ensightReadFile &is)
MeshedSurface< face > meshedSurface
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)