40 return 2 * edges.
size();
47 label nConnectivity = 0;
49 for (
const face&
f : faces)
51 nConnectivity +=
f.
size();
62void Foam::vtk::polyWriter::beginPiece
100void 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;
138void Foam::vtk::polyWriter::writePoints
159void 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();
227void 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);
323 parallel_ ? globalIndex(nLocalConns).localStart() : 0
327 auto iter = vertOffsets.begin();
329 for (
const edge&
e : edges)
361void 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)
429void 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);
524 parallel_ ? globalIndex(nLocalConns).localStart() : 0
528 auto iter = vertOffsets.begin();
530 for (
const face&
f : faces)
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.
A face is a list of labels corresponding to mesh vertices.
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.
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).
vtk::formatter & format()
The VTK formatter in use. FatalError for off-processor.
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.
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
label nLocalLines_
Local number of lines (edges)
label nLocalPolys_
Local number of polys (faces)
bool writeLineGeometry(const pointField &points, const edgeList &edges)
bool writePolyGeometry(const pointField &points, const faceList &faces)
label numberOfPoints_
The number of field points for the current Piece.
label nLocalPoints_
Local number of points.
label nLocalVerts_
Local number of vertices (points)
label numberOfCells_
The number of field cells (edges or faces) for the current Piece.
virtual bool writeGeometry()
Dummy write mesh topology method - Fatal if called.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void beginPolys(std::ostream &os, label nPolys, label nConnectivity)
Emit header for POLYGONS (with trailing newline).
void beginLines(std::ostream &os, label nLines, label nConnectivity=0)
Emit header for LINES (with trailing newline).
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
@ NUMBER_OF_POLYS
"NumberOfPolys"
@ NUMBER_OF_LINES
"NumberOfLines"
@ NUMBER_OF_POINTS
"NumberOfPoints"
@ CONNECTIVITY
"connectivity"
fileTag
Some common XML tags for vtk files.
formatType
The output format type for file contents.
@ INLINE_BASE64
XML inline base64, base64Formatter.
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.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
static label countConnectivity(const edgeList &edges)
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)
errorManip< error > abort(error &err)
List< edge > edgeList
A List of edges.
List< face > faceList
A List of faces.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
word format(conversionProperties.get< word >("format"))