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

How to do mesh smoothing when creating a mesh by FEniCS

+1 vote

Dear all

I find that sometimes the mesh generated by cgal in FEniCS is not very regular,
i.e., some elements seem to too small or too large. So is there any command that
can smooth internal vertices of mesh by local averaging. Please see the following
simple code for example. I hope to make every element has the same size.

Any help is welcome. Thank you~

from dolfin import *

domain = Rectangle(0., 0., 1., 1.) + Circle(0.5, 1, .5)
mesh2d = Mesh(domain, 5)
plot(mesh2d, "2D mesh")

interactive()
asked Oct 1, 2014 by Huadong Gao FEniCS Novice (230 points)
edited Oct 1, 2014 by johannr

Did you encounter any particular problems? The element size may be related to the boundary curvature etc. to ensure a good geometric representation of your actual domain. So what is wrong with the generated meshes? Of course you can always optimize your mesh afterwards, but the question which mesh is 'optimal' typically depends on your type of problem.

Dear Christian Waluga

Thank you very much for your help. You are right. I just want to
make the mesh smoother, i.e., every triangle has the same size.
Is there any built-in FEniCS command for mesh smoothing?

Thank you again~

Huadong

1 Answer

+1 vote
 
Best answer

Hi, smoothing by local averaging is done by the smooth method

from dolfin import *

domain = Rectangle(0., 0., 1., 1.) + Circle(0.5, 1, .5)
mesh2d = Mesh(domain, 5)

plot(mesh2d, title="before smooth", interactive=True)
mesh2d.smooth(20)
plot(mesh2d, title="after smooth", interactive=True)
answered Oct 4, 2014 by MiroK FEniCS Expert (80,920 points)
selected Oct 11, 2014 by Huadong Gao

MiroK, Thank you very much~

...