53 allPatchNames_.
clear();
57 faceZoneNames_.
clear();
59 boundaryFaceToBeIncluded_.
clear();
78 if (patchPatterns_.
empty())
80 forAll(allPatchNames_, nameI)
82 patchNames_.
insert(allPatchNames_[nameI]);
88 forAll(allPatchNames_, nameI)
90 const word& patchName = allPatchNames_[nameI];
93 patchNames_.
insert(patchName);
100 if (patchNames_.
size())
103 patchPartOffset_ = 1;
134 const cellShape& cellShape =
cellShapes[celli];
135 const cellModel& cellModel = cellShape.model();
137 if (cellModel == tet)
139 tets[nTets++] = celli;
141 else if (cellModel == pyr)
143 pyrs[nPyrs++] = celli;
145 else if (cellModel == prism)
147 prisms[nPrisms++] = celli;
149 else if (cellModel == wedge)
151 wedges[nWedges++] = celli;
153 else if (cellModel ==
hex)
155 hexes[nHexes++] = celli;
159 polys[nPolys++] = celli;
165 prisms.setSize(nPrisms);
166 wedges.setSize(nWedges);
167 hexes.setSize(nHexes);
168 polys.setSize(nPolys);
170 meshCellSets_.
nTets = nTets;
173 meshCellSets_.
nPyrs = nPyrs;
176 meshCellSets_.
nPrisms = nPrisms;
182 meshCellSets_.
nPolys = nPolys;
206 tris.setSize(
p.size());
207 quads.setSize(
p.size());
208 polys.setSize(
p.size());
216 const face&
f =
p[facei];
220 tris[nTris++] = facei;
222 else if (
f.size() == 4)
224 quads[nQuads++] = facei;
228 polys[nPolys++] = facei;
233 quads.setSize(nQuads);
234 polys.setSize(nPolys);
241 const word& patchName = allPatchNames_[
patchi];
244 if (patchNames_.
empty() || patchNames_.
found(patchName))
248 nfp.nTris = boundaryFaceSets_[
patchi].tris.size();
249 nfp.nQuads = boundaryFaceSets_[
patchi].quads.size();
250 nfp.nPolys = boundaryFaceSets_[
patchi].polys.size();
254 reduce(nfp.nTris, sumOp<label>());
255 reduce(nfp.nQuads, sumOp<label>());
256 reduce(nfp.nPolys, sumOp<label>());
258 nPatchPrims_.insert(patchName, nfp);
267 sort(faceZoneNamesAll);
270 forAll(faceZoneNamesAll, nameI)
272 const word& zoneName = faceZoneNamesAll[nameI];
275 faceZoneNames_.
insert(zoneName);
280 boundaryFaceToBeIncluded_.
setSize
292 isA<processorPolyPatch>(pp)
293 && !refCast<const processorPolyPatch>(pp).owner()
299 boundaryFaceToBeIncluded_[bFacei++] = 0;
305 forAll(faceZoneNamesAll, zoneI)
307 const word& zoneName = faceZoneNamesAll[zoneI];
310 const faceZone& fz = mesh_.
faceZones()[faceZoneId];
314 labelList& tris = faceZoneFaceSets_[faceZoneId].tris;
315 labelList& quads = faceZoneFaceSets_[faceZoneId].quads;
316 labelList& polys = faceZoneFaceSets_[faceZoneId].polys;
318 tris.setSize(fz.size());
319 quads.setSize(fz.size());
320 polys.setSize(fz.size());
326 label faceCounter = 0;
335 const face&
f = mesh_.
faces()[facei];
339 tris[nTris++] = faceCounter;
341 else if (
f.size() == 4)
343 quads[nQuads++] = faceCounter;
347 polys[nPolys++] = faceCounter;
355 quads.setSize(nQuads);
356 polys.setSize(nPolys);
360 forAll(faceZoneNamesAll, zoneI)
362 const word& zoneName = faceZoneNamesAll[zoneI];
366 if (faceZoneNames_.
found(zoneName))
370 faceZoneFaceSets_[faceZoneId].tris.size()
371 || faceZoneFaceSets_[faceZoneId].quads.size()
372 || faceZoneFaceSets_[faceZoneId].polys.size()
375 nfp.nTris = faceZoneFaceSets_[faceZoneId].tris.size();
376 nfp.nQuads = faceZoneFaceSets_[faceZoneId].quads.size();
377 nfp.nPolys = faceZoneFaceSets_[faceZoneId].polys.size();
381 reduce(nfp.nTris, sumOp<label>());
382 reduce(nfp.nQuads, sumOp<label>());
383 reduce(nfp.nPolys, sumOp<label>());
385 nFaceZonePrims_.insert(zoneName, nfp);
396 const bool noPatches,
401 const bool faceZones,
408 noPatches_(noPatches),
410 patchPatterns_(patchPatterns),
411 faceZones_(faceZones),
412 faceZonePatterns_(faceZonePatterns),
414 meshCellSets_(mesh.nCells())
432 if (mesh_.isInternalFace(facei))
438 res = boundaryFaceToBeIncluded_[facei-mesh_.nInternalFaces()];
448 reduce(appI,maxOp<label>());
494 const cellShape& cellPoints =
cellShapes[wedges[i]];
496 hexLabels[0] = cellPoints[0];
497 hexLabels[1] = cellPoints[1];
498 hexLabels[2] = cellPoints[0];
499 hexLabels[3] = cellPoints[2];
500 hexLabels[4] = cellPoints[3];
501 hexLabels[5] = cellPoints[4];
502 hexLabels[6] = cellPoints[6];
503 hexLabels[7] = cellPoints[5];
505 mcsl[i +
offset] = cellShape(
hex, hexLabels);
513 void Foam::ensightMesh::writePrims
516 ensightStream& ensightGeometryFile
522 if (ensightGeometryFile.ascii())
530 List<int> temp(cellPoints.size());
532 forAll(cellPoints, pointi)
534 temp[pointi] = cellPoints[pointi] + 1;
536 ensightGeometryFile.write(temp);
543 List<int> temp(numIntElem);
551 forAll(cellPoints, pointi)
553 temp[
n] = cellPoints[pointi] + 1;
557 ensightGeometryFile.write(temp);
563 void Foam::ensightMesh::writePolysNFaces
567 ensightStream& ensightGeometryFile
572 ensightGeometryFile.write(cellFaces[polys[i]].size());
577 void Foam::ensightMesh::writePolysNPointsPerFace
582 ensightStream& ensightGeometryFile
587 const labelList& cf = cellFaces[polys[i]];
591 ensightGeometryFile.write(faces[cf[facei]].size());
597 void Foam::ensightMesh::writePolysPoints
603 ensightStream& ensightGeometryFile
608 const labelList& cf = cellFaces[polys[i]];
615 bool reverseOrder =
false;
616 if (
faceId >= faceOwner.size())
629 if (faceOwner[
faceId] != polys[i])
646 temp[np-1-pointi] =
f[pointi] + 1;
650 temp[pointi] =
f[pointi] + 1;
653 ensightGeometryFile.write(temp);
659 void Foam::ensightMesh::writeAllPolys
662 ensightStream& ensightGeometryFile
665 if (meshCellSets_.nPolys)
667 const cellList& cellFaces = mesh_.cells();
668 const labelList& faceOwner = mesh_.faceOwner();
679 ensightGeometryFile.write(
"nfaced");
680 ensightGeometryFile.write(meshCellSets_.nPolys);
716 toMaster<< meshCellSets_.polys << cellFaces;
724 writePolysNPointsPerFace
739 writePolysNPointsPerFace
755 toMaster<< meshCellSets_.polys << cellFaces << faces;
797 toMaster<< meshCellSets_.polys << cellFaces << faces << faceOwner;
803 void Foam::ensightMesh::writeAllPrims
808 ensightStream& ensightGeometryFile
815 ensightGeometryFile.write(key);
816 ensightGeometryFile.write(nPrims);
841 void Foam::ensightMesh::writeFacePrims
844 ensightStream& ensightGeometryFile
849 const face& patchFace = patchFaces[i];
851 List<int> temp(patchFace.size());
854 temp[pointi] = patchFace[pointi] + 1;
857 ensightGeometryFile.write(temp);
862 void Foam::ensightMesh::writeAllFacePrims
868 ensightStream& ensightGeometryFile
875 ensightGeometryFile.write(key);
876 ensightGeometryFile.write(nPrims);
880 UIndirectList<face>(patchFaces, prims)(),
889 writeFacePrims(patchFaces, ensightGeometryFile);
899 toMaster<< UIndirectList<face>(patchFaces, prims);
905 void Foam::ensightMesh::writeNSidedNPointsPerFace
908 ensightStream& ensightGeometryFile
913 ensightGeometryFile.write(patchFaces[i].size());
918 void Foam::ensightMesh::writeNSidedPoints
921 ensightStream& ensightGeometryFile
924 writeFacePrims(patchFaces, ensightGeometryFile);
928 void Foam::ensightMesh::writeAllNSided
933 ensightStream& ensightGeometryFile
940 ensightGeometryFile.write(
"nsided");
941 ensightGeometryFile.write(nPrims);
947 writeNSidedNPointsPerFace
949 UIndirectList<face>(patchFaces, prims)(),
958 writeNSidedNPointsPerFace
972 toMaster<< UIndirectList<face>(patchFaces, prims);
980 UIndirectList<face>(patchFaces, prims)(),
989 writeNSidedPoints(patchFaces, ensightGeometryFile);
999 toMaster<< UIndirectList<face>(patchFaces, prims);
1005 void Foam::ensightMesh::writeAllPoints
1007 const label ensightPartI,
1008 const word& ensightPartName,
1011 ensightStream& ensightGeometryFile
1018 ensightGeometryFile.writePartHeader(ensightPartI);
1019 ensightGeometryFile.write(ensightPartName.c_str());
1020 ensightGeometryFile.write(
"coordinates");
1021 ensightGeometryFile.write(
nPoints);
1025 ensightGeometryFile.write(uniquePoints.component(d));
1030 ensightGeometryFile.write(patchPointsComponent);
1043 toMaster<< uniquePoints.component(d);
1051 const fileName& postProcPath,
1052 const word& prepend,
1055 Ostream& ensightCaseFile
1058 const Time& runTime = mesh_.time();
1062 word timeFile = prepend;
1066 timeFile +=
"0000.";
1074 fileName ensightGeometryFileName = timeFile +
"mesh";
1076 ensightStream* ensightGeometryFilePtr =
nullptr;
1081 ensightGeometryFilePtr =
new ensightBinaryStream
1083 postProcPath/ensightGeometryFileName,
1086 ensightGeometryFilePtr->write(
"C binary");
1090 ensightGeometryFilePtr =
new ensightAsciiStream
1092 postProcPath/ensightGeometryFileName,
1098 ensightStream& ensightGeometryFile = *ensightGeometryFilePtr;
1104 ensightGeometryFile.write(
"EnSight Geometry File");
1105 ensightGeometryFile.write(desc.c_str());
1106 ensightGeometryFile.write(
"node id assign");
1107 ensightGeometryFile.write(
"element id assign");
1110 if (patchNames_.empty())
1114 const pointField uniquePoints(mesh_.points(), uniquePointMap_);
1128 meshCellSets_.nHexesWedges,
1132 meshCellSets_.hexes,
1133 meshCellSets_.wedges,
1142 meshCellSets_.nPrisms,
1143 map(
cellShapes, meshCellSets_.prisms, pointToGlobal_),
1150 meshCellSets_.nPyrs,
1151 map(
cellShapes, meshCellSets_.pyrs, pointToGlobal_),
1158 meshCellSets_.nTets,
1159 map(
cellShapes, meshCellSets_.tets, pointToGlobal_),
1171 label ensightPatchi = patchPartOffset_;
1175 const word& patchName = allPatchNames_[
patchi];
1177 if (patchNames_.empty() || patchNames_.found(patchName))
1179 const nFacePrimitives& nfp = nPatchPrims_[patchName];
1181 if (nfp.nTris || nfp.nQuads || nfp.nPolys)
1183 const polyPatch&
p = mesh_.boundaryMesh()[
patchi];
1192 autoPtr<globalIndex> globalPointsPtr =
1193 mesh_.globalData().mergePoints
1198 uniqueMeshPointLabels
1201 pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
1214 globalPointsPtr().size(),
1250 const word& faceZoneName = iter.key();
1252 label faceID = mesh_.faceZones().findIndex(faceZoneName);
1254 const faceZone& fz = mesh_.faceZones()[faceID];
1256 const nFacePrimitives& nfp = nFaceZonePrims_[faceZoneName];
1258 if (nfp.nTris || nfp.nQuads || nfp.nPolys)
1260 const labelList& tris = faceZoneFaceSets_[faceID].tris;
1261 const labelList& quads = faceZoneFaceSets_[faceID].quads;
1262 const labelList& polys = faceZoneFaceSets_[faceID].polys;
1267 autoPtr<globalIndex> globalPointsPtr =
1268 mesh_.globalData().mergePoints
1270 fz.patch().meshPoints(),
1271 fz.patch().meshPointMap(),
1273 uniqueMeshPointLabels
1276 pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
1280 faceList faceZoneFaces(fz.patch().localFaces());
1284 label nMasterFaces = 0;
1288 if (faceToBeIncluded(fz[facei]))
1295 faceList faceZoneMasterFaces(nMasterFaces);
1297 label currentFace = 0;
1301 if (faceToBeIncluded(fz[facei]))
1303 faceZoneMasterFaces[currentFace] = faceZoneFaces[facei];
1309 forAll(faceZoneMasterFaces, i)
1319 globalPointsPtr().size(),
1328 faceZoneMasterFaces,
1337 faceZoneMasterFaces,
1345 faceZoneMasterFaces,
1353 delete ensightGeometryFilePtr;
Istream and Ostream manipulators taking arguments.
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
wordList toc() const
Return the table of contents.
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
bool empty() const
Return true if the hash table is empty.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void clear()
Clear all entries from table.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
void clear()
Clear the list, i.e. set addressable size to zero.
label findIndex(const word &key) const
Return the index of the given the key or -1 if not found.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
static int masterNo()
Process index of the master.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
label size() const
Return the number of elements in the UPtrList.
static const direction nComponents
Number of components in this vector space.
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or nullptr.
void setSize(const label nCells)
static void barrier()
Helper to cause barrier. Necessary on Quadrics.
void correct()
Update for new mesh.
void write(const fileName &postProcPath, const word &prepend, const label timeIndex, const bool meshMoving, Ostream &ensightCaseFile) const
~ensightMesh()
Destructor.
bool faceToBeIncluded(const label facei) const
When exporting faceZones, check if a given face has to be included.
ensightMesh(const fvMesh &mesh, const bool noPatches, const bool patches, const wordReList &patchPatterns, const bool faceZones, const wordReList &faceZonePatterns, const bool binary)
Construct from fvMesh.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const labelList & processorPatches() const
Return list of processor patch labels.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
wordList names() const
Return the list of patch names.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
virtual const faceList & faces() const
Return raw faces.
const globalMeshData & globalData() const
Return parallel info.
const faceZoneList & faceZones() const
Return face zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const cellShapeList & cellShapes() const
Return cell shapes.
label nInternalFaces() const
const cellShapeList & cellShapes
const fvPatchList & patches
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp, const SuType &Su)
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
List< cell > cellList
list of cells
const char *const FOAMversion
IOstream & hex(IOstream &io)
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
List< wordRe > wordReList
A List of wordRe (word or regular expression)
HashSet wordHashSet
A HashSet with word keys.
void offset(label &lst, const label o)
Operations on lists of strings.