39 void Foam::vtk::internalMeshWriter::beginPiece()
79 void Foam::vtk::internalMeshWriter::writePoints()
90 vtuCells_.addPointCellLabels()
100 vtuCells_.addPointCellLabels()
109 void Foam::vtk::internalMeshWriter::writeCellsLegacy(
const label pointOffset)
111 const List<uint8_t>&
cellTypes = vtuCells_.cellTypes();
112 const labelList& vertLabels = vtuCells_.vertLabels();
115 label nVerts = vertLabels.size();
119 reduce(nCells, sumOp<label>());
120 reduce(nVerts, sumOp<label>());
123 if (nCells != numberOfCells_)
126 <<
"Expecting " << numberOfCells_
127 <<
" cells, but found " << nCells
137 <<
"CELLS " << nCells <<
' ' << nVerts <<
nl;
169 <<
"CELL_TYPES " << nCells <<
nl;
189 void Foam::vtk::internalMeshWriter::writeCellsConnectivity
191 const label pointOffset
198 const labelList& vertLabels = vtuCells_.vertLabels();
199 label nVerts = vertLabels.
size();
203 reduce(nVerts, sumOp<label>());
208 const uint64_t payLoad = vtk::sizeofData<label>(nVerts);
211 format().writeSize(payLoad);
243 const labelList& vertOffsets = vtuCells_.vertOffsets();
244 label nOffs = vertOffsets.
size();
248 reduce(nOffs, sumOp<label>());
253 const uint64_t payLoad =
254 vtk::sizeofData<label>(nOffs);
257 format().writeSize(payLoad);
263 const globalIndex procOffset
265 vertOffsets.empty() ? 0 : vertOffsets.back()
287 const List<uint8_t>&
cellTypes = vtuCells_.cellTypes();
292 reduce(nCells, sumOp<label>());
295 if (nCells != numberOfCells_)
298 <<
"Expecting " << numberOfCells_
299 <<
" cells, but found " << nCells
305 const uint64_t payLoad =
306 vtk::sizeofData<uint8_t>(nCells);
309 format().writeSize(payLoad);
320 checkFormatterValidity();
335 void Foam::vtk::internalMeshWriter::writeCellsFaces
337 const label pointOffset
365 const uint64_t payLoad =
369 format().writeSize(payLoad);
409 const labelList& faceOffsets = vtuCells_.faceOffsets();
410 const label nLocalCells = vtuCells_.cellTypes().
size();
412 label nCells = nLocalCells;
416 reduce(nCells, sumOp<label>());
421 const uint64_t payLoad =
422 vtk::sizeofData<label>(nCells);
425 format().writeSize(payLoad);
431 const List<uint8_t>&
cellTypes = vtuCells_.cellTypes();
432 const label nLocalCells =
cellTypes.size();
435 const label labelsOffset =
440 if (faceOffsets.size())
442 faceOffsetsRenumber =
451 faceOffsetsRenumber.resize(nLocalCells, -1);
473 Foam::vtk::internalMeshWriter::internalMeshWriter
480 vtk::fileWriter(vtk::
fileTag::UNSTRUCTURED_GRID, opts),
492 Foam::vtk::internalMeshWriter::internalMeshWriter
502 open(file, parallel);
506 Foam::vtk::internalMeshWriter::internalMeshWriter
517 open(file, parallel);
533 <<
"case=" << mesh_.time().caseName()
534 <<
" region=" << mesh_.name()
535 <<
" time=" << mesh_.time().timeName()
536 <<
" index=" << mesh_.time().timeIndex() <<
endl;
543 mesh_.time().globalCaseName()
552 "case='" + mesh_.time().globalCaseName()
553 +
"' region='" + mesh_.name()
554 +
"' time='" + mesh_.time().timeName()
555 +
"' index='" +
Foam::name(mesh_.time().timeIndex())
570 const label pointOffset =
577 writeCellsLegacy(pointOffset);
586 writeCellsConnectivity(pointOffset);
587 writeCellsFaces(pointOffset);
600 return enter_CellData(numberOfCells_, nFields);
606 return enter_PointData(numberOfPoints_, nFields);
619 <<
" for cellID field" <<
nl <<
endl 623 const labelList& cellMap = vtuCells_.cellMap();
626 this->beginDataArray<label>(
"cellID", numberOfCells_);
631 const globalIndex globalCellOffset(vtuCells_.nFieldCells());
640 this->endDataArray();
665 <<
" for pointID field" <<
nl <<
endl 670 this->beginDataArray<label>(
"pointID", numberOfPoints_);
673 const label pointOffset =
679 const label cellOffset =
688 label pointi = vtuCells_.nPoints();
689 for (
const label celli : vtuCells_.addPointCellLabels())
691 pointIds[pointi] = (-1 - celli - cellOffset);
704 this->endDataArray();
void size(const label n)
Older name for setAddressableSize.
autoPtr< vtk::formatter > format_
The VTK formatter in use (only valid on master process)
A class for handling file names.
void writeLists(vtk::formatter &fmt, const UList< Type > &values1, const UList< Type > &values2, const labelUList &addressing)
Write a list of values and a list of values via indirect addressing.
void writePointIDs()
Write point ids as PointData.
errorManipArg< error, int > exit(error &err, const int errNo=1)
vtk::formatter & format()
The VTK formatter in use. FatalError for off-processor.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
static int debug
Debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void writeListsParallel(vtk::formatter &fmt, const UList< Type > &values1, const UList< Type > &values2)
Write a list of values and another list of values.
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
label nFieldPoints() const noexcept
Number of field points = nPoints + nAddPoints.
virtual bool beginPointData(label nFields=0)
Begin PointData for specified number of fields.
labelList faceLabels(nFaceLabels)
bool parallel_
Parallel writing (via master)
bool writeProcIDs()
Write processor ids as CellData. This is no-op in serial.
bool legacy() const noexcept
Commonly used query.
const vtuCells & vtuCells_
The volume cells (internalMesh)
label numberOfPoints_
The number of field points for the current Piece.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
label numberOfCells_
The number of field cells for the current Piece.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
static labelList copyFaceLabelsXml(const labelUList &faceLabels, const label globalPointOffset)
Copy faces stream labels with a global point offset - XML format.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
bool writeProcIDs(const label nValues)
Write nValues of processor ids as CellData or PointData (no-op in serial)
#define DebugInFunction
Report an information message using Foam::Info.
static labelList copyVertLabelsLegacy(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - legacy format.
const labelList & cellTypes
static labelList copyVertLabelsXml(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - XML format.
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
label nFieldCells() const noexcept
Number of field cells = nCells + nAddCells.
Write an OpenFOAM volume (internal) geometry and internal fields as a vtu file or a legacy vtk file...
word format(conversionProperties.get< word >("format"))
virtual bool beginFile(std::string title="")
Write file header (non-collective)
fileTag
Some common XML tags for vtk files.
static labelList copyFaceOffsetsXml(const labelUList &faceOffsets, const label prevOffset)
Copy face offsets with an offset from previous - XML format.
#define PoutInFunction
Report using Foam::Pout with FUNCTION_NAME prefix.
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
virtual bool writeGeometry()
Write mesh topology.
static label calcOffset(const label localSize, const label comm=UPstream::worldComm, const bool checkOverflow=false)
Calculate globally-consistent local start offset based on the local input size(s).
virtual bool beginFile(std::string title="")
Write file header (non-collective)
A deep-copy description of an OpenFOAM volume mesh in data structures suitable for VTK UnstructuredGr...
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
void writeCellIDs()
Write cell ids as CellData.