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

bug in generate_mesh from mshr library

0 votes

Dear Friends

I have come across the following
problem.

I created a circle with radius r
using Circle from mshr

and then generate_mesh
to subdivide the mesh
I realized after the eigenvalue for a free particle in a circle with radius 2.4...( first zero of J_0)
did not converge to 1 that most of the boundary points of the mesh do not fall
on the circle .
I am actually very dependent on the mesh generating functionality in FEniCS
and need this to work urgently.

The following code demonstrates the problem

testCircle.py

from mshr import *
from dolfin import *
import sys
n=eval(sys.argv[1])
c=Circle(Point(0.,0.),1)
m=generate_mesh(c,n)
no=1
V=FunctionSpace(m,"CG",no)
def boundary(x, on_boundary):
if on_boundary:
dr=sqrt(x[0]x[0]+x[1]x[1])-1.0
if abs(dr) < 1e-8:
print dr
return on_boundary
bc = DirichletBC(V, Expression('0'), boundary)
u=TrialFunction(V)
v=TestFunction(V)
a=uvdx
b=v*dx
A,_=assemble_system(a,b,bc)

==========================
running this from the command line with
python testCircle.py 100 only finds
32 points that are exactly on the circle.
Any help will be much appreciated.

regards

Moritz

closed with the note: Please send this question to the fenics-support mailing list: http://fenicsproject.org/mailman/listinfo/fenics-support
asked Mar 30, 2015 by moritzbraun FEniCS User (1,390 points)
closed Mar 31, 2015 by johannr

Dear Johannes

The rules for which
issues are accepted and which ones are not
are not clear to me!

regards

Moritz

I ran into the same issue when 'mshr' was introduced as the default way of generating meshes for Fenics.

Just change Circle(Point(0.,0.),1) to Circle(Point(0.,0.),1,K), then the circle is approximated by a K-sided polygon. By default the mesh is a 32-sided polygon, which is why you got 32 points correctly on the circle boundary.

...