Go to the documentation of this file.
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;
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();
301 fieldFileNames.
append(parsed.last().str());
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);
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 append(const T &val)
Append an element at the end of the list.
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.
bool good() const noexcept
True if next operation might succeed.
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 (stdout output on master, null elsewhere)
#define DebugInFunction
Report an information message using Foam::Info.
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.
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
Macros for easy insertion into run-time selection tables.
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())
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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.
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)