1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include <OpenFOAM/argList.H>
28 #include <OpenFOAM/Time.H>
29 #include "ensightMesh.H"
30 #include <finiteVolume/fvMesh.H>
31 #include <OpenFOAM/PstreamCombineReduceOps.H>
32 #include <OpenFOAM/processorPolyPatch.H>
33 #include <OpenFOAM/cellModeller.H>
34 #include <OpenFOAM/IOmanip.H>
36 #include "ensightWriteBinary.H"
39 // * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
44 class concatPatchNames
51 HashTable<labelList>& x,
52 const HashTable<labelList>& y
55 forAllConstIter(HashTable<labelList>, y, iter)
57 HashTable<labelList>::iterator xiter = x.find(iter.key());
61 x.insert(iter.key(), iter());
65 labelList& xPatches = xiter();
66 const labelList& yPatches = iter();
68 label offset = xPatches.size();
69 xPatches.setSize(offset + yPatches.size());
73 xPatches[i + offset] = yPatches[i];
80 } // End namespace Foam
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
85 Foam::ensightMesh::ensightMesh
94 meshCellSets_(mesh_.nCells()),
95 boundaryFaceSets_(mesh_.boundary().size()),
101 forAll (mesh_.boundaryMesh(), patchi)
105 typeid(mesh_.boundaryMesh()[patchi])
106 != typeid(processorPolyPatch)
109 if (!allPatchNames_.found(mesh_.boundaryMesh()[patchi].name()))
111 allPatchNames_.insert
113 mesh_.boundaryMesh()[patchi].name(),
114 labelList(1, Pstream::myProcNo())
119 mesh_.boundaryMesh()[patchi].name(),
126 combineReduce(allPatchNames_, concatPatchNames());
128 if (args.options().found("patches"))
130 wordList patchNameList(IStringStream(args.options()["patches"])());
132 if (!patchNameList.size())
134 patchNameList = allPatchNames_.toc();
137 forAll (patchNameList, i)
139 patchNames_.insert(patchNameList[i]);
143 const cellShapeList& cellShapes = mesh.cellShapes();
145 const cellModel& tet = *(cellModeller::lookup("tet"));
146 const cellModel& pyr = *(cellModeller::lookup("pyr"));
147 const cellModel& prism = *(cellModeller::lookup("prism"));
148 const cellModel& wedge = *(cellModeller::lookup("wedge"));
149 const cellModel& hex = *(cellModeller::lookup("hex"));
151 labelList& tets = meshCellSets_.tets;
152 labelList& pyrs = meshCellSets_.pyrs;
153 labelList& prisms = meshCellSets_.prisms;
154 labelList& wedges = meshCellSets_.wedges;
155 labelList& hexes = meshCellSets_.hexes;
156 labelList& polys = meshCellSets_.polys;
166 if (!patchNames_.size())
168 forAll(cellShapes, celli)
170 const cellShape& cellShape = cellShapes[celli];
171 const cellModel& cellModel = cellShape.model();
173 if (cellModel == tet)
175 tets[nTets++] = celli;
177 else if (cellModel == pyr)
179 pyrs[nPyrs++] = celli;
181 else if (cellModel == prism)
183 prisms[nPrisms++] = celli;
185 else if (cellModel == wedge)
187 wedges[nWedges++] = celli;
189 else if (cellModel == hex)
191 hexes[nHexes++] = celli;
195 polys[nPolys++] = celli;
201 prisms.setSize(nPrisms);
202 wedges.setSize(nWedges);
203 hexes.setSize(nHexes);
204 polys.setSize(nPolys);
206 meshCellSets_.nTets = nTets;
207 reduce(meshCellSets_.nTets, sumOp<label>());
209 meshCellSets_.nPyrs = nPyrs;
210 reduce(meshCellSets_.nPyrs, sumOp<label>());
212 meshCellSets_.nPrisms = nPrisms;
213 reduce(meshCellSets_.nPrisms, sumOp<label>());
215 meshCellSets_.nHexesWedges = nHexes + nWedges;
216 reduce(meshCellSets_.nHexesWedges, sumOp<label>());
218 meshCellSets_.nPolys = nPolys;
219 reduce(meshCellSets_.nPolys, sumOp<label>());
223 forAll (mesh.boundary(), patchi)
225 if (mesh.boundary()[patchi].size())
227 const polyPatch& p = mesh.boundaryMesh()[patchi];
229 labelList& tris = boundaryFaceSets_[patchi].tris;
230 labelList& quads = boundaryFaceSets_[patchi].quads;
231 labelList& polys = boundaryFaceSets_[patchi].polys;
233 tris.setSize(p.size());
234 quads.setSize(p.size());
235 polys.setSize(p.size());
243 const face& f = p[facei];
247 tris[nTris++] = facei;
249 else if (f.size() == 4)
251 quads[nQuads++] = facei;
255 polys[nPolys++] = facei;
260 quads.setSize(nQuads);
261 polys.setSize(nPolys);
265 forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
267 const word& patchName = iter.key();
270 if (!patchNames_.size() || patchNames_.found(patchName))
272 if (patchIndices_.found(patchName))
274 label patchi = patchIndices_.find(patchName)();
276 nfp.nPoints = mesh.boundaryMesh()[patchi].localPoints().size();
277 nfp.nTris = boundaryFaceSets_[patchi].tris.size();
278 nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
279 nfp.nPolys = boundaryFaceSets_[patchi].polys.size();
283 reduce(nfp.nPoints, sumOp<label>());
284 reduce(nfp.nTris, sumOp<label>());
285 reduce(nfp.nQuads, sumOp<label>());
286 reduce(nfp.nPolys, sumOp<label>());
288 nPatchPrims_.insert(patchName, nfp);
293 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
295 Foam::ensightMesh::~ensightMesh()
299 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
301 void Foam::ensightMesh::writePoints
303 const scalarField& pointsComponent,
304 OFstream& ensightGeometryFile
307 forAll(pointsComponent, pointi)
309 ensightGeometryFile<< setw(12) << float(pointsComponent[pointi]) << nl;
314 Foam::cellShapeList Foam::ensightMesh::map
316 const cellShapeList& cellShapes,
317 const labelList& prims
320 cellShapeList mcsl(prims.size());
324 mcsl[i] = cellShapes[prims[i]];
331 Foam::cellShapeList Foam::ensightMesh::map
333 const cellShapeList& cellShapes,
334 const labelList& hexes,
335 const labelList& wedges
338 cellShapeList mcsl(hexes.size() + wedges.size());
342 mcsl[i] = cellShapes[hexes[i]];
345 label offset = hexes.size();
347 const cellModel& hex = *(cellModeller::lookup("hex"));
348 labelList hexLabels(8);
352 const cellShape& cellPoints = cellShapes[wedges[i]];
354 hexLabels[0] = cellPoints[0];
355 hexLabels[1] = cellPoints[1];
356 hexLabels[2] = cellPoints[0];
357 hexLabels[3] = cellPoints[2];
358 hexLabels[4] = cellPoints[3];
359 hexLabels[5] = cellPoints[4];
360 hexLabels[6] = cellPoints[6];
361 hexLabels[7] = cellPoints[5];
363 mcsl[i + offset] = cellShape(hex, hexLabels);
370 void Foam::ensightMesh::writePrims
372 const cellShapeList& cellShapes,
373 const label pointOffset,
374 OFstream& ensightGeometryFile
377 label po = pointOffset + 1;
379 forAll(cellShapes, i)
381 const cellShape& cellPoints = cellShapes[i];
383 forAll(cellPoints, pointi)
385 ensightGeometryFile<< setw(10) << cellPoints[pointi] + po;
387 ensightGeometryFile << nl;
392 void Foam::ensightMesh::writePrimsBinary
394 const cellShapeList& cellShapes,
395 const label pointOffset,
396 std::ofstream& ensightGeometryFile
399 label po = pointOffset + 1;
401 // Create a temp int array
404 numElem = cellShapes.size();
406 if (cellShapes.size() > 0)
408 // All the cellShapes have the same number of elements!
409 int numIntElem = cellShapes.size()*cellShapes[0].size();
410 List<int> temp(numIntElem);
414 forAll(cellShapes, i)
416 const cellShape& cellPoints = cellShapes[i];
418 forAll(cellPoints, pointi)
420 temp[n] = cellPoints[pointi] + po;
425 ensightGeometryFile.write
427 reinterpret_cast<char*>(temp.begin()),
428 numIntElem*sizeof(int)
434 void Foam::ensightMesh::writePolys
436 const labelList& polys,
437 const cellList& cellFaces,
438 const faceList& faces,
439 const label pointOffset,
440 OFstream& ensightGeometryFile
446 << "nfaced" << nl << setw(10) << polys.size() << nl;
448 label po = pointOffset + 1;
453 << setw(10) << cellFaces[polys[i]].size() << nl;
458 const labelList& cf = cellFaces[polys[i]];
463 << setw(10) << faces[cf[facei]].size() << nl;
469 const labelList& cf = cellFaces[polys[i]];
473 const face& f = faces[cf[facei]];
477 ensightGeometryFile << setw(10) << f[pointi] + po;
479 ensightGeometryFile << nl;
486 void Foam::ensightMesh::writePolysBinary
488 const labelList& polys,
489 const cellList& cellFaces,
490 const faceList& faces,
491 const label pointOffset,
492 std::ofstream& ensightGeometryFile
497 writeEnsDataBinary("nfaced",ensightGeometryFile);
498 writeEnsDataBinary(polys.size(),ensightGeometryFile);
500 label po = pointOffset + 1;
502 //TODO No buffer at the moment. To be done for speed purposes!
507 cellFaces[polys[i]].size(),
514 const labelList& cf = cellFaces[polys[i]];
520 faces[cf[facei]].size(),
528 const labelList& cf = cellFaces[polys[i]];
532 const face& f = faces[cf[facei]];
536 writeEnsDataBinary(f[pointi] + po,ensightGeometryFile);
544 void Foam::ensightMesh::writeAllPrims
548 const cellShapeList& cellShapes,
549 const labelList& pointOffsets,
550 OFstream& ensightGeometryFile
555 if (Pstream::master())
557 ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
559 writePrims(cellShapes, 0, ensightGeometryFile);
561 for (int slave=1; slave<Pstream::nProcs(); slave++)
563 IPstream fromSlave(Pstream::scheduled, slave);
564 cellShapeList cellShapes(fromSlave);
569 pointOffsets[slave-1],
576 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
577 toMaster<< cellShapes;
583 void Foam::ensightMesh::writeAllPrimsBinary
587 const cellShapeList& cellShapes,
588 const labelList& pointOffsets,
589 std::ofstream& ensightGeometryFile
594 if (Pstream::master())
596 writeEnsDataBinary(key,ensightGeometryFile);
597 writeEnsDataBinary(nPrims,ensightGeometryFile);
599 writePrimsBinary(cellShapes, 0, ensightGeometryFile);
601 for (int slave=1; slave<Pstream::nProcs(); slave++)
603 IPstream fromSlave(Pstream::scheduled, slave);
604 cellShapeList cellShapes(fromSlave);
609 pointOffsets[slave-1],
616 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
617 toMaster<< cellShapes;
623 void Foam::ensightMesh::writeFacePrims
626 const faceList& patchFaces,
627 const label pointOffset,
628 OFstream& ensightGeometryFile
631 if (patchFaces.size())
633 if (word(key) == "nsided")
636 << key << nl << setw(10) << patchFaces.size() << nl;
638 forAll(patchFaces, i)
641 << setw(10) << patchFaces[i].size() << nl;
645 label po = pointOffset + 1;
647 forAll(patchFaces, i)
649 const face& patchFace = patchFaces[i];
651 forAll(patchFace, pointi)
653 ensightGeometryFile << setw(10) << patchFace[pointi] + po;
655 ensightGeometryFile << nl;
661 void Foam::ensightMesh::writeFacePrimsBinary
664 const faceList& patchFaces,
665 const label pointOffset,
666 std::ofstream& ensightGeometryFile
669 if (patchFaces.size())
671 //TODO No buffer at the moment. To be done for speed purposes!
672 if (word(key) == "nsided")
674 writeEnsDataBinary(key,ensightGeometryFile);
675 writeEnsDataBinary(patchFaces.size(),ensightGeometryFile);
677 forAll(patchFaces, i)
681 patchFaces[i].size(),
687 label po = pointOffset + 1;
689 forAll(patchFaces, i)
691 const face& patchFace = patchFaces[i];
693 forAll(patchFace, pointi)
697 patchFace[pointi] + po,
706 Foam::faceList Foam::ensightMesh::map
708 const faceList& patchFaces,
709 const labelList& prims
712 faceList ppf(prims.size());
716 ppf[i] = patchFaces[prims[i]];
723 void Foam::ensightMesh::writeAllFacePrims
726 const labelList& prims,
728 const faceList& patchFaces,
729 const labelList& pointOffsets,
730 const labelList& patchProcessors,
731 OFstream& ensightGeometryFile
736 if (Pstream::master())
738 if (word(key) != "nsided")
740 ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
748 map(patchFaces, prims),
754 forAll (patchProcessors, i)
756 if (patchProcessors[i] != 0)
758 label slave = patchProcessors[i];
759 IPstream fromSlave(Pstream::scheduled, slave);
760 faceList patchFaces(fromSlave);
772 else if (&prims != NULL)
774 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
775 toMaster<< map(patchFaces, prims);
781 void Foam::ensightMesh::writeAllFacePrimsBinary
784 const labelList& prims,
786 const faceList& patchFaces,
787 const labelList& pointOffsets,
788 const labelList& patchProcessors,
789 std::ofstream& ensightGeometryFile
794 if (Pstream::master())
796 if (word(key) != "nsided")
798 writeEnsDataBinary(key,ensightGeometryFile);
799 writeEnsDataBinary(nPrims,ensightGeometryFile);
807 map(patchFaces, prims),
813 forAll (patchProcessors, i)
815 if (patchProcessors[i] != 0)
817 label slave = patchProcessors[i];
818 IPstream fromSlave(Pstream::scheduled, slave);
819 faceList patchFaces(fromSlave);
831 else if (&prims != NULL)
833 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
834 toMaster<< map(patchFaces, prims);
840 void Foam::ensightMesh::write
842 const fileName& postProcPath,
844 const label timeIndex,
845 Ostream& ensightCaseFile
850 writeBinary(postProcPath, prepend, timeIndex, ensightCaseFile);
854 writeAscii(postProcPath, prepend, timeIndex, ensightCaseFile);
859 void Foam::ensightMesh::writeAscii
861 const fileName& postProcPath,
863 const label timeIndex,
864 Ostream& ensightCaseFile
867 const Time& runTime = mesh_.time();
868 const pointField& points = mesh_.points();
869 const cellList& cellFaces = mesh_.cells();
870 const faceList& faces = mesh_.faces();
871 const cellShapeList& cellShapes = mesh_.cellShapes();
873 word timeFile = prepend;
879 else if (mesh_.moving())
881 timeFile += itoa(timeIndex) + '.';
884 // set the filename of the ensight file
885 fileName ensightGeometryFileName = timeFile + "mesh";
887 OFstream *ensightGeometryFilePtr = NULL;
888 if (Pstream::master())
890 ensightGeometryFilePtr = new OFstream
892 postProcPath/ensightGeometryFileName,
893 runTime.writeFormat(),
894 runTime.writeVersion(),
895 runTime.writeCompression()
899 OFstream& ensightGeometryFile = *ensightGeometryFilePtr;
901 if (Pstream::master())
904 ensightGeometryFile.setf
906 ios_base::scientific,
909 ensightGeometryFile.precision(5);
912 << "OpenFOAM Geometry File " << nl
913 << "OpenFOAM version " << Foam::FOAMfullVersion << nl
914 << "node id assign" << nl
915 << "element id assign" << nl;
918 labelList pointOffsets(Pstream::nProcs(), 0);
920 if (!patchNames_.size())
922 label nPoints = points.size();
923 Pstream::gather(nPoints, sumOp<label>());
925 if (Pstream::master())
929 << setw(10) << 1 << nl
930 << "FOAM cells" << nl
931 << "coordinates" << nl
932 << setw(10) << nPoints
935 for (direction d=0; d<vector::nComponents; d++)
937 writePoints(points.component(d), ensightGeometryFile);
938 pointOffsets[0] = points.size();
940 for (int slave=1; slave<Pstream::nProcs(); slave++)
942 IPstream fromSlave(Pstream::scheduled, slave);
943 scalarField pointsComponent(fromSlave);
944 writePoints(pointsComponent, ensightGeometryFile);
945 pointOffsets[slave] =
946 pointOffsets[slave-1]
947 + pointsComponent.size();
953 for (direction d=0; d<vector::nComponents; d++)
955 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
956 toMaster<< points.component(d);
963 meshCellSets_.nHexesWedges,
964 map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
972 meshCellSets_.nPrisms,
973 map(cellShapes, meshCellSets_.prisms),
982 map(cellShapes, meshCellSets_.pyrs),
991 map(cellShapes, meshCellSets_.tets),
997 if (meshCellSets_.nPolys)
999 if (Pstream::master())
1004 << setw(10) << meshCellSets_.nPolys << nl;
1008 meshCellSets_.polys,
1015 for (int slave=1; slave<Pstream::nProcs(); slave++)
1017 IPstream fromSlave(Pstream::scheduled, slave);
1018 labelList polys(fromSlave);
1019 cellList cellFaces(fromSlave);
1020 faceList faces(fromSlave);
1027 pointOffsets[slave-1],
1034 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
1035 toMaster<< meshCellSets_.polys << cellFaces << faces;
1041 label ensightPatchi = 2;
1043 forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
1045 const labelList& patchProcessors = iter();
1047 if (!patchNames_.size() || patchNames_.found(iter.key()))
1049 const word& patchName = iter.key();
1050 const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
1052 const labelList *trisPtr = NULL;
1053 const labelList *quadsPtr = NULL;
1054 const labelList *polysPtr = NULL;
1056 const pointField *patchPointsPtr = NULL;
1057 const faceList *patchFacesPtr = NULL;
1059 if (patchIndices_.found(iter.key()))
1061 label patchi = patchIndices_.find(iter.key())();
1062 const polyPatch& p = mesh_.boundaryMesh()[patchi];
1064 trisPtr = &boundaryFaceSets_[patchi].tris;
1065 quadsPtr = &boundaryFaceSets_[patchi].quads;
1066 polysPtr = &boundaryFaceSets_[patchi].polys;
1068 patchPointsPtr = &(p.localPoints());
1069 patchFacesPtr = &(p.localFaces());
1072 const labelList& tris = *trisPtr;
1073 const labelList& quads = *quadsPtr;
1074 const labelList& polys = *polysPtr;
1075 const pointField& patchPoints = *patchPointsPtr;
1076 const faceList& patchFaces = *patchFacesPtr;
1078 if (nfp.nTris || nfp.nQuads || nfp.nPolys)
1080 labelList patchPointOffsets(Pstream::nProcs(), 0);
1082 if (Pstream::master())
1086 << setw(10) << ensightPatchi++ << nl
1088 << "coordinates" << nl
1089 << setw(10) << nfp.nPoints
1092 for (direction d=0; d<vector::nComponents; d++)
1098 patchPoints.component(d),
1103 patchPointOffsets = 0;
1105 forAll (patchProcessors, i)
1107 if (patchProcessors[i] != 0)
1109 label slave = patchProcessors[i];
1110 IPstream fromSlave(Pstream::scheduled, slave);
1111 scalarField patchPointsComponent(fromSlave);
1115 patchPointsComponent,
1119 if (i < Pstream::nProcs()-1)
1121 patchPointOffsets[i+1] =
1122 patchPointOffsets[i]
1123 + patchPointsComponent.size();
1128 if (i < Pstream::nProcs()-1)
1130 patchPointOffsets[i+1] =
1131 patchPointOffsets[i]
1132 + patchPoints.size();
1138 else if (patchPointsPtr)
1140 for (direction d=0; d<vector::nComponents; d++)
1147 toMaster<< patchPoints.component(d);
1187 if (Pstream::master())
1189 delete ensightGeometryFilePtr;
1194 void Foam::ensightMesh::writeBinary
1196 const fileName& postProcPath,
1197 const word& prepend,
1198 const label timeIndex,
1199 Ostream& ensightCaseFile
1202 //const Time& runTime = mesh.time();
1203 const pointField& points = mesh_.points();
1204 const cellList& cellFaces = mesh_.cells();
1205 const faceList& faces = mesh_.faces();
1206 const cellShapeList& cellShapes = mesh_.cellShapes();
1208 word timeFile = prepend;
1214 else if (mesh_.moving())
1216 timeFile += itoa(timeIndex) + '.';
1219 // set the filename of the ensight file
1220 fileName ensightGeometryFileName = timeFile + "mesh";
1222 std::ofstream *ensightGeometryFilePtr = NULL;
1224 if (Pstream::master())
1226 ensightGeometryFilePtr = new std::ofstream
1228 (postProcPath/ensightGeometryFileName).c_str(),
1229 ios_base::out | ios_base::binary | ios_base::trunc
1231 // Check on file opened?
1234 std::ofstream& ensightGeometryFile = *ensightGeometryFilePtr;
1236 if (Pstream::master())
1238 writeEnsDataBinary("C binary",ensightGeometryFile);
1239 writeEnsDataBinary("OpenFOAM Geometry File",ensightGeometryFile);
1240 writeEnsDataBinary("Binary format",ensightGeometryFile);
1241 writeEnsDataBinary("node id assign",ensightGeometryFile);
1242 writeEnsDataBinary("element id assign",ensightGeometryFile);
1245 labelList pointOffsets(Pstream::nProcs(), 0);
1247 if (!patchNames_.size())
1249 label nPoints = points.size();
1250 Pstream::gather(nPoints, sumOp<label>());
1252 if (Pstream::master())
1254 writeEnsDataBinary("part",ensightGeometryFile);
1255 writeEnsDataBinary(1,ensightGeometryFile);
1256 writeEnsDataBinary("FOAM cells",ensightGeometryFile);
1257 writeEnsDataBinary("coordinates",ensightGeometryFile);
1258 writeEnsDataBinary(nPoints,ensightGeometryFile);
1260 for (direction d=0; d<vector::nComponents; d++)
1262 //writePointsBinary(points.component(d), ensightGeometryFile);
1263 writeEnsDataBinary(points.component(d), ensightGeometryFile);
1264 pointOffsets[0] = points.size();
1266 for (int slave=1; slave<Pstream::nProcs(); slave++)
1268 IPstream fromSlave(Pstream::scheduled, slave);
1269 scalarField pointsComponent(fromSlave);
1270 //writePointsBinary(pointsComponent, ensightGeometryFile);
1271 writeEnsDataBinary(pointsComponent, ensightGeometryFile);
1272 pointOffsets[slave] =
1273 pointOffsets[slave-1]
1274 + pointsComponent.size();
1280 for (direction d=0; d<vector::nComponents; d++)
1282 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
1283 toMaster<< points.component(d);
1290 meshCellSets_.nHexesWedges,
1291 map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
1299 meshCellSets_.nPrisms,
1300 map(cellShapes, meshCellSets_.prisms),
1308 meshCellSets_.nPyrs,
1309 map(cellShapes, meshCellSets_.pyrs),
1317 meshCellSets_.nTets,
1318 map(cellShapes, meshCellSets_.tets),
1323 if (meshCellSets_.nPolys)
1325 if (Pstream::master())
1330 << setw(10) << meshCellSets_.nPolys << nl;
1334 meshCellSets_.polys,
1341 for (int slave=1; slave<Pstream::nProcs(); slave++)
1343 IPstream fromSlave(Pstream::scheduled, slave);
1344 labelList polys(fromSlave);
1345 cellList cellFaces(fromSlave);
1346 faceList faces(fromSlave);
1353 pointOffsets[slave-1],
1360 OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
1361 toMaster<< meshCellSets_.polys << cellFaces << faces;
1367 label ensightPatchi = 2;
1371 forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
1374 const labelList& patchProcessors = iter();
1376 if (!patchNames_.size() || patchNames_.found(iter.key()))
1378 const word& patchName = iter.key();
1379 const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
1381 const labelList *trisPtr = NULL;
1382 const labelList *quadsPtr = NULL;
1383 const labelList *polysPtr = NULL;
1385 const pointField *patchPointsPtr = NULL;
1386 const faceList *patchFacesPtr = NULL;
1388 if (patchIndices_.found(iter.key()))
1390 label patchi = patchIndices_.find(iter.key())();
1391 const polyPatch& p = mesh_.boundaryMesh()[patchi];
1393 trisPtr = &boundaryFaceSets_[patchi].tris;
1394 quadsPtr = &boundaryFaceSets_[patchi].quads;
1395 polysPtr = &boundaryFaceSets_[patchi].polys;
1397 patchPointsPtr = &(p.localPoints());
1398 patchFacesPtr = &(p.localFaces());
1401 const labelList& tris = *trisPtr;
1402 const labelList& quads = *quadsPtr;
1403 const labelList& polys = *polysPtr;
1404 const pointField& patchPoints = *patchPointsPtr;
1405 const faceList& patchFaces = *patchFacesPtr;
1407 if (nfp.nTris || nfp.nQuads || nfp.nPolys)
1409 labelList patchPointOffsets(Pstream::nProcs(), 0);
1411 if (Pstream::master())
1413 writeEnsDataBinary("part",ensightGeometryFile);
1414 writeEnsDataBinary(ensightPatchi++,ensightGeometryFile);
1415 //writeEnsDataBinary(patchName.c_str(),ensightGeometryFile);
1416 writeEnsDataBinary(iter.key().c_str(),ensightGeometryFile);
1417 writeEnsDataBinary("coordinates",ensightGeometryFile);
1418 writeEnsDataBinary(nfp.nPoints,ensightGeometryFile);
1420 for (direction d=0; d<vector::nComponents; d++)
1427 patchPoints.component(d),
1432 patchPointOffsets = 0;
1435 forAll (patchProcessors, i)
1437 if (patchProcessors[i] != 0)
1439 label slave = patchProcessors[i];
1440 IPstream fromSlave(Pstream::scheduled, slave);
1441 scalarField patchPointsComponent(fromSlave);
1446 patchPointsComponent,
1450 if (i < Pstream::nProcs()-1)
1452 patchPointOffsets[i+1] =
1453 patchPointOffsets[i]
1454 + patchPointsComponent.size();
1459 if (i < Pstream::nProcs()-1)
1461 patchPointOffsets[i+1] =
1462 patchPointOffsets[i]
1463 + patchPoints.size();
1469 else if (patchPointsPtr)
1471 for (direction d=0; d<vector::nComponents; d++)
1478 toMaster<< patchPoints.component(d);
1482 writeAllFacePrimsBinary
1493 writeAllFacePrimsBinary
1504 writeAllFacePrimsBinary
1519 if (Pstream::master())
1521 delete ensightGeometryFilePtr;
1525 // ************************ vim: set sw=4 sts=4 et: ************************ //