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

Maximum mesh size

+1 vote

Is there a way to have the maximum mesh size???

I've read the related question but the solution doesn't seem to work. This function MaxCellEdgeLength(domain) should return a real positive number right? Why using the code below the output is a string "maxcelledgelength"?????

from dolfin import *
from mshr import *
import numpy  as np

# Create mesh
xlim, ylim = 2., 4.
size = 10*2
domain = Rectangle(Point(0., 0.), Point(xlim, ylim))
mesh = generate_mesh(domain,size)
hmax = MaxCellEdgeLength(mesh)
print hmax
related to an answer for: Max cell edge length
asked May 31, 2017 by caterinabig FEniCS User (1,460 points)

1 Answer

+2 votes
 
Best answer

Hi, MaxCellEdgeLength(mesh) is not a number (as can be verified by checking the its type). The object is to be used in defining a form. Consider the following instead.

answered May 31, 2017 by MiroK FEniCS Expert (80,920 points)
selected Jun 1, 2017 by caterinabig

Thank you.

So the function to use is hmax = mesh.hmax()

And do you know if there is a way to have the opposite results? I mean, is it possible to have a mesh with a prescribed hmax? Instead of prescribing the number of segments in which we split the edge, i.e. size in my code.

This should be possible with mshr or gmsh mesh generators. For the former see here.

...