Skip to content
Snippets Groups Projects
Commit f22ba88d authored by mattijs's avatar mattijs
Browse files

ENH: extrudeMesh: allow flipNormals for extrude-from-patch

parent 3f8aefc4
Branches
Tags
No related merge requests found
......@@ -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.
......
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment