krober10nd / SeismicMesh

2D/3D serial and parallel triangular mesh generation tool for finite element methods.
https://seismicmesh.readthedocs.io/
GNU General Public License v3.0
129 stars 33 forks source link

Stretching+SDF viz #198

Closed krober10nd closed 3 years ago

krober10nd commented 3 years ago
krober10nd commented 3 years ago

198

lgtm-com[bot] commented 3 years ago

This pull request introduces 1 alert when merging b0238e94db981f4428985abcbfbb4e8817bf5a62 into 8e77d0538179c923013dc5d1f41257e8a2cc6916 - view on LGTM.com

new alerts:

krober10nd commented 3 years ago

Hey @nschloe I'm trying to implement the stretching for SDFs in both 2D (and 3D) following basically what you did here https://github.com/nschloe/dmsh/blob/main/dmsh/geometry/stretch.py

seems to work great in 2D, but in 3D it starts doing some strange stuff. Mesh sizes are altered (even though the mesh is supposed to be uniform) and quality is not good.

Any ideas what that may causing that?

I suspect it may be because the stretching distorts the element sizes and the projection back to the unstretched space to evaluate the SDF leads to poor quality triangles.

Any ideas or help would be greatly appreciated!

nschloe commented 3 years ago

Are you stretching the geometry or the mesh?

krober10nd commented 3 years ago

Geometry.

nschloe commented 3 years ago

Then mesh sizes should not me affected at all of course. The generator itself shouldn't know if if the geometry was created using a stretch or in any other way. I'd probably take a stretched geometry that exhibits the strange behavior and try to reproduce the geometry without stretching. (Think cube + stretch = cuboid.)

krober10nd commented 3 years ago

That make sense. Will try to do that and see what happens. Thanks!

krober10nd commented 3 years ago

@nschloe was a simple typo in the application of the stretching for 3D. I also made a simple domain.show() method that can help you figure out what the 0-level set looks like.

testing2

nschloe commented 3 years ago

domain.show() looks suspiciously like ParaView. ;)

krober10nd commented 3 years ago

heh.

krober10nd commented 3 years ago

testing This is domain.show() very primitive.

nschloe commented 3 years ago

Perhaps it'd be more informative if you only showed the points with values below zero, i.e., the actual domain.

krober10nd commented 3 years ago

Yes. Could be a lot easier to see especially when you start intersecting them in 3d.

krober10nd commented 3 years ago

Alright, this just plots the points near the 0-level set.

 import meshio
 from SeismicMesh import *

 domain = Rectangle((0.0, 1.0, 0.0, 1.0), stretch=[2.0, 1.0], rotate=0.3 * 3.14)
 domain.show(samples=1000000)
 points, cells = generate_mesh(domain=domain, edge_length=0.10)
 meshio.write_points_cells("test.vtk", points, [("triangle", cells)])

ApproximateLevelSet

nschloe commented 3 years ago

This looks very good.