refine

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

Refine given mesh and return the refined mesh.

Arguments
mesh
the Mesh to be refined.
cell_markers
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.
redistribute
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)
cell_markers.set_all(False)
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)