This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Meshing a sphere with tets creates different results every time

+1 vote

Dear All

I have run into the following funny behaviour.
Creating a sphere with the short script

from dolfin import *
c=Point(0,0,0)
from dolfin  import *
c=Point(0,0,0)
S=Sphere(c,8)
# Make a 3D mesh out of the sphere
mesh=Mesh(S,16)
print mesh

the output changes from run to run!
This is very strange. I did not report it as bug yet, since I first wanted to
make sure the mistake is not on my side!

regards

Moritz

asked Jul 2, 2013 by moritzbraun FEniCS User (1,390 points)
edited Jul 2, 2013 by johannr

1 Answer

+2 votes
 
Best answer

Meshing is not a deterministic process.

answered Jul 2, 2013 by johanhake FEniCS Expert (22,480 points)
selected Jul 3, 2013 by Jan Blechta

Dear Johan

It seems I need to rather use external tools like gmsh.
Please advise as to some online resource that explains
this behaviour and motivates why this sholuld be accepted.

regards

Moritz

Hi Johan

I have found, that this happens in cgal.

Is there a way to switch the random behaviour of cgal off?

regards

Morirtz

Please advise as to some online resource that explains
this behaviour and motivates why this sholuld be accepted.

I do not understand:

Is there a way to switch the random behaviour of cgal off?

I have no clue...

Generate mesh once, store to file and reuse to ensure deterministic behaviour of your program.

from dolfin import *
try:
    mesh = Mesh('mesh.xml.gz')
except RuntimeError:
    c = Point(0, 0, 0)
    S = Sphere(c, 8)
    mesh = Mesh(S, 16)
    File('mesh.xml.gz') << mesh
print mesh

Dear Jan
Thanks a lot for your help!
This is one way of achieving it.
Thanks also for showing me the trick
of saving a dolfin mesh to a file via the << operator.

...