39void Foam::vtk::internalMeshWriter::beginPiece()
79void Foam::vtk::internalMeshWriter::writePoints()
90 vtuCells_.addPointCellLabels()
100 vtuCells_.addPointCellLabels()
109void 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;
189void 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();
335void 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);
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 =
575 writeCellsLegacy(pointOffset);
584 writeCellsConnectivity(pointOffset);
585 writeCellsFaces(pointOffset);
598 return enter_CellData(numberOfCells_, nFields);
604 return enter_PointData(numberOfPoints_, nFields);
610 if (isState(outputState::CELL_DATA))
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();
656 if (isState(outputState::POINT_DATA))
663 <<
" for pointID field" <<
nl <<
endl
668 this->beginDataArray<label>(
"pointID", numberOfPoints_);
671 const label pointOffset =
677 const label cellOffset =
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.
A class for handling file names.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label localStart() const
My local start.
Mesh consisting of general polyhedral cells.
Base class for VTK output writers that handle geometry and fields (eg, vtp, vtu data)....
bool legacy() const noexcept
Commonly used query.
autoPtr< vtk::formatter > format_
The VTK formatter in use (only valid on master process)
bool parallel_
Parallel writing (via master)
bool parallel() const noexcept
Parallel output requested?
vtk::outputOptions opts_
Requested output options.
virtual bool open(const fileName &file, bool parallel=Pstream::parRun())
Open file for writing (creates parent directory).
virtual bool beginFile(std::string title="")
Write file header (non-collective)
vtk::formatter & format()
The VTK formatter in use. FatalError for off-processor.
Write an OpenFOAM volume (internal) geometry and internal fields as a vtu file or a legacy vtk file.
void writePointIDs()
Write point ids as PointData.
label numberOfPoints_
The number of field points for the current Piece.
label numberOfCells_
The number of field cells for the current Piece.
bool writeProcIDs()
Write processor ids as CellData. This is no-op in serial.
static int debug
Debug information.
virtual bool writeGeometry()
Write mesh topology.
virtual bool beginFile(std::string title="")
Write file header (non-collective)
const vtuCells & vtuCells_
The volume cells (internalMesh)
void writeCellIDs()
Write cell ids as CellData.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
bool append() const noexcept
True if output format uses an append mode.
A deep-copy description of an OpenFOAM volume mesh in data structures suitable for VTK UnstructuredGr...
static labelList copyFaceLabelsXml(const labelUList &faceLabels, const label globalPointOffset)
Copy faces stream labels with a global point offset - XML format.
static labelList copyFaceOffsetsXml(const labelUList &faceOffsets, const label prevOffset)
Copy face offsets with an offset from previous - XML format.
static labelList copyVertLabelsXml(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - XML format.
static labelList copyVertLabelsLegacy(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - legacy format.
label nFieldPoints() const noexcept
Number of field points = nPoints + nAddPoints.
label nFieldCells() const noexcept
Number of field cells = nCells + nAddCells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define PoutInFunction
Report using Foam::Pout with FUNCTION_NAME prefix.
#define DebugInFunction
Report an information message using Foam::Info.
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
@ NUMBER_OF_CELLS
"NumberOfCells"
@ NUMBER_OF_POINTS
"NumberOfPoints"
@ FACEOFFSETS
"faceoffsets"
@ CONNECTIVITY
"connectivity"
fileTag
Some common XML tags for vtk files.
@ UNSTRUCTURED_GRID
"UnstructuredGrid"
void writeListsParallel(vtk::formatter &fmt, const UList< Type > &values1, const UList< Type > &values2)
Write a list of values and another list of values.
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 writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
word format(conversionProperties.get< word >("format"))
const labelList & cellTypes