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;
138 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
142 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
146 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
148 if (buffer.find(
"ignore") != std::string::npos)
150 idHandling.first() = idTypes::IGNORE;
152 else if (buffer.find(
"given") != std::string::npos)
154 idHandling.first() = idTypes::GIVEN;
159 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
161 if (buffer.find(
"ignore") != std::string::npos)
163 idHandling.
second() = idTypes::IGNORE;
165 else if (buffer.find(
"given") != std::string::npos)
167 idHandling.
second() = idTypes::GIVEN;
173 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
175 if (buffer.find(
"extents") != std::string::npos)
180 discard<scalar>(6, is);
184 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
194 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
198 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
211 <<
"Cannot read file " << is.
name()
219 debugSection(
"FORMAT", is);
220 readLine(is, buffer);
222 debugSection(
"GEOMETRY", is);
223 readLine(is, buffer);
233 debugSection(
"VARIABLE", is);
241 readLine(is, buffer);
243 if (buffer ==
"TIME")
253 if (buffer.find(
':') == string::npos || parsed.size() < 4)
256 <<
"Error reading field file name. Current buffer: "
262 Info<<
"variable line: " << parsed.size();
263 for (
const auto&
s : parsed)
265 Info<<
" " <<
s.str();
270 fieldNames.
append(parsed[parsed.size()-2].str());
271 fieldFileNames.
append(parsed.last().str());
273 fieldNames_.transfer(fieldNames);
274 fieldFileNames_.transfer(fieldFileNames);
277 <<
"fieldNames: " << fieldNames_ <<
nl
278 <<
"fieldFileNames: " << fieldFileNames_ <<
nl;
281 readLine(is, buffer);
283 readLine(is, buffer);
284 readFromLine(3, buffer, nTimeSteps_);
285 readLine(is, buffer);
286 readFromLine(3, buffer, timeStartIndex_);
287 readLine(is, buffer);
288 readFromLine(2, buffer, timeIncrement_);
291 <<
"nTimeSteps: " << nTimeSteps_ <<
nl
292 <<
"timeStartIndex: " << timeStartIndex_ <<
nl
293 <<
"timeIncrement: " << timeIncrement_ <<
nl;
296 readLine(is, buffer);
297 timeValues_.setSize(nTimeSteps_);
298 for (
label i = 0; i < nTimeSteps_; ++i)
300 scalar t(readScalar(is));
302 timeValues_[i].value() = t;
316 baseDir_(fName.
path()),
337 if (!surfPtr_.valid())
341 if (!isBinary.
good())
344 <<
"Cannot read file " << isBinary.
name()
353 string buf(
size_t(80),
'\0');
354 iss.read(&buf[0], 80);
359 buf.erase(iss.gcount());
363 const auto endp = buf.find(
'\0');
364 if (endp != std::string::npos)
372 (buf.find(
"binary") == std::string::npos)
373 && (buf.find(
"Binary") == std::string::npos)
382 Info<<
"stream format: ";
397 <<
"File: " << is.
name() <<
nl;
407 if (idHandling.first() == idTypes::GIVEN)
410 <<
"Treating node id 'given' as being 'ignore'" <<
nl
411 <<
"If something fails, this could be the reason" <<
nl
414 idHandling.first() = idTypes::IGNORE;
417 if (idHandling.first() == idTypes::IGNORE)
420 <<
"Ignore " <<
nPoints <<
" node ids" <<
nl;
451 if (faceType ==
"tria3")
456 <<
"faceType <" << faceType.c_str() <<
"> count: "
461 idHandling.
second() == idTypes::IGNORE
462 || idHandling.
second() == idTypes::GIVEN
466 <<
"Ignore " << nFace <<
" element ids" <<
nl;
469 discard<label>(nFace, is);
473 for (
label facei = 0; facei < nFace; ++facei)
483 else if (faceType ==
"quad4")
488 <<
"faceType <" << faceType.c_str() <<
"> count: "
493 idHandling.
second() == idTypes::IGNORE
494 || idHandling.
second() == idTypes::GIVEN
498 <<
"Ignore " << nFace <<
" element ids" <<
nl;
501 discard<label>(nFace, is);
505 for (
label facei = 0; facei < nFace; ++facei)
515 else if (faceType ==
"nsided")
520 <<
"faceType <" << faceType.c_str() <<
"> count: "
525 idHandling.
second() == idTypes::IGNORE
526 || idHandling.
second() == idTypes::GIVEN
530 <<
"Ignore " << nFace <<
" element ids" <<
nl;
533 discard<label>(nFace, is);
537 for (
label facei = 0; facei < nFace; ++facei)
541 for (
label facei = 0; facei < nFace; ++facei)
557 <<
"Unknown face type: <" << faceType.c_str()
558 <<
">. Stopping read and continuing with current "
559 <<
"elements only" <<
endl;
566 schema_.transfer(schema);
569 <<
"read nFaces: " << faces.size() <<
nl
570 <<
"file schema: " << schema_ <<
nl;
573 for (
face&
f : faces)
606 const label fieldIndex,
607 const scalar& refValue
610 return readField<scalar>(
timeIndex, fieldIndex);
617 const label fieldIndex,
621 return readField<vector>(
timeIndex, fieldIndex);
629 const label fieldIndex,
633 return readField<sphericalTensor>(
timeIndex, fieldIndex);
640 const label fieldIndex,
644 return readField<symmTensor>(
timeIndex, fieldIndex);
651 const label fieldIndex,
655 return readField<tensor>(
timeIndex, fieldIndex);
int debug
Static debugging option.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
const T & second() const noexcept
Return second element, which is also the last element.
label ListType::const_reference val
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 into a string function.
A class for handling file names.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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.
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.
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
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.
virtual const meshedSurface & geometry()
Return a reference to the surface geometry.
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)