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.last()
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
340 label nFaceLabels = vtuCells_.faceLabels().size();
344 reduce(nFaceLabels, sumOp<label>());
358 const labelList& faceLabels = vtuCells_.faceLabels();
365 const uint64_t payLoad =
366 vtk::sizeofData<label>(nFaceLabels);
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();
434 const globalIndex procOffset(faceLabels.size());
438 if (faceOffsets.size())
440 faceOffsetsRenumber =
444 procOffset.localStart()
449 faceOffsetsRenumber.
resize(nLocalCells, -1);
471 Foam::vtk::internalMeshWriter::internalMeshWriter
478 vtk::fileWriter(vtk::
fileTag::UNSTRUCTURED_GRID, opts),
490 Foam::vtk::internalMeshWriter::internalMeshWriter
500 open(file, parallel);
504 Foam::vtk::internalMeshWriter::internalMeshWriter
515 open(file, parallel);
531 <<
"case=" << mesh_.time().caseName()
532 <<
" region=" << mesh_.name()
533 <<
" time=" << mesh_.time().timeName()
534 <<
" index=" << mesh_.time().timeIndex() <<
endl;
541 mesh_.time().globalCaseName()
550 "case='" + mesh_.time().globalCaseName()
551 +
"' region='" + mesh_.name()
552 +
"' time='" + mesh_.time().timeName()
553 +
"' index='" +
Foam::name(mesh_.time().timeIndex())
568 const label pointOffset =
570 parallel_ ?
globalIndex(vtuCells_.nFieldPoints()).localStart() : 0
575 writeCellsLegacy(pointOffset);
584 writeCellsConnectivity(pointOffset);
585 writeCellsFaces(pointOffset);
598 return enter_CellData(numberOfCells_, nFields);
604 return enter_PointData(numberOfPoints_, nFields);
617 <<
" for cellID field" <<
nl <<
endl 621 const labelList& cellMap = vtuCells_.cellMap();
624 this->beginDataArray<label>(
"cellID", numberOfCells_);
629 const globalIndex globalCellOffset(vtuCells_.nFieldCells());
638 this->endDataArray();
663 <<
" for pointID field" <<
nl <<
endl 668 this->beginDataArray<label>(
"pointID", numberOfPoints_);
671 const label pointOffset =
673 parallel_ ? globalIndex(vtuCells_.nPoints()).localStart() : 0
677 const label cellOffset =
679 parallel_ ? globalIndex(vtuCells_.nCells()).localStart() : 0
686 label pointi = vtuCells_.nPoints();
687 for (
const label celli : vtuCells_.addPointCellLabels())
689 pointIds[pointi] = (-1 - celli - cellOffset);
702 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.
void resize(const label len)
Adjust allocated size of list.
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.
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).
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
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 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)
bool writeProcIDs(const label nValues)
Write nValues of processor ids as CellData (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 reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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.
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 writeCellIDs()
Write cell ids as CellData.