diff --git a/src/conversion/ensight/mesh/ensightMesh.C b/src/conversion/ensight/mesh/ensightMesh.C index 72c7856201..b769c2b154 100644 --- a/src/conversion/ensight/mesh/ensightMesh.C +++ b/src/conversion/ensight/mesh/ensightMesh.C @@ -342,7 +342,7 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const ( pp.meshPoints(), pp.meshPointMap(), - pointToGlobal, // local patch point to unique global index + pointToGlobal, // local point to unique global index uniqueMeshPointLabels // unique global points ); @@ -376,43 +376,43 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const const word& zoneName = zoneNames[zonei]; const ensightFaces& ensFaces = faceZoneFaces_[zoneName]; - label zoneId = mesh_.faceZones().findZoneID(zoneName); - const faceZone& fz = mesh_.faceZones()[zoneId]; + // Use the properly sorted faceIds (ensightFaces) and do NOT use the + // faceZone directly, otherwise the point-maps will not correspond. + // - perform face-flipping later - // Renumber the faceZone points/faces into unique points + indirectPrimitivePatch pp + ( + IndirectList(mesh_.faces(), ensFaces.faceIds()), + mesh_.points() + ); + + // Renumber the points/faces into unique points labelList pointToGlobal; labelList uniqueMeshPointLabels; autoPtr globalPointsPtr = mesh_.globalData().mergePoints ( - fz().meshPoints(), - fz().meshPointMap(), - pointToGlobal, - uniqueMeshPointLabels + pp.meshPoints(), + pp.meshPointMap(), + pointToGlobal, // local point to unique global index + uniqueMeshPointLabels // unique global points ); - // Make a copy in the proper order - primitiveFacePatch pp - ( - faceList(mesh_.faces(), ensFaces.faceIds()), - mesh_.points() - ); - + // Renumber the faces belonging to the faceZone, + // from local numbering to unique global index. + // Also a good place to perform face flipping const boolList& flip = ensFaces.flipMap(); - forAll(pp, facei) + faceList patchFaces(pp.localFaces()); + forAll(patchFaces, facei) { + face& f = patchFaces[facei]; + if (flip[facei]) { - pp[facei].flip(); + f.flip(); } - } - // Renumber the faces belonging to the faceZone, - // from local numbering to unique global index - faceList patchFaces(pp.localFaces()); - forAll(patchFaces, i) - { - inplaceRenumber(pointToGlobal, patchFaces[i]); + inplaceRenumber(pointToGlobal, f); } writeAllPoints diff --git a/src/conversion/ensight/mesh/ensightMeshIO.C b/src/conversion/ensight/mesh/ensightMeshIO.C index f8bc9230c2..4337a95c15 100644 --- a/src/conversion/ensight/mesh/ensightMeshIO.C +++ b/src/conversion/ensight/mesh/ensightMeshIO.C @@ -121,6 +121,7 @@ void Foam::ensightMesh::writeFaceSizes const face& f = faceLst[i]; os.write(f.size()); + os.newline(); } } @@ -136,6 +137,7 @@ void Foam::ensightMesh::writeFaceSizes const face& f = faceLst[i]; os.write(f.size()); + os.newline(); } } @@ -173,10 +175,13 @@ void Foam::ensightMesh::writePolysNFaces ensightGeoFile& os ) const { + // write the number of faces per element (1/line in ASCII) forAll(addr, i) { - const labelList& cf = cellFaces[addr[i]]; + const labelUList& cf = cellFaces[addr[i]]; + os.write(cf.size()); + os.newline(); } } @@ -189,13 +194,15 @@ void Foam::ensightMesh::writePolysNPointsPerFace ensightGeoFile& os ) const { + // write the number of points per element face (1/line in ASCII) forAll(addr, i) { - const labelList& cf = cellFaces[addr[i]]; + const labelUList& cf = cellFaces[addr[i]]; - forAll(cf, faceI) + forAll(cf, facei) { - os.write(faces[cf[faceI]].size()); + os.write(faces[cf[facei]].size()); + os.newline(); } } } @@ -213,11 +220,11 @@ void Foam::ensightMesh::writePolysPoints forAll(addr, i) { const label cellId = addr[i]; - const labelList& cf = cellFaces[cellId]; + const labelUList& cf = cellFaces[cellId]; - forAll(cf, faceI) + forAll(cf, facei) { - const label faceId = cf[faceI]; + const label faceId = cf[facei]; const face& f = faces[faceId]; // face points (in global points) if (faceId < faceOwner.size() && faceOwner[faceId] != cellId)