92 for (
const label
patchId : patchIDs_)
104 const label
nPatches = patchIDs_.size();
132 for (
const label
patchId : patchIDs_)
136 toProc <<
pp.localPoints();
152 label nPolys = nLocalPolys_;
153 label nPolyConn = nLocalPolyConn_;
161 if (nPolys != numberOfCells_)
164 <<
"Expecting " << numberOfCells_
165 <<
" faces, but found " << nPolys
171 labelList vertLabels(nLocalPolys_ + nLocalPolyConn_);
177 auto iter = vertLabels.begin();
179 label off = pointOffset;
181 for (
const label
patchId : patchIDs_)
185 for (
const face&
f :
pp.localFaces())
190 for (
const label
id :
f)
224 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
232 label nVerts = nLocalPolyConn_;
236 reduce(nVerts, sumOp<label>());
241 const uint64_t payLoad =
242 vtk::sizeofData<label>(nVerts);
245 format().writeSize(payLoad);
252 auto iter = vertLabels.begin();
254 label off = pointOffset;
256 for (
const label
patchId : patchIDs_)
260 for (
const face&
f :
pp.localFaces())
262 for (
const label
id :
f)
295 label nOffs = vertOffsets.size();
299 reduce(nOffs, sumOp<label>());
304 const uint64_t payLoad =
305 vtk::sizeofData<label>(nOffs);
308 format().writeSize(payLoad);
315 parallel_ ? globalIndex(nLocalPolyConn_).localStart() : 0
319 auto iter = vertOffsets.begin();
321 for (
const label
patchId : patchIDs_)
325 for (
const face&
f :
pp)
367 vtk::fileWriter(vtk::
fileTag::POLY_DATA, opts),
392 open(file, parallel);
407 open(file, parallel);
426 patchIDs_.size() == 1
427 ? mesh_.boundaryMesh()[patchIDs_.first()].name()
437 if (patchIDs_.size() == 1)
441 "patch='" + mesh_.boundaryMesh()[patchIDs_.first()].name() +
"'" 448 "npatches='" +
Foam::name(patchIDs_.size()) +
"'" 454 " time='" + mesh_.time().timeName()
455 +
"' index='" +
Foam::name(mesh_.time().timeIndex())
471 const label pointOffset =
478 writePolysLegacy(pointOffset);
482 writePolys(pointOffset);
491 return enter_CellData(numberOfCells_, nFields);
497 return enter_PointData(numberOfPoints_, nFields);
510 <<
" for patchID field" <<
nl <<
endl 514 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
516 label nPolys = nLocalPolys_;
520 reduce(nPolys, sumOp<label>());
524 this->beginDataArray<label>(
"patchID", nPolys);
528 for (
const label
patchId : patchIDs_)
548 for (label i=0; i < recv.size(); i += 2)
550 const label len = recv[i];
551 const label val = recv[i+1];
569 for (
const label
patchId : patchIDs_)
582 this->endDataArray();
588 if (this->isPointData())
611 <<
" for patchID field" <<
nl <<
endl 615 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
617 label nPolys = nLocalPolys_;
621 reduce(nPolys, sumOp<label>());
625 this->beginDataArray<label>(
"neighID", nPolys);
631 for (
const label
patchId : patchIDs_)
635 const label val = (
pp ?
pp->neighbProcNo() : -1);
657 for (label i=0; i < recv.size(); i += 2)
659 const label len = recv[i];
660 const label val = recv[i+1];
678 for (
const label
patchId : patchIDs_)
683 send[i+1] = (
pp ?
pp->neighbProcNo() : -1);
692 this->endDataArray();
Write OpenFOAM patches and patch fields in VTP or legacy vtk format.
const labelList patchIDs(pbm.patchSet(polyPatchNames, false, true).sortedToc())
autoPtr< vtk::formatter > format_
The VTK formatter in use (only valid on master process)
"blocking" : (MPI_Bsend, MPI_Recv)
A class for handling file names.
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
errorManipArg< error, int > exit(error &err, const int errNo=1)
patchMeshWriter(const patchMeshWriter &)=delete
No copy construct.
A face is a list of labels corresponding to mesh vertices.
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.
label nLocalPolys_
Local number of polys (faces)
constexpr char nl
The newline '\n' character (0x0a)
void writePatchIDs()
Write patch ids as CellData.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
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)
void beginPiece()
Determine sizes (nLocalPoints_, nLocalPolys_), and begin piece.
bool legacy() const noexcept
Commonly used query.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
label numberOfCells_
The number of field cells (faces) for the current Piece.
virtual bool beginPointData(label nFields=0)
Begin PointData for specified number of fields.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
void beginPoints(std::ostream &os, label nPoints)
Emit header for POINTS (with trailing newline).
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void writePolys(const label pointOffset)
Write patch faces.
bool writeProcIDs()
Write processor ids for each line as CellData or for each point as PointData, depending on isPointDat...
bool writeProcIDs(const label nValues)
Write nValues of processor ids as CellData or PointData (no-op in serial)
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
label nLocalPoints_
Local number of points.
virtual bool writeGeometry()
Write patch topology.
word format(conversionProperties.get< word >("format"))
virtual bool beginFile(std::string title="")
Write file header (non-collective)
labelList patchIDs_
The selected patch ids.
fileTag
Some common XML tags for vtk files.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
void writePoints()
Write patch points.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
bool writeNeighIDs()
Write processor neighbour ids as CellData. This is no-op in serial.
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
label nLocalPolyConn_
Local connectivity count for polys (faces) == sum of face sizes.
Mesh consisting of general polyhedral cells.
label localStart() const
My local start.
List< label > labelList
A List of labels.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
A patch is a list of labels that address the faces in the global face list.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void writePolysLegacy(const label pointOffset)
Write patch faces, legacy format.
const polyMesh & mesh_
Reference to the OpenFOAM mesh (or subset)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
virtual bool beginFile(std::string title="")
Write file header (non-collective)