dubious mesh quality

Issue #45 duplicate
Nico Schlömer created an issue

I'm playing around with mshr and started with creating an ordinary ball,

import dolfin
from mshr import *
import meshio

ball = Sphere(dolfin.Point(0, 0, 0), 1.0)

m = generate_mesh(ball, 100, "cgal")

meshio.write('test.e', m.coordinates(), {'tetra': m.cells()})

(for some reason named Sphere in mshr). The level of refinement is quite high, but what I'm getting is sc1.png sc2.png

It appears as if a rough mesh is created once and then refined without taking the original geometry into account.

Comments (6)

  1. Benjamin Dam Kehlet

    You are right, mshr does this by triangulating the csg primitives, then evaluate the boolean operations to obtain an explicit surface description, then remeshing the surface and finally meshing the volume. The initial triangulation of the primitive is not fine enough in this case.

    The solution is to take the meshing criteria into account when triangulating the primitives, but this requires some work. I will be working on subdomain support in 3D the coming weeks and hope to also fix this as part of the effort. In the meantime there is an easy workaround: There is an optional third argument to the constructor of Sphere which controls how fine the triangulation will be. Increase this sufficiently, try eg. with 15:

    ball = Sphere(dolfin.Point(0, 0, 0), 1.0, 15)
    

    PS: Is Sphere not a good name for the primitive?

  2. Prof Garth Wells

    I expect that @nschloe's point on the name 'sphere' is something that has come up before; the object is a polyhedron rather than a sphere, and it doesn't approach a sphere upon refinement.

  3. Nico Schlömer reporter

    With 15 I'm still getting 15.png

    100 is better

    100.png

    Is Sphere not a good name for the primitive?

    Well, a sphere is the surface of a ball, so I kind of expected to get a shell mesh at first. Renaming the geometry to Ball or the mesh generation to generate_volume_mesh (whatever is more appropriate) would clear this up, but this is really a nitpick.

  4. Benjamin Dam Kehlet

    Ah, I agree, that is inconsistent. The name was taken from the old UnitSphereMesh in Dolfin, but that also seems inconsistent (since it generated a volume mesh). So lets add a generate_volume_mesh() and keep generate_mesh() for backward compatability. (At a later point I would like to add a generate_surface_mesh() also).

    @garth-wells : The object is a sphere (it is represented as a center point and a radius). The problem is that when the mesh generator is invoked, the conversion to polyhedron does not take the requested mesh resolution into account. I will fix that soon.

  5. Log in to comment