Go to the documentation of this file.
67 while (is.
good() && (i <
n))
73 <<
"Skipping token " << tok <<
nl;
79 <<
"Requested to skip " <<
n <<
" tokens, but stream exited after "
80 << i <<
" tokens. Last token read: " << tok
93 const auto pos =
line.find(
'#');
94 if (
pos != std::string::npos)
106 const word& expected,
111 readLine(is, actual);
113 if (expected != actual)
116 <<
"Expected section header '" << expected
117 <<
"' but read " << actual <<
nl
122 <<
"Read section header: " << expected <<
nl;
141 std::ostringstream oss;
144 const std::string maskStr(nMask,
'*');
145 const std::string indexStr = oss.str();
146 result.
replace(maskStr, indexStr);
165 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
169 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
173 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
175 if (buffer.find(
"ignore") != std::string::npos)
177 idHandling.first() = idTypes::IGNORE;
179 else if (buffer.find(
"given") != std::string::npos)
181 idHandling.first() = idTypes::GIVEN;
186 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
188 if (buffer.find(
"ignore") != std::string::npos)
190 idHandling.
second() = idTypes::IGNORE;
192 else if (buffer.find(
"given") != std::string::npos)
194 idHandling.
second() = idTypes::GIVEN;
200 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
202 if (buffer.find(
"extents") != std::string::npos)
207 discard<scalar>(6, is);
211 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
221 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
225 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
238 <<
"Cannot read file " << is.
name()
246 debugSection(
"FORMAT", is);
247 readLine(is, buffer);
249 debugSection(
"GEOMETRY", is);
250 readLine(is, buffer);
262 debugSection(
"VARIABLE", is);
270 readLine(is, buffer);
272 if (buffer ==
"TIME")
282 if (buffer.find(
':') == string::npos || parsed.size() < 4)
285 <<
"Error reading field file name. Current buffer: "
291 Info<<
"variable line: " << parsed.size();
292 for (
const auto&
s : parsed)
294 Info<<
" " <<
s.str();
299 fieldNames.
append(parsed[parsed.size()-2].str());
300 fieldFileNames.
append(parsed.last().str());
302 fieldNames_.transfer(fieldNames);
303 fieldFileNames_.transfer(fieldFileNames);
306 <<
"fieldNames: " << fieldNames_ <<
nl
307 <<
"fieldFileNames: " << fieldFileNames_ <<
nl;
310 readLine(is, buffer);
312 readLine(is, buffer);
313 readFromLine(3, buffer, nTimeSteps_);
314 readLine(is, buffer);
315 readFromLine(3, buffer, timeStartIndex_);
316 readLine(is, buffer);
317 readFromLine(2, buffer, timeIncrement_);
320 <<
"nTimeSteps: " << nTimeSteps_ <<
nl
321 <<
"timeStartIndex: " << timeStartIndex_ <<
nl
322 <<
"timeIncrement: " << timeIncrement_ <<
nl;
325 readLine(is, buffer);
326 timeValues_.setSize(nTimeSteps_);
327 for (label i = 0; i < nTimeSteps_; ++i)
329 scalar t(readScalar(is));
331 timeValues_[i].value() = t;
345 baseDir_(fName.
path()),
374 if (!isBinary.
good())
377 <<
"Cannot read file " << isBinary.
name()
386 string buf(
size_t(80),
'\0');
387 iss.read(&buf[0], 80);
392 buf.erase(iss.gcount());
396 const auto endp = buf.find(
'\0');
397 if (endp != std::string::npos)
405 (buf.find(
"binary") == std::string::npos)
406 && (buf.find(
"Binary") == std::string::npos)
415 Info<<
"stream format: ";
430 <<
"File: " << is.
name() <<
nl;
440 if (idHandling.first() == idTypes::GIVEN)
443 <<
"Treating node id 'given' as being 'ignore'" <<
nl
444 <<
"If something fails, this could be the reason" <<
nl
447 idHandling.first() = idTypes::IGNORE;
450 if (idHandling.first() == idTypes::IGNORE)
453 <<
"Ignore " <<
nPoints <<
" node ids" <<
nl;
484 if (faceType ==
"tria3")
489 <<
"faceType <" << faceType.c_str() <<
"> count: "
494 idHandling.
second() == idTypes::IGNORE
495 || idHandling.
second() == idTypes::GIVEN
499 <<
"Ignore " << nFace <<
" element ids" <<
nl;
502 discard<label>(nFace, is);
506 for (label facei = 0; facei < nFace; ++facei)
516 else if (faceType ==
"quad4")
521 <<
"faceType <" << faceType.c_str() <<
"> count: "
526 idHandling.
second() == idTypes::IGNORE
527 || idHandling.
second() == idTypes::GIVEN
531 <<
"Ignore " << nFace <<
" element ids" <<
nl;
534 discard<label>(nFace, is);
538 for (label facei = 0; facei < nFace; ++facei)
548 else if (faceType ==
"nsided")
553 <<
"faceType <" << faceType.c_str() <<
"> count: "
558 idHandling.
second() == idTypes::IGNORE
559 || idHandling.
second() == idTypes::GIVEN
563 <<
"Ignore " << nFace <<
" element ids" <<
nl;
566 discard<label>(nFace, is);
570 for (label facei = 0; facei < nFace; ++facei)
574 for (label facei = 0; facei < nFace; ++facei)
590 <<
"Unknown face type: <" << faceType.c_str()
591 <<
">. Stopping read and continuing with current "
592 <<
"elements only" <<
endl;
599 schema_.transfer(schema);
602 <<
"read nFaces: " << faces.size() <<
nl
603 <<
"file schema: " << schema_ <<
nl;
606 for (
face&
f : faces)
608 for (label& pointi :
f)
639 const label fieldIndex,
640 const scalar& refValue
643 return readField<scalar>(
timeIndex, fieldIndex);
650 const label fieldIndex,
654 return readField<vector>(
timeIndex, fieldIndex);
662 const label fieldIndex,
666 return readField<sphericalTensor>(
timeIndex, fieldIndex);
673 const label fieldIndex,
677 return readField<symmTensor>(
timeIndex, fieldIndex);
684 const label fieldIndex,
688 return readField<tensor>(
timeIndex, fieldIndex);
int debug
Static debugging option.
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
const T & second() const noexcept
Return second element, which is also the last element.
Base class for surface readers.
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
A class for handling words, derived from Foam::string.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
A class for handling file names.
static fileName replaceMask(const fileName &fName, const label timeIndex)
Replace the '*' mask chars with a 0 padded string.
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))
A class for managing temporary objects.
Input from file stream, using an ISstream.
virtual const fileName & name() const
Read/write access to the name of the stream.
void skip(const label n, Istream &is) const
Helper function to skip forward n steps in stream.
void readLine(IFstream &is, string &buffer) const
Helper function to read an ascii line from file.
An IOstream is an abstract base class for all input/output systems; be they streams,...
void readCase(IFstream &is)
Read the case file.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
Foam::SubStrings< StringType > splitSpace(const StringType &str)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
virtual wordList fieldNames(const label timeIndex) const
Return a list of the available fields at a given time.
ensightSurfaceReader(const fileName &fName)
Construct from fileName.
virtual instantList times() const
Return a list of the available times.
Ensight output with specialized read() for strings, integers and floats. Correctly handles binary rea...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
messageStream Info
Information stream (uses stdout - output is on the master only)
#define DebugInFunction
Report an information message using Foam::Info.
word name(const complex &c)
Return string representation of complex.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
virtual const meshedSurface & geometry(const label timeIndex)
Return a reference to the surface geometry.
Pair< idTypes > readGeometryHeader(ensightReadFile &is) const
Read (and discard) geometry file header.
void debugSection(const word &expected, IFstream &is) const
Read and check a section header.
Omanip< int > setw(const int i)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Istream & readBinaryHeader()
Read "C Binary" for binary files (eg, geometry/measured)
virtual std::istream & stdStream()
Access to underlying std::istream.
static void discard(label n, ensightReadFile &is)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
An ordered pair of two objects of type <T> with first() and second() elements.
MeshedSurface< face > meshedSurface
Omanip< char > setfill(char fillch)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
A face is a list of labels corresponding to mesh vertices.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
std::string::size_type count(const std::string &s, const char c)
Count the number of occurrences of the specified character.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
virtual tmp< Field< scalar > > field(const label timeIndex, const label fieldIndex, const scalar &refValue=pTraits< scalar >::zero) const
Return a scalar field at a given time.
bool good() const
Return true if next operation might succeed.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
virtual Istream & read(char *buf, std::streamsize count)
Binary read.
static constexpr direction nComponents
Number of components in this vector space.
dimensionedScalar pos(const dimensionedScalar &ds)