44 class concatPatchProcs
63 label offset = xPatches.
size();
68 xPatches[i + offset] = yPatches[i];
79 Foam::ensightMesh::ensightMesh
89 meshCellSets_(mesh_.nCells()),
90 boundaryFaceSets_(mesh_.
boundary().size()),
98 const cellModel& tet = *(cellModeller::lookup(
"tet"));
99 const cellModel& pyr = *(cellModeller::lookup(
"pyr"));
100 const cellModel& prism = *(cellModeller::lookup(
"prism"));
101 const cellModel& wedge = *(cellModeller::lookup(
"wedge"));
108 mesh_.boundaryMesh().names(), mesh_.boundary().size()
109 - mesh_.globalData().processorPatches().size()
112 allPatchProcs_.setSize(allPatchNames_.size());
116 if (mesh_.boundary()[
patchi].size())
118 allPatchProcs_[
patchi].setSize(1);
119 allPatchProcs_[
patchi][0] = Pstream::myProcNo();
129 if (patchNameList.empty())
131 patchNameList = allPatchNames_;
136 patchNames_.insert(patchNameList[i]);
141 if (patchNames_.size())
144 patchPartOffset_ = 1;
151 labelList& prisms = meshCellSets_.prisms;
152 labelList& wedges = meshCellSets_.wedges;
168 if (cellModel == tet)
170 tets[nTets++] = cellI;
172 else if (cellModel == pyr)
174 pyrs[nPyrs++] = cellI;
176 else if (cellModel == prism)
178 prisms[nPrisms++] = cellI;
180 else if (cellModel == wedge)
182 wedges[nWedges++] = cellI;
184 else if (cellModel == hex)
186 hexes[nHexes++] = cellI;
190 polys[nPolys++] = cellI;
201 meshCellSets_.nTets = nTets;
204 meshCellSets_.nPyrs = nPyrs;
207 meshCellSets_.nPrisms = nPrisms;
210 meshCellSets_.nHexesWedges = nHexes + nWedges;
213 meshCellSets_.nPolys = nPolys;
239 const face&
f = p[faceI];
243 tris[nTris++] = faceI;
245 else if (f.
size() == 4)
247 quads[nQuads++] = faceI;
251 polys[nPolys++] = faceI;
265 const word& patchName = allPatchNames_[
patchi];
268 if (patchNames_.empty() || patchNames_.found(patchName))
273 nfp.nTris = boundaryFaceSets_[
patchi].tris.size();
274 nfp.nQuads = boundaryFaceSets_[
patchi].quads.size();
275 nfp.nPolys = boundaryFaceSets_[
patchi].polys.size();
284 nPatchPrims_.insert(patchName, nfp);
297 void Foam::ensightMesh::writePoints
303 forAll(pointsComponent, pointI)
305 ensightGeometryFile<<
setw(12) << float(pointsComponent[pointI]) <<
nl;
320 mcsl[i] = cellShapes[prims[i]];
338 mcsl[i] = cellShapes[hexes[i]];
341 label offset = hexes.
size();
348 const cellShape& cellPoints = cellShapes[wedges[i]];
350 hexLabels[0] = cellPoints[0];
351 hexLabels[1] = cellPoints[1];
352 hexLabels[2] = cellPoints[0];
353 hexLabels[3] = cellPoints[2];
354 hexLabels[4] = cellPoints[3];
355 hexLabels[5] = cellPoints[4];
356 hexLabels[6] = cellPoints[6];
357 hexLabels[7] = cellPoints[5];
359 mcsl[i + offset] = cellShape(hex, hexLabels);
366 void Foam::ensightMesh::writePrims
369 const label pointOffset,
373 label po = pointOffset + 1;
377 const cellShape& cellPoints = cellShapes[i];
379 forAll(cellPoints, pointI)
381 ensightGeometryFile<<
setw(10) << cellPoints[pointI] + po;
383 ensightGeometryFile <<
nl;
388 void Foam::ensightMesh::writePrimsBinary
391 const label pointOffset,
392 std::ofstream& ensightGeometryFile
395 label po = pointOffset + 1;
400 numElem = cellShapes.
size();
402 if (cellShapes.
size())
405 int numIntElem = cellShapes.
size()*cellShapes[0].
size();
412 const cellShape& cellPoints = cellShapes[i];
414 forAll(cellPoints, pointI)
416 temp[n] = cellPoints[pointI] + po;
421 ensightGeometryFile.write
423 reinterpret_cast<char*>(temp.begin()),
424 numIntElem*
sizeof(
int)
430 void Foam::ensightMesh::writePolysNFaces
440 <<
setw(10) << cellFaces[polys[i]].
size() <<
nl;
445 void Foam::ensightMesh::writePolysNPointsPerFace
455 const labelList& cf = cellFaces[polys[i]];
466 void Foam::ensightMesh::writePolysPoints
471 const label pointOffset,
475 label po = pointOffset + 1;
479 const labelList& cf = cellFaces[polys[i]];
483 const face& f = faces[cf[faceI]];
487 ensightGeometryFile <<
setw(10) << f[pointI] + po;
489 ensightGeometryFile <<
nl;
495 void Foam::ensightMesh::writeAllPolys
501 if (meshCellSets_.nPolys)
503 const cellList& cellFaces = mesh_.cells();
504 const faceList& faces = mesh_.faces();
509 <<
"nfaced" <<
nl <<
setw(10) << meshCellSets_.nPolys <<
nl;
540 toMaster<< meshCellSets_.polys << cellFaces;
547 writePolysNPointsPerFace
562 writePolysNPointsPerFace
574 toMaster<< meshCellSets_.polys << cellFaces << faces;
602 pointOffsets[slave-1],
610 toMaster<< meshCellSets_.polys << cellFaces << faces;
616 void Foam::ensightMesh::writePolysNFacesBinary
620 std::ofstream& ensightGeometryFile
627 cellFaces[polys[i]].size(),
634 void Foam::ensightMesh::writePolysNPointsPerFaceBinary
639 std::ofstream& ensightGeometryFile
644 const labelList& cf = cellFaces[polys[i]];
650 faces[cf[faceI]].size(),
658 void Foam::ensightMesh::writePolysPointsBinary
663 const label pointOffset,
664 std::ofstream& ensightGeometryFile
667 label po = pointOffset + 1;
671 const labelList& cf = cellFaces[polys[i]];
675 const face& f = faces[cf[faceI]];
686 void Foam::ensightMesh::writeAllPolysBinary
689 std::ofstream& ensightGeometryFile
692 if (meshCellSets_.nPolys)
694 const cellList& cellFaces = mesh_.cells();
695 const faceList& faces = mesh_.faces();
707 writePolysNFacesBinary
720 writePolysNFacesBinary
731 toMaster<< meshCellSets_.polys << cellFaces;
738 writePolysNPointsPerFaceBinary
753 writePolysNPointsPerFaceBinary
765 toMaster<< meshCellSets_.polys << cellFaces << faces;
772 writePolysPointsBinary
788 writePolysPointsBinary
793 pointOffsets[slave-1],
801 toMaster<< meshCellSets_.polys << cellFaces << faces;
807 void Foam::ensightMesh::writeAllPrims
820 ensightGeometryFile << key <<
nl <<
setw(10) << nPrims <<
nl;
822 writePrims(cellShapes, 0, ensightGeometryFile);
832 pointOffsets[slave-1],
846 void Foam::ensightMesh::writeAllPrimsBinary
852 std::ofstream& ensightGeometryFile
862 writePrimsBinary(cellShapes, 0, ensightGeometryFile);
872 pointOffsets[slave-1],
886 void Foam::ensightMesh::writeFacePrims
889 const label pointOffset,
893 if (patchFaces.
size())
895 label po = pointOffset + 1;
899 const face& patchFace = patchFaces[i];
903 ensightGeometryFile <<
setw(10) << patchFace[pointI] + po;
905 ensightGeometryFile <<
nl;
911 void Foam::ensightMesh::writeFacePrimsBinary
914 const label pointOffset,
915 std::ofstream& ensightGeometryFile
918 if (patchFaces.
size())
920 label po = pointOffset + 1;
924 const face& patchFace = patchFaces[i];
930 patchFace[pointI] + po,
949 ppf[i] = patchFaces[prims[i]];
956 void Foam::ensightMesh::writeAllFacePrims
971 ensightGeometryFile << key <<
nl <<
setw(10) << nPrims <<
nl;
977 map(patchFaces, prims),
983 forAll (patchProcessors, i)
985 if (patchProcessors[i] != 0)
987 label slave = patchProcessors[i];
1000 else if (&prims != NULL)
1003 toMaster<< map(patchFaces, prims);
1009 void Foam::ensightMesh::writeNSidedNPointsPerFace
1023 void Foam::ensightMesh::writeNSidedPoints
1026 const label pointOffset,
1039 void Foam::ensightMesh::writeAllNSided
1054 <<
"nsided" << nl <<
setw(10) << nPrims <<
nl;
1062 writeNSidedNPointsPerFace
1064 map(patchFaces, prims),
1069 forAll (patchProcessors, i)
1071 if (patchProcessors[i] != 0)
1073 label slave = patchProcessors[i];
1077 writeNSidedNPointsPerFace
1085 else if (&prims != NULL)
1088 toMaster<< map(patchFaces, prims);
1098 map(patchFaces, prims),
1104 forAll (patchProcessors, i)
1106 if (patchProcessors[i] != 0)
1108 label slave = patchProcessors[i];
1121 else if (&prims != NULL)
1124 toMaster<< map(patchFaces, prims);
1130 void Foam::ensightMesh::writeNSidedPointsBinary
1133 const label pointOffset,
1134 std::ofstream& ensightGeometryFile
1137 writeFacePrimsBinary
1146 void Foam::ensightMesh::writeNSidedNPointsPerFaceBinary
1149 std::ofstream& ensightGeometryFile
1156 patchFaces[i].size(),
1163 void Foam::ensightMesh::writeAllNSidedBinary
1170 std::ofstream& ensightGeometryFile
1186 writeNSidedNPointsPerFaceBinary
1188 map(patchFaces, prims),
1193 forAll (patchProcessors, i)
1195 if (patchProcessors[i] != 0)
1197 label slave = patchProcessors[i];
1201 writeNSidedNPointsPerFaceBinary
1209 else if (&prims != NULL)
1212 toMaster<< map(patchFaces, prims);
1220 writeNSidedPointsBinary
1222 map(patchFaces, prims),
1228 forAll (patchProcessors, i)
1230 if (patchProcessors[i] != 0)
1232 label slave = patchProcessors[i];
1236 writeNSidedPointsBinary
1245 else if (&prims != NULL)
1248 toMaster<< map(patchFaces, prims);
1254 void Foam::ensightMesh::writeAllFacePrimsBinary
1262 std::ofstream& ensightGeometryFile
1274 writeFacePrimsBinary
1276 map(patchFaces, prims),
1282 forAll (patchProcessors, i)
1284 if (patchProcessors[i] != 0)
1286 label slave = patchProcessors[i];
1290 writeFacePrimsBinary
1299 else if (&prims != NULL)
1302 toMaster<< map(patchFaces, prims);
1311 const word& prepend,
1318 writeBinary(postProcPath, prepend, timeIndex, ensightCaseFile);
1322 writeAscii(postProcPath, prepend, timeIndex, ensightCaseFile);
1327 void Foam::ensightMesh::writeAscii
1330 const word& prepend,
1331 const label timeIndex,
1335 const Time& runTime = mesh_.
time();
1339 word timeFile = prepend;
1345 else if (mesh_.moving())
1347 timeFile +=
itoa(timeIndex) +
'.';
1351 fileName ensightGeometryFileName = timeFile +
"mesh";
1353 OFstream *ensightGeometryFilePtr = NULL;
1356 ensightGeometryFilePtr =
new OFstream
1358 postProcPath/ensightGeometryFileName,
1365 OFstream& ensightGeometryFile = *ensightGeometryFilePtr;
1370 ensightGeometryFile.
setf
1373 ios_base::floatfield
1378 <<
"EnSight Geometry File" << nl
1380 <<
"node id assign" << nl
1381 <<
"element id assign" <<
nl;
1386 if (patchNames_.empty())
1395 <<
setw(10) << 1 << nl
1396 <<
"internalMesh" << nl
1397 <<
"coordinates" << nl
1398 <<
setw(10) << nPoints
1403 writePoints(points.
component(
d), ensightGeometryFile);
1404 pointOffsets[0] = points.
size();
1410 writePoints(pointsComponent, ensightGeometryFile);
1411 pointOffsets[slave] =
1412 pointOffsets[slave-1]
1413 + pointsComponent.size();
1429 meshCellSets_.nHexesWedges,
1430 map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
1438 meshCellSets_.nPrisms,
1439 map(cellShapes, meshCellSets_.prisms),
1447 meshCellSets_.nPyrs,
1448 map(cellShapes, meshCellSets_.pyrs),
1456 meshCellSets_.nTets,
1457 map(cellShapes, meshCellSets_.tets),
1470 label ensightPatchI = patchPartOffset_;
1474 const word& patchName = allPatchNames_[
patchi];
1477 if (patchNames_.empty() || patchNames_.found(patchName))
1479 const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
1486 const faceList *patchFacesPtr = NULL;
1488 if (mesh_.boundary()[
patchi].size())
1492 trisPtr = &boundaryFaceSets_[
patchi].tris;
1493 quadsPtr = &boundaryFaceSets_[
patchi].quads;
1494 polysPtr = &boundaryFaceSets_[
patchi].polys;
1503 const pointField& patchPoints = *patchPointsPtr;
1504 const faceList& patchFaces = *patchFacesPtr;
1506 if (nfp.nTris || nfp.nQuads || nfp.nPolys)
1514 <<
setw(10) << ensightPatchI++ << nl
1516 <<
"coordinates" << nl
1517 <<
setw(10) << nfp.nPoints
1531 patchPointOffsets = 0;
1533 forAll (patchProcessors, i)
1535 if (patchProcessors[i] != 0)
1537 label slave = patchProcessors[i];
1543 patchPointsComponent,
1549 patchPointOffsets[i+1] =
1550 patchPointOffsets[i]
1551 + patchPointsComponent.size();
1558 patchPointOffsets[i+1] =
1559 patchPointOffsets[i]
1560 + patchPoints.
size();
1566 else if (patchPointsPtr)
1616 delete ensightGeometryFilePtr;
1621 void Foam::ensightMesh::writeBinary
1624 const word& prepend,
1625 const label timeIndex,
1633 word timeFile = prepend;
1639 else if (mesh_.moving())
1641 timeFile +=
itoa(timeIndex) +
'.';
1645 fileName ensightGeometryFileName = timeFile +
"mesh";
1647 std::ofstream *ensightGeometryFilePtr = NULL;
1651 ensightGeometryFilePtr =
new std::ofstream
1653 (postProcPath/ensightGeometryFileName).c_str(),
1654 ios_base::out | ios_base::binary | ios_base::trunc
1659 std::ofstream& ensightGeometryFile = *ensightGeometryFilePtr;
1672 if (patchNames_.empty())
1674 label nPoints = points.
size();
1689 pointOffsets[0] = points.
size();
1697 pointOffsets[slave] =
1698 pointOffsets[slave-1]
1699 + pointsComponent.size();
1715 meshCellSets_.nHexesWedges,
1716 map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
1724 meshCellSets_.nPrisms,
1725 map(cellShapes, meshCellSets_.prisms),
1733 meshCellSets_.nPyrs,
1734 map(cellShapes, meshCellSets_.pyrs),
1742 meshCellSets_.nTets,
1743 map(cellShapes, meshCellSets_.tets),
1756 label ensightPatchI = patchPartOffset_;
1762 const word& patchName = allPatchNames_[
patchi];
1765 if (patchNames_.empty() || patchNames_.found(patchName))
1767 const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
1774 const faceList *patchFacesPtr = NULL;
1776 if (mesh_.boundary()[
patchi].size())
1780 trisPtr = &boundaryFaceSets_[
patchi].tris;
1781 quadsPtr = &boundaryFaceSets_[
patchi].quads;
1782 polysPtr = &boundaryFaceSets_[
patchi].polys;
1791 const pointField& patchPoints = *patchPointsPtr;
1792 const faceList& patchFaces = *patchFacesPtr;
1794 if (nfp.nTris || nfp.nQuads || nfp.nPolys)
1819 patchPointOffsets = 0;
1822 forAll (patchProcessors, i)
1824 if (patchProcessors[i] != 0)
1826 label slave = patchProcessors[i];
1833 patchPointsComponent,
1839 patchPointOffsets[i+1] =
1840 patchPointOffsets[i]
1841 + patchPointsComponent.size();
1848 patchPointOffsets[i+1] =
1849 patchPointOffsets[i]
1850 + patchPoints.
size();
1856 else if (patchPointsPtr)
1869 writeAllFacePrimsBinary
1880 writeAllFacePrimsBinary
1891 writeAllNSidedBinary
1907 delete ensightGeometryFilePtr;