40 return 2 * edges.
size();
47 label nConnectivity = 0;
49 for (
const face&
f : faces)
51 nConnectivity +=
f.
size();
62 void Foam::vtk::polyWriter::beginPiece
100 void Foam::vtk::polyWriter::beginPiece
107 nLocalPoints_ =
points.size();
110 nLocalPolys_ = faces.size();
112 numberOfPoints_ = nLocalPoints_;
113 numberOfCells_ = nLocalPolys_;
117 reduce(numberOfPoints_, sumOp<label>());
118 reduce(numberOfCells_, sumOp<label>());
123 if (legacy())
return;
138 void Foam::vtk::polyWriter::writePoints
159 void Foam::vtk::polyWriter::writeLinesLegacy
162 const label pointOffset
168 label nLines = nLocalLines_;
169 label nConns = nLocalConns;
173 reduce(nLines, sumOp<label>());
174 reduce(nConns, sumOp<label>());
177 if (nLines != numberOfCells_)
180 <<
"Expecting " << numberOfCells_
181 <<
" edges, but found " << nLines
187 labelList vertLabels(nLocalLines_ + nLocalConns);
193 auto iter = vertLabels.begin();
195 const label off = pointOffset;
197 for (
const edge&
e : edges)
202 *iter = off +
e.first();
205 *iter = off +
e.second();
227 void Foam::vtk::polyWriter::writeLines
230 const label pointOffset
247 label nConns = nLocalConns;
251 reduce(nConns, sumOp<label>());
256 const uint64_t payLoad = vtk::sizeofData<label>(nConns);
259 format().writeSize(payLoad *
sizeof(label));
266 auto iter = vertLabels.begin();
268 const label off = pointOffset;
270 for (
const edge&
e : edges)
273 *iter = off +
e.first();
276 *iter = off +
e.second();
304 label nOffs = vertOffsets.size();
308 reduce(nOffs, sumOp<label>());
313 const uint64_t payLoad = vtk::sizeofData<label>(nOffs);
316 format().writeSize(payLoad);
327 auto iter = vertOffsets.begin();
329 for (
const edge&
e : edges)
361 void Foam::vtk::polyWriter::writePolysLegacy
364 const label pointOffset
370 label nPolys = nLocalPolys_;
371 label nConns = nLocalConns;
375 reduce(nPolys, sumOp<label>());
376 reduce(nConns, sumOp<label>());
379 if (nPolys != numberOfCells_)
382 <<
"Expecting " << numberOfCells_
383 <<
" faces, but found " << nPolys
389 labelList vertLabels(nLocalPolys_ + nLocalConns);
395 auto iter = vertLabels.begin();
397 const label off = pointOffset;
399 for (
const face&
f : faces)
404 for (
const label
id :
f)
429 void Foam::vtk::polyWriter::writePolys
432 const label pointOffset
449 label nConns = nLocalConns;
453 reduce(nConns, sumOp<label>());
458 const uint64_t payLoad = vtk::sizeofData<label>(nConns);
461 format().writeSize(payLoad *
sizeof(label));
468 auto iter = vertLabels.begin();
470 label off = pointOffset;
472 for (
const face&
f : faces)
474 for (
const label
id :
f)
505 label nOffs = vertOffsets.size();
509 reduce(nOffs, sumOp<label>());
514 const uint64_t payLoad = vtk::sizeofData<label>(nOffs);
517 format().writeSize(payLoad);
528 auto iter = vertOffsets.begin();
530 for (
const face&
f : faces)
564 Foam::vtk::polyWriter::polyWriter
569 vtk::fileWriter(vtk::
fileTag::POLY_DATA, opts),
582 Foam::vtk::polyWriter::polyWriter
591 open(file, parallel);
595 Foam::vtk::polyWriter::polyWriter
604 open(file, parallel);
613 <<
"Method was not overloaded, called without a geometry!!" <<
nl 614 <<
" Indicates a programming error" <<
nl <<
endl 629 beginPiece(
points, edges);
633 const label pointOffset =
640 writeLinesLegacy(edges, pointOffset);
644 writeLines(edges, pointOffset);
659 beginPiece(
points, faces);
663 const label pointOffset =
670 writePolysLegacy(faces, pointOffset);
674 writePolys(faces, pointOffset);
683 return enter_CellData(numberOfCells_, nFields);
689 return enter_PointData(numberOfPoints_, nFields);
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.
label nLocalVerts_
Local number of vertices (points)
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...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
constexpr char nl
The newline '\n' character (0x0a)
virtual bool writeGeometry()
Dummy write mesh topology method - Fatal if called.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void beginPolys(std::ostream &os, label nPolys, label nConnectivity)
Emit header for POLYGONS (with trailing newline).
label numberOfPoints_
The number of field points for the current Piece.
bool parallel_
Parallel writing (via master)
bool legacy() const noexcept
Commonly used query.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
List< face > faceList
List of faces.
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
label nLocalLines_
Local number of lines (edges)
virtual bool beginPointData(label nFields=0)
Begin PointData for specified number of fields.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
formatType
The output format type for file contents.
label nLocalPoints_
Local number of points.
errorManip< error > abort(error &err)
void beginLines(std::ostream &os, label nLines, label nConnectivity=0)
Emit header for LINES (with trailing newline).
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
word format(conversionProperties.get< word >("format"))
fileTag
Some common XML tags for vtk files.
bool writePolyGeometry(const pointField &points, const faceList &faces)
Low-level write face/point topology. Normally used by writeGeometry() in a derived class...
label nLocalPolys_
Local number of polys (faces)
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
XML inline base64, base64Formatter.
bool writeLineGeometry(const pointField &points, const edgeList &edges)
Low-level write edge/point topology. Normally used by writeGeometry() in a derived class...
List< label > labelList
A List of labels.
static label countConnectivity(const edgeList &edges)
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).
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.
label numberOfCells_
The number of field cells (edges or faces) for the current Piece.