43 void Foam::ensightMesh::clear()
45 cellZoneParts_.clear();
46 faceZoneParts_.clear();
47 boundaryParts_.clear();
51 void Foam::ensightMesh::renumber()
55 for (
const label
id : cellZoneParts_.sortedToc())
57 cellZoneParts_[id].index() = partNo++;
60 for (
const label
id : boundaryParts_.sortedToc())
62 boundaryParts_[id].index() = partNo++;
65 for (
const label
id : faceZoneParts_.sortedToc())
67 faceZoneParts_[id].index() = partNo++;
74 Foam::ensightMesh::ensightMesh
83 Foam::ensightMesh::ensightMesh
89 options_(new options(opts)),
121 const auto&
pbm = mesh_.boundaryMesh();
126 if (option().useBoundaryMesh())
130 option().patchSelection(),
131 option().patchExclude()
138 const auto&
pp =
pbm[patchi];
140 if (isType<emptyPolyPatch>(
pp))
144 else if (isA<processorPolyPatch>(
pp))
157 const auto& czMatcher = option().cellZoneSelection();
162 if (option().useCellZones())
165 czoneIds = mesh_.cellZones().indices
167 option().cellZoneSelection(),
168 option().cellZoneExclude()
175 if (option().useFaceZones())
178 fzoneIds = mesh_.faceZones().indices
180 option().faceZoneSelection(),
181 option().faceZoneExclude()
187 bitSet cellSelection;
194 for (
const label zoneId : czoneIds)
196 const auto& zn = mesh_.cellZones()[zoneId];
197 const auto& zoneName = zn.name();
202 cellSelection.
resize(mesh_.nCells());
204 cellSelection.set(zn);
206 ensightCells& part = cellZoneParts_(zoneId);
209 part.identifier() = zoneId;
210 part.rename(zoneName);
212 part.classify(mesh_, zn);
223 if (option().useInternalMesh() && czMatcher.empty())
229 if (cellZoneParts_.empty())
231 ensightCells& part = cellZoneParts_(internalZone);
234 part.identifier() = internalZone;
235 part.rename(
"internalMesh");
237 part.classify(mesh_);
249 cellSelection.flip();
253 ensightCells& part = cellZoneParts_(internalZone);
256 part.identifier() = internalZone;
257 part.rename(
"internalMesh");
259 part.classify(mesh_, cellSelection);
271 cellSelection.clearStorage();
273 else if (cellSelection.none())
276 cellSelection.clearStorage();
285 excludeFace.resize(mesh_.nFaces());
287 const labelList& owner = mesh_.faceOwner();
291 const label celli = owner[facei];
293 if (!cellSelection.test(celli))
295 excludeFace.set(facei);
307 excludeFace.resize(mesh_.nFaces());
309 for (
const polyPatch&
p :
pbm)
311 const auto* cpp = isA<coupledPolyPatch>(
p);
315 isA<emptyPolyPatch>(
p)
316 || (cpp && !cpp->owner())
321 excludeFace.set(
p.range());
331 const auto& patchName =
p.
name();
333 if (isA<emptyPolyPatch>(
p))
338 else if (isA<processorPolyPatch>(
p))
344 ensightFaces& part = boundaryParts_(
patchId);
348 part.rename(patchName);
372 for (
const label zoneId : fzoneIds)
374 const auto& zn = mesh_.faceZones()[zoneId];
375 const auto& zoneName = zn.name();
377 ensightFaces& part = faceZoneParts_(zoneId);
380 part.identifier() = zoneId;
381 part.rename(zoneName);
402 faceZoneParts_.erase(zoneId);
408 needsUpdate_ =
false;
424 for (
const label
id : cellZoneParts_.sortedToc())
426 cellZoneParts_[id].
write(
os, mesh_, parallel);
430 for (
const label
id : boundaryParts_.sortedToc())
432 boundaryParts_[id].
write(
os, mesh_, parallel);
436 for (
const label
id : faceZoneParts_.sortedToc())
438 faceZoneParts_[id].write(
os, mesh_, parallel);
446 cellZoneParts_.empty()
447 && boundaryParts_.empty()
448 && faceZoneParts_.empty()
const polyBoundaryMesh & pbm
virtual Ostream & write(const char c) override
Write character.
void resize(const label len)
Adjust allocated size of list.
const ensightMesh::options & option() const
Reference to the writer/mesh options.
const word & name() const noexcept
Return the object name.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information...
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching patch groups.
void correct()
Update for new mesh.
static void writeBox(ensightGeoFile &os, const boundBox &bb, const label partIndex=0, const word &partName="geometry-box")
Write bounding box geometry. All parameters are only relevant on master No beginGeometry() marker...
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
void write(ensightGeoFile &os, bool parallel=UPstream::parRun()) const
Write geometry to file (normally in parallel). Adds beginGeometry() marker.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Encapsulation of volume meshes for writing in ensight format. It manages cellZones, facesZone, patches.
OBJstream os(runTime.globalPath()/outputName)
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static const label internalZone
The zone-id for internal mesh or unzoned cells.
Configuration options for the ensightMesh.
Mesh consisting of general polyhedral cells.
int verbose() const noexcept
Output verbosity level.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())