Go to the documentation of this file.
34 void Foam::vtk::patchWriter::beginPiece()
39 nLocalPoints_ = nLocalFaces_ = nLocalVerts_ = 0;
45 nLocalPoints_ += pp.nPoints();
46 nLocalFaces_ += pp.size();
48 for (
const face&
f : pp)
50 nLocalVerts_ +=
f.size();
54 numberOfPoints_ = nLocalPoints_;
55 numberOfCells_ = nLocalFaces_;
59 reduce(numberOfPoints_, sumOp<label>());
60 reduce(numberOfCells_, sumOp<label>());
81 void Foam::vtk::patchWriter::writePoints()
83 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
93 const uint64_t payLoad =
94 vtk::sizeofData<float, 3>(numberOfPoints_);
100 format().writeSize(payLoad);
156 toMaster << pp.localPoints();
176 void Foam::vtk::patchWriter::writePolysLegacy(
const label pointOffset)
178 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
182 label nFaces = nLocalFaces_;
183 label nVerts = nLocalVerts_;
187 reduce(nFaces, sumOp<label>());
188 reduce(nVerts, sumOp<label>());
191 if (nFaces != numberOfCells_)
194 <<
"Expecting " << numberOfCells_
195 <<
" faces, but found " << nFaces
201 labelList vertLabels(nLocalFaces_ + nLocalVerts_);
207 auto iter = vertLabels.begin();
209 label off = pointOffset;
215 for (
const face&
f : pp.localFaces())
247 void Foam::vtk::patchWriter::writePolys(
const label pointOffset)
254 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
262 label nVerts = nLocalVerts_;
266 reduce(nVerts, sumOp<label>());
271 const uint64_t payLoad =
272 vtk::sizeofData<label>(nVerts);
275 format().writeSize(payLoad);
282 auto iter = vertLabels.begin();
284 label off = pointOffset;
290 for (
const face&
f : pp.localFaces())
325 label nOffs = vertOffsets.size();
329 reduce(nOffs, sumOp<label>());
334 const uint64_t payLoad =
335 vtk::sizeofData<label>(nOffs);
338 format().writeSize(payLoad);
345 parallel_ ? globalIndex(nLocalVerts_).localStart() : 0
349 auto iter = vertOffsets.begin();
355 for (
const face&
f : pp)
390 Foam::vtk::patchWriter::patchWriter
395 const bool useNearCellValue
401 useNearCellValue_(useNearCellValue),
413 Foam::vtk::patchWriter::patchWriter
423 open(file, parallel);
427 Foam::vtk::patchWriter::patchWriter
438 open(file, parallel);
442 Foam::vtk::patchWriter::patchWriter
447 const bool useNearCellValue,
454 open(file, parallel);
473 patchIDs_.size() == 1
474 ? mesh_.boundaryMesh()[patchIDs_.first()].name()
484 if (patchIDs_.size() == 1)
488 "patch='" + mesh_.boundaryMesh()[patchIDs_.first()].name() +
"'"
495 "npatches='" +
Foam::name(patchIDs_.size()) +
"'"
501 " time='" + mesh_.time().timeName()
502 +
"' index='" +
Foam::name(mesh_.time().timeIndex())
518 const label pointOffset =
525 writePolysLegacy(pointOffset);
529 writePolys(pointOffset);
538 return enter_CellData(numberOfCells_, nFields);
544 return enter_PointData(numberOfPoints_, nFields);
557 <<
"Bad writer state (" << stateNames[state_]
559 <<
") for patchID field" <<
nl <<
endl
565 label nFaces = nLocalFaces_;
576 legacy::intField<1>(
format(),
"patchID", nFaces);
580 const uint64_t payLoad =
581 vtk::sizeofData<label>(nFaces);
584 format().writeSize(payLoad);
615 for (
label i=0; i < recv.size(); i += 2)
617 const label len = recv[i];
678 <<
"Bad writer state (" << stateNames[state_]
680 <<
") for patchID field" <<
nl <<
endl
684 label nFaces = nLocalFaces_;
695 legacy::intField<1>(
format(),
"procID", nFaces);
699 const uint64_t payLoad =
700 vtk::sizeofData<label>(nFaces);
703 format().writeSize(payLoad);
758 <<
"Bad writer state (" << stateNames[state_]
760 <<
") for patchID field" <<
nl <<
endl
766 label nFaces = nLocalFaces_;
777 legacy::intField<1>(
format(),
"neighID", nFaces);
781 const uint64_t payLoad =
782 vtk::sizeofData<label>(nFaces);
785 format().writeSize(payLoad);
797 const label val = (pp ? pp->neighbProcNo() : -1);
824 for (
label i=0; i < recv.size(); i += 2)
826 const label len = recv[i];
851 send[i+1] = (pp ? pp->neighbProcNo() : -1);
Encapsulated combinations of output format options. This is primarily useful when defining the output...
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
void writeListParallel(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
label ListType::const_reference val
Base class for VTK output writers that handle geometry and fields (eg, vtp, vtu data)....
static constexpr int masterNo() noexcept
Process index of the master.
bool legacy() const
Commonly used query.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label localStart() const
My local start.
Output inter-processor communications stream.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
void beginPolys(std::ostream &os, label nPolys, label nConnectivity)
Emit header for POLYGONS (with trailing newline).
label localSize() const
My local size.
virtual bool beginPointData(label nFields=0)
Begin PointData for specified number of fields.
virtual bool beginFile(std::string title="")
Write file header (non-collective)
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
autoPtr< vtk::formatter > format_
The VTK formatter in use (master process)
virtual bool writeGeometry()
Write patch topology.
word format(conversionProperties.get< word >("format"))
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static int lastSlave(const label communicator=0)
Process index of last slave.
word name(const complex &c)
Return string representation of complex.
bool writeNeighIDs()
Write processor neighbour ids as CellData. This is no-op in serial.
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
bool parallel_
Writing in parallel (via master)
Mesh data needed to do the Finite Volume discretisation.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Write OpenFOAM patches and patch fields in VTP or legacy vtk format.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static bool master(const label communicator=0)
Am I the master process.
static constexpr int firstSlave() noexcept
Process index of first slave.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
void writePatchIDs()
Write patch ids as CellData.
const polyBoundaryMesh & patches
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Input inter-processor communications stream.
vtk::formatter & format()
The VTK formatter in use.
bool writeProcIDs()
Write processor ids as CellData. This is no-op in serial.
virtual bool beginFile(std::string title="")
Write file header (non-collective)