diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 1c769a4346f59795792ed7e89d925313c21222ff..6cd54bb4614eda954bba1ae30615386d0744f11a 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -251,10 +251,10 @@ int main(int argc, char *argv[]) if (mode == PATCH || mode == MESH) { - if (flipNormals) + if (flipNormals && mode == MESH) { FatalErrorIn(args.executable()) - << "Flipping normals not supported for extrusions from patch." + << "Flipping normals not supported for extrusions from mesh." << exit(FatalError); } @@ -297,6 +297,60 @@ int main(int argc, char *argv[]) addPatchCellLayer layerExtrude(mesh, (mode == MESH)); const labelList meshFaces(patchFaces(patches, sourcePatches)); + + if (mode == PATCH && flipNormals) + { + // Cheat. Flip patch faces in mesh. This invalidates the + // mesh (open cells) but does produce the correct extrusion. + polyTopoChange meshMod(mesh); + forAll(meshFaces, i) + { + label meshFaceI = meshFaces[i]; + + label patchI = patches.whichPatch(meshFaceI); + label own = mesh.faceOwner()[meshFaceI]; + label nei = -1; + if (patchI == -1) + { + nei = mesh.faceNeighbour()[meshFaceI]; + } + + label zoneI = mesh.faceZones().whichZone(meshFaceI); + bool zoneFlip = false; + if (zoneI != -1) + { + label index = mesh.faceZones()[zoneI].whichFace(meshFaceI); + zoneFlip = mesh.faceZones()[zoneI].flipMap()[index]; + } + + meshMod.modifyFace + ( + mesh.faces()[meshFaceI].reverseFace(), // modified face + meshFaceI, // label of face + own, // owner + nei, // neighbour + true, // face flip + patchI, // patch for face + zoneI, // zone for face + zoneFlip // face flip in zone + ); + } + + // Change the mesh. No inflation. + autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false); + + // Update fields + mesh.updateMesh(map); + + // Move mesh (since morphing does not do this) + if (map().hasMotionPoints()) + { + mesh.movePoints(map().preMotionPoints()); + } + } + + + indirectPrimitivePatch extrudePatch ( IndirectList<face> @@ -471,11 +525,6 @@ int main(int argc, char *argv[]) displacement[pointI] = extrudePt - layer0Points[pointI]; } - if (flipNormals) - { - Info<< "Flipping faces." << nl << endl; - displacement = -displacement; - } // Check if wedge (has layer0 different from original patch points) // If so move the mesh to starting position. diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict index f1985fe7f65b4b6a4c205239a5eb597c9f46d8e4..e075acbc4e4b81f5e2a6393dd30009e60eab6c61 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict @@ -31,7 +31,8 @@ exposedPatchName movingWall; // If construct from surface: surface "movingWall.stl"; -// Flip surface normals before usage. +// Flip surface normals before usage. Valid only for extrude from surface or +// patch. flipNormals false; //- Linear extrusion in point-normal direction