extrude issues
I was playing around with extrude_2d
and found two issues with
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import meshio
import dolfin
import mshr
# box for reference
box = mshr.Box(dolfin.Point(-3, -1, -0.1), dolfin.Point(3, 1, 0.1))
# triangle
t1 = mshr.Polygon([
dolfin.Point(2.5, -0.5, 1),
dolfin.Point(2.5, 0.5, 1),
dolfin.Point(1.5, -0.5, 1)
])
g3d = mshr.Extrude2D(t1, -2)
m = mshr.generate_mesh(box + g3d, 20, "cgal")
meshio.write(
'test.e',
m.coordinates(),
{'tetra': m.cells()}
)
-
The extrusion will always start as z-level 0, independently of the z-values of the
Polygon
points. Perhaps the extrusion can be designed a little more generally here to allow for specifying a direction of extrusion, perhaps even with a rotation angle. (Not sure what CGAL supports here, the ideas come from Gmsh.) -
There are some funny artifacts at the bottom side of the reference
Box
Comments (8)
-
-
I have pushed a fix for the problem that leads to artifacts in the box.
-
Yes, a Polygon is a 2D primitive so the points doesn't have a z component. It a design choice (in Dolfin) to use the same point class both in 2D and 3D. But maybe mshr could issue a warning if the z component is not zero when creating a polygon?
-
reporter a Polygon is a 2D primitive
Perhaps it shouldn't be? I'm not sure right now how to create a polygon extrusion that cuts through the "board" in the above example. Limiting the extrusion direction to (0,0,1) seems unnecessarily strict, too.
-
I think it is strength that any 2D geometry can be extruded to 3D.
You can translate and rotate after the extrusion. Insert eg.
g3d = mshr.CSGTranslation(g3d, dolfin.Point(0,0,1))
Was this what you meant? Maybe it would look better to just have a function
translate(g3d, Point(0,0,1))
? -
reporter I wasn't aware of translate/rotate. Thanks for the hint!
Two things aren't possible with the current extrusion:
- Extrusion at an angle, to e.g., generate an oblique cone.
- Rotation with extrusion to generate screws or turbines.
I would say those are different issues, but perhaps worthwhile thinking about.
-
Yes, sounds good! That shouldn't be too hard to implement. Could you register them as enhancements in the issue tracker?
-
- changed status to resolved
The reported bug is fixed. The proposed improvements will be registered as separate issues.
- Log in to comment
Fix orientation of extruded polygon when z is negative. Ref issue
#46.→ <<cset 560953fc3bcd>>