dolfin.mesh.refinement.refine(mesh, cell_markers=None, redistribute=True)

Refine given mesh and return the refined mesh.

the Mesh to be refined.
an optional argument (a boolean MeshFunction over cells) may be given to specify which cells should be refined. If no cell markers are given, then the mesh is refined uniformly.
an optional argument (boolean) may be given to set whether to redistribute the mesh across processes following refinement. The is relevant only when the mesh is distributed across processes. In serial the argument has no impact. Default it True.

Examples of usage

mesh = refine(mesh)

To only refine cells with too large error, define a boolean MeshFunction over the mesh and mark the cells to be refined as True.

cell_markers = CellFunction("bool", mesh)
for cell in cells(mesh):
    # set cell_markers[cell] = True if the cell's error
    # indicator is greater than some criterion.
mesh = refine(mesh, cell_markers)