meshpro / dmsh

:spider_web: Simple mesh generator inspired by distmesh.
GNU General Public License v3.0
210 stars 26 forks source link

Mesh on 3D-surface #1

Closed shengdie closed 5 years ago

shengdie commented 5 years ago

Hello,

Thank you for your work, could you please implement the 3d-surface mesh like sphere? I tried by myself, but I am not familiar with matlab. Thank you.

gdmcbain commented 5 years ago

Interesting but I suspect nontrivial. Meanwhile, there are a couple of routines for the sphere in meshzoo.

shengdie commented 5 years ago

I knew it, but it is not based on force balance. I like distmesh, because it generates most equilateral triangles, which is important in FEM simulations. distmesh offers matlab code for 3d-surface mesh, but I can't read it😞

Geordie McBain notifications@github.com 于2019年6月23日周日 下午8:33写道:

Interesting but I suspect nontrivial. Meanwhile, there are a couple of routines for the sphere in meshzoo https://github.com/nschloe/meshzoo#sphere-surface.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nschloe/dmsh/issues/1?email_source=notifications&email_token=ABVUYFN6RS3LKZEPB3CBAQ3P4AI7NA5CNFSM4H22EEOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLK2ZY#issuecomment-504802663, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVUYFLFQ7UQOF25VHZSX5DP4AI7NANCNFSM4H22EEOA .

nschloe commented 5 years ago

Would be nice to have. Link to code?

shengdie commented 5 years ago

Would be nice to have. Link to code?

In the official site, distmeshsurface.m http://persson.berkeley.edu/distmesh/distmesh.zip

nschloe commented 5 years ago

Way too complicated for me to dive in like that. PRs welcome.

nschloe commented 5 years ago

I knew it, but it is not based on force balance. I like distmesh, because it generates most equilateral triangles

I've improved icosa sphere in meshzoo a bit yesterday. In general, you can't get much better than that.

iso

nschloe commented 5 years ago

Alright, it turns out you can actually do a little bit better. I've just added support for surface meshes to optimesh (https://twitter.com/nschloe/status/1184605182396641280), so here's how you get the best spherical mesh:

import meshzoo
import optimesh

points, cells = meshzoo.icosa_sphere(10)

class Sphere:
    def f(self, x):
        return 1.0 - (x[0] ** 2 + x[1] ** 2 + x[2] ** 2)

    def grad(self, x):
        return -2 * x

points, cells = optimesh.cvt.quasi_newton_uniform_full(
    points, cells, 1.0e-2, 100, verbose=False,
    implicit_surface=Sphere(),
    # step_filename_format="out{:03d}.vtk"
)

opt

dmsh definitely won't be able to do any better, so let's close this.