69 while (is.good() && (i <
n))
75 <<
"Skipping token " << tok <<
nl;
81 <<
"Requested to skip " <<
n <<
" tokens, but stream exited after " 82 << i <<
" tokens. Last token read: " << tok
95 const auto pos = line.find(
'#');
96 if (
pos != std::string::npos)
102 while (
line.empty() && is.good());
108 const word& expected,
113 readLine(is, actual);
115 if (expected != actual)
118 <<
"Expected section header '" << expected
119 <<
"' but read " << actual <<
nl 124 <<
"Read section header: " << expected <<
nl;
143 const std::string maskStr(nMask,
'*');
145 result.
replace(maskStr, indexStr);
156 is.readBinaryHeader();
160 Pair<idTypes> idHandling(idTypes::NONE, idTypes::NONE);
164 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
168 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
172 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
174 if (buffer.contains(
"ignore"))
176 idHandling.first() = idTypes::IGNORE;
178 else if (buffer.contains(
"given"))
180 idHandling.first() = idTypes::GIVEN;
185 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
187 if (buffer.contains(
"ignore"))
189 idHandling.second() = idTypes::IGNORE;
191 else if (buffer.contains(
"given"))
193 idHandling.second() = idTypes::GIVEN;
199 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
201 if (buffer.contains(
"extents"))
206 discard<scalar>(6, is);
210 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
220 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
224 DebugInfo<<
"buffer [" << buffer.length() <<
"] " << buffer <<
nl;
237 <<
"Cannot read file " << is.
name()
245 debugSection(
"FORMAT", is);
246 readLine(is, buffer);
248 debugSection(
"GEOMETRY", is);
249 readLine(is, buffer);
261 debugSection(
"VARIABLE", is);
264 DynamicList<word> fieldNames(16);
265 DynamicList<string> fieldFileNames(16);
269 readLine(is, buffer);
271 if (buffer ==
"TIME")
281 if (!buffer.contains(
':') || parsed.size() < 4)
284 <<
"Error reading field file name. Current buffer: " 290 Info<<
"variable line: " << parsed.size();
291 for (
const auto&
s : parsed)
293 Info<<
" " <<
s.str();
298 fieldNames.append(parsed[parsed.size()-2].str());
299 fieldFileNames.append(parsed.last().str());
301 fieldNames_.transfer(fieldNames);
302 fieldFileNames_.transfer(fieldFileNames);
305 <<
"fieldNames: " << fieldNames_ <<
nl 306 <<
"fieldFileNames: " << fieldFileNames_ <<
nl;
309 readLine(is, buffer);
311 readLine(is, buffer);
312 readFromLine(3, buffer, nTimeSteps_);
313 readLine(is, buffer);
314 readFromLine(3, buffer, timeStartIndex_);
315 readLine(is, buffer);
316 readFromLine(2, buffer, timeIncrement_);
319 <<
"nTimeSteps: " << nTimeSteps_ <<
nl 320 <<
"timeStartIndex: " << timeStartIndex_ <<
nl 321 <<
"timeIncrement: " << timeIncrement_ <<
nl;
324 readLine(is, buffer);
325 timeValues_.resize_nocopy(nTimeSteps_);
326 for (label i = 0; i < nTimeSteps_; ++i)
328 scalar t(readScalar(is));
330 timeValues_[i].value() = t;
342 const fileName& fName,
343 const dictionary& options
346 surfaceReader(fName, options),
350 && options.getOrDefault(
"masterOnly", false)
352 readFormat_(IOstreamOption::ASCII),
353 baseDir_(fName.
path()),
363 if (options.getOrDefault(
"debug",
false))
395 const fileName& geometryFile
402 ensightReadFile is(geometryFile);
405 readFormat_ = is.format();
408 <<
"File: " << is.name()
412 Pair<idTypes> idHandling = readGeometryHeader(is);
420 if (idHandling.first() == idTypes::GIVEN)
423 <<
"Treating node id 'given' as being 'ignore'" <<
nl 424 <<
"If something fails, this could be the reason" <<
nl 427 idHandling.first() = idTypes::IGNORE;
430 if (idHandling.first() == idTypes::IGNORE)
433 <<
"Ignore " <<
nPoints <<
" node ids" <<
nl;
440 for (
direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
450 DynamicList<face> dynFaces(
nPoints/3);
451 DynamicList<faceInfoTuple> faceTypeInfo(16);
476 faceInfoTuple(ensightFaces::elemType::TRIA3, faceCount)
480 <<
"faceType <" << faceType.c_str() <<
"> count: " 485 idHandling.second() == idTypes::IGNORE
486 || idHandling.second() == idTypes::GIVEN
490 <<
"Ignore " << faceCount <<
" element ids" <<
nl;
493 discard<label>(faceCount, is);
496 for (label facei = 0; facei < faceCount; ++facei)
504 dynFaces.append(std::move(
f));
517 faceInfoTuple(ensightFaces::elemType::QUAD4, faceCount)
521 <<
"faceType <" << faceType.c_str() <<
"> count: " 526 idHandling.second() == idTypes::IGNORE
527 || idHandling.second() == idTypes::GIVEN
531 <<
"Ignore " << faceCount <<
" element ids" <<
nl;
534 discard<label>(faceCount, is);
537 for (label facei = 0; facei < faceCount; ++facei)
545 dynFaces.append(std::move(
f));
558 faceInfoTuple(ensightFaces::elemType::NSIDED, faceCount)
562 <<
"faceType <" << faceType.c_str() <<
"> count: " 567 idHandling.second() == idTypes::IGNORE
568 || idHandling.second() == idTypes::GIVEN
572 <<
"Ignore " << faceCount <<
" element ids" <<
nl;
575 discard<label>(faceCount, is);
579 for (label facei = 0; facei < faceCount; ++facei)
583 for (label facei = 0; facei < faceCount; ++facei)
591 dynFaces.append(std::move(
f));
599 <<
"Unknown face type: <" << faceType.c_str()
600 <<
">. Stopping read and continuing with current " 601 <<
"elements only" <<
endl;
608 for (face&
f : dynFaces)
616 faceTypeInfo_.transfer(faceTypeInfo);
617 faceList faces(std::move(dynFaces));
620 <<
"read nFaces: " << faces.size() <<
nl 621 <<
"file schema: " << faceTypeInfo_ <<
nl;
638 auto& surf = *surfPtr_;
640 fileName geomFile(baseDir_/replaceMask(meshFileName_,
timeIndex));
644 surf = readGeometry(geomFile);
676 const label fieldIndex,
677 const scalar& refValue
680 return readField<scalar>(
timeIndex, fieldIndex);
687 const label fieldIndex,
691 return readField<vector>(
timeIndex, fieldIndex);
699 const label fieldIndex,
703 return readField<sphericalTensor>(
timeIndex, fieldIndex);
710 const label fieldIndex,
714 return readField<symmTensor>(
timeIndex, fieldIndex);
721 const label fieldIndex,
725 return readField<tensor>(
timeIndex, fieldIndex);
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
Replace first occurrence of sub-string s1 with s2, beginning at pos.
virtual wordList fieldNames(const label timeIndex) const
Return a list of the available fields at a given time.
A class for handling file names.
virtual const fileName & name() const
The name of the input serial stream. (eg, the name of the Fstream file name)
errorManipArg< error, int > exit(error &err, const int errNo=1)
static word padded(const int nwidth, const label value)
Stringified zero-padded integer value.
static const char * elemNames[nTypes]
The ensight 'Face' element type names.
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.
instantList timeValues_
Times.
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.
constexpr char nl
The newline '\n' character (0x0a)
static const Enum< streamFormat > formatNames
Stream format names (ascii, binary)
List< face > faceList
A List of faces.
List< string > fieldFileNames_
Field file names.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
bool masterOnly_
Read on master and broadcast (in parallel)
List< word > fieldNames_
Field names.
static label worldComm
Default world communicator (all processors). May differ from globalComm if local worlds are in use...
void readLine(ISstream &is, string &buffer) const
Helper function to read an ascii line from file.
Macros for easy insertion into run-time selection tables.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
fileName meshFileName_
Name of mesh file, including any subdirectory.
dimensionedScalar pos(const dimensionedScalar &ds)
void debugSection(const word &expected, ISstream &is) const
Read and check a section header.
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
ensightSurfaceReader(const fileName &fName, const dictionary &options=dictionary())
Construct from fileName, with reader options.
vectorField pointField
pointField is a vectorField.
An ordered pair of two objects of type <T> with first() and second() elements.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
MeshedSurface< face > meshedSurface
#define DebugInFunction
Report an information message using Foam::Info.
A variant of IFstream with specialised read() for strings, integers and floats. Correctly handles bin...
static void discard(label n, ensightReadFile &is)
void skip(const label n, Istream &is) const
Helper function to skip forward n steps in stream.
#define DebugInfo
Report an information message using Foam::Info.
label timeStartIndex_
Start time index.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
label timeIncrement_
Time increment.
defineTypeNameAndDebug(combustionModel, 0)
label nTimeSteps_
Number of time steps.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::SubStrings< StringType > splitSpace(const StringType &str)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all processes in communicator.
virtual instantList times() const
Return a list of the available times.
Generic input stream using a standard (STL) stream.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
bool good() const noexcept
True if next operation might succeed.
virtual Istream & read(char *buf, std::streamsize count)
Binary read.
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.
static bool master(const label communicator=worldComm)
Am I the master rank.
std::string::size_type count(const std::string &s, const char c)
Count the number of occurrences of the specified character.
void readCase(ISstream &is)
Read the case file.
static fileName replaceMask(const fileName &fName, const label timeIndex)
Replace the '*' mask chars with a 0 padded string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
A class for managing temporary objects.
meshedSurface readGeometry(const fileName &geometryFile)
Read and return surface geometry. Updates faceTypeInfo_.
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))
Tensor of scalars, i.e. Tensor<scalar>.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...