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
99 void Foam::vtk::polyWriter::beginPiece
106 nLocalPoints_ =
points.size();
108 nLocalPolys_ = faces.size();
110 numberOfPoints_ = nLocalPoints_;
111 numberOfCells_ = nLocalPolys_;
115 reduce(numberOfPoints_, sumOp<label>());
116 reduce(numberOfCells_, sumOp<label>());
121 if (legacy())
return;
136 void Foam::vtk::polyWriter::writePoints
157 void Foam::vtk::polyWriter::writeLinesLegacy
160 const label pointOffset
166 label nLines = nLocalLines_;
167 label nConns = nLocalConns;
171 reduce(nLines, sumOp<label>());
172 reduce(nConns, sumOp<label>());
175 if (nLines != numberOfCells_)
178 <<
"Expecting " << numberOfCells_
179 <<
" edges, but found " << nLines
185 labelList vertLabels(nLocalLines_ + nLocalConns);
191 auto iter = vertLabels.begin();
193 const label off = pointOffset;
195 for (
const edge&
e : edges)
200 *iter = off +
e.first();
203 *iter = off +
e.second();
225 void Foam::vtk::polyWriter::writeLines
228 const label pointOffset
245 label nConns = nLocalConns;
249 reduce(nConns, sumOp<label>());
254 const uint64_t payLoad = vtk::sizeofData<label>(nConns);
257 format().writeSize(payLoad *
sizeof(label));
264 auto iter = vertLabels.begin();
266 const label off = pointOffset;
268 for (
const edge&
e : edges)
271 *iter = off +
e.first();
274 *iter = off +
e.second();
302 label nOffs = vertOffsets.size();
306 reduce(nOffs, sumOp<label>());
311 const uint64_t payLoad = vtk::sizeofData<label>(nOffs);
314 format().writeSize(payLoad);
321 parallel_ ? globalIndex(nLocalConns).localStart() : 0
325 auto iter = vertOffsets.begin();
327 for (
const edge&
e : edges)
359 void Foam::vtk::polyWriter::writePolysLegacy
362 const label pointOffset
368 label nPolys = nLocalPolys_;
369 label nConns = nLocalConns;
373 reduce(nPolys, sumOp<label>());
374 reduce(nConns, sumOp<label>());
377 if (nPolys != numberOfCells_)
380 <<
"Expecting " << numberOfCells_
381 <<
" faces, but found " << nPolys
387 labelList vertLabels(nLocalPolys_ + nLocalConns);
393 auto iter = vertLabels.begin();
395 const label off = pointOffset;
397 for (
const face&
f : faces)
402 for (
const label
id :
f)
427 void Foam::vtk::polyWriter::writePolys
430 const label pointOffset
447 label nConns = nLocalConns;
451 reduce(nConns, sumOp<label>());
456 const uint64_t payLoad = vtk::sizeofData<label>(nConns);
459 format().writeSize(payLoad *
sizeof(label));
466 auto iter = vertLabels.begin();
468 label off = pointOffset;
470 for (
const face&
f : faces)
472 for (
const label
id :
f)
503 label nOffs = vertOffsets.size();
507 reduce(nOffs, sumOp<label>());
512 const uint64_t payLoad = vtk::sizeofData<label>(nOffs);
515 format().writeSize(payLoad);
522 parallel_ ? globalIndex(nLocalConns).localStart() : 0
526 auto iter = vertOffsets.begin();
528 for (
const face&
f : faces)
562 Foam::vtk::polyWriter::polyWriter
567 vtk::fileWriter(vtk::
fileTag::POLY_DATA, opts),
579 Foam::vtk::polyWriter::polyWriter
588 open(file, parallel);
592 Foam::vtk::polyWriter::polyWriter
601 open(file, parallel);
610 <<
"Method was not overloaded, called without a geometry!!" <<
nl
611 <<
" Indicates a programming error" <<
nl <<
endl
626 beginPiece(
points, edges);
630 const label pointOffset =
637 writeLinesLegacy(edges, pointOffset);
641 writeLines(edges, pointOffset);
656 beginPiece(
points, faces);
660 const label pointOffset =
667 writePolysLegacy(faces, pointOffset);
671 writePolys(faces, pointOffset);
680 return enter_CellData(numberOfCells_, nFields);
686 return enter_PointData(numberOfPoints_, nFields);