diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 8ad9a47b89ee2af9c53e7874d0ebe499093a0359..b590eb31cd67383146216cfbdc4f211a38397137 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -989,11 +989,15 @@ private: labelList& neighbour ) const; - //- Rotates a face by an amount nPos - face rotateFace + //- Create an empty fvMesh + autoPtr<fvMesh> createDummyMesh ( - const face& f, - const label nPos + const IOobject& io, + const wordList& patchTypes, + const wordList& patchNames, + const labelList& patchSizes, + const labelList& patchStarts, + const labelList& procNeighbours ) const; //- Rotate the faces on processor patches if necessary diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index 49c4fe71fa7aaa135d9d828c15f89cbe3a458073..ab7ce33f8563760f144c6aff33f6893a1a7e0078 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -562,27 +562,61 @@ void Foam::conformalVoronoiMesh::writeMesh } -Foam::face Foam::conformalVoronoiMesh::rotateFace +Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh ( - const face& f, - const label nPos + const IOobject& io, + const wordList& patchTypes, + const wordList& patchNames, + const labelList& patchSizes, + const labelList& patchStarts, + const labelList& procNeighbours ) const { - face newF(f.size()); + autoPtr<fvMesh> meshPtr + ( + new fvMesh + ( + io, + xferCopy(pointField()), + xferCopy(faceList()), + xferCopy(cellList()) + ) + ); + fvMesh& mesh = meshPtr(); - forAll(f, fp) - { - label fp1 = (fp + nPos) % f.size(); + List<polyPatch*> patches(patchStarts.size()); - if (fp1 < 0) + forAll(patches, patchI) + { + if (patchTypes[patchI] == processorPolyPatch::typeName) { - fp1 += f.size(); + patches[patchI] = new processorPolyPatch + ( + patchNames[patchI], + 0, //patchSizes[p], + 0, //patchStarts[p], + patchI, + mesh.boundaryMesh(), + Pstream::myProcNo(), + procNeighbours[patchI] + ); + } + else + { + patches[patchI] = polyPatch::New + ( + patchTypes[patchI], + patchNames[patchI], + 0, //patchSizes[p], + 0, //patchStarts[p], + patchI, + mesh.boundaryMesh() + ).ptr(); } - - newF[fp1] = f[fp]; } + mesh.addFvPatches(patches); - return newF; + return meshPtr; } @@ -599,51 +633,28 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches const labelList& procNeighbours ) const { - fvMesh tempMesh + // Create dummy mesh with correct proc boundaries to do sorting + autoPtr<fvMesh> sortMeshPtr ( - IOobject + createDummyMesh ( - meshName, - instance, - runTime_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - xferCopy(pointField()), - xferCopy(faceList()), - xferCopy(cellList()) - ); - - List<polyPatch*> patches(patchStarts.size()); - - forAll(patches, p) - { - if (patchTypes[p] == processorPolyPatch::typeName) - { - patches[p] = new processorPolyPatch - ( - patchNames[p], - patchSizes[p], - patchStarts[p], - p, - tempMesh.boundaryMesh(), - Pstream::myProcNo(), - procNeighbours[p] - ); - } - else - { - patches[p] = polyPatch::New + IOobject ( - patchTypes[p], - patchNames[p], - patchSizes[p], - patchStarts[p], - p, - tempMesh.boundaryMesh() - ).ptr(); - } - } + meshName, + instance, + runTime_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + patchTypes, + patchNames, + patchSizes, + patchStarts, + procNeighbours + ) + ); + const fvMesh& sortMesh = sortMeshPtr(); // Rotation on new faces. labelList rotation(faces.size(), 0); @@ -651,11 +662,13 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches PstreamBuffers pBufs(Pstream::nonBlocking); // Send ordering - forAll(patches, patchI) + forAll(sortMesh.boundaryMesh(), patchI) { - if (isA<processorPolyPatch>(*patches[patchI])) + const polyPatch& pp = sortMesh.boundaryMesh()[patchI]; + + if (isA<processorPolyPatch>(pp)) { - static_cast<processorPolyPatch*>(patches[patchI])->initOrder + refCast<const processorPolyPatch>(pp).initOrder ( pBufs, primitivePatch @@ -677,15 +690,17 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches // Receive and calculate ordering bool anyChanged = false; - forAll(patches, patchI) + forAll(sortMesh.boundaryMesh(), patchI) { - if (isA<processorPolyPatch>(*patches[patchI])) + const polyPatch& pp = sortMesh.boundaryMesh()[patchI]; + + if (isA<processorPolyPatch>(pp)) { labelList patchFaceMap(patchSizes[patchI], -1); labelList patchFaceRotation(patchSizes[patchI], 0); bool changed = - static_cast<processorPolyPatch*>(patches[patchI])->order + refCast<const processorPolyPatch>(pp).order ( pBufs, primitivePatch @@ -727,7 +742,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches { if (rotation[faceI] != 0) { - faces[faceI] = rotateFace(faces[faceI], rotation[faceI]); + faces[faceI] = faces[faceI].rotateFace(rotation[faceI]); } } } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index 3211df15140eb845406ef9fff78a882eab66029c..5a593f0bf1840bfbaa95278cb18ce65ac2b80d64 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -633,6 +633,27 @@ Foam::face Foam::face::reverseFace() const } +Foam::face Foam::face::rotateFace(const label nPos) const +{ + const labelList& f = *this; + labelList newList(size()); + + forAll(f, fp) + { + label fp1 = (fp + nPos) % f.size(); + + if (fp1 < 0) + { + fp1 += f.size(); + } + + newList[fp1] = f[fp]; + } + + return face(xferMove(newList)); +} + + Foam::label Foam::face::which(const label globalIndex) const { const labelList& f = *this; diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index c1c9716c03f4f55ee1f62e232f94b168d20c8c1e..3b2ffcc757a961435746c72843260f66b882343b 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -197,6 +197,9 @@ public: // The starting points of the original and reverse face are identical. face reverseFace() const; + //- Rotate face by number of positions + face rotateFace(const label nPos) const; + //- Navigation through face vertices //- Which vertex on face (face index given a global index) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 9b14aae0df11d22cfe663da68cfcd164a8efddd1..58a897666b51489b796780d25628ebcaefa395f9 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -1890,30 +1890,6 @@ void Foam::polyTopoChange::calcFaceZonePointMap } -Foam::face Foam::polyTopoChange::rotateFace -( - const face& f, - const label nPos -) -{ - face newF(f.size()); - - forAll(f, fp) - { - label fp1 = (fp + nPos) % f.size(); - - if (fp1 < 0) - { - fp1 += f.size(); - } - - newF[fp1] = f[fp]; - } - - return newF; -} - - void Foam::polyTopoChange::reorderCoupledFaces ( const bool syncParallel, @@ -2024,7 +2000,7 @@ void Foam::polyTopoChange::reorderCoupledFaces { if (rotation[faceI] != 0) { - faces_[faceI] = rotateFace(faces_[faceI], rotation[faceI]); + faces_[faceI] = faces_[faceI].rotateFace(rotation[faceI]); } } } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index 6feac49d7574d00f00067bf47cc797b8d083318a..476a406223c6ffd925d8b81e4d44ec8219b09280 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -363,9 +363,6 @@ class polyTopoChange // Coupling - //- Rotate face by number of positions - static face rotateFace(const face& f, const label nPos); - //- Do all coupled patch face reordering void reorderCoupledFaces (