I guess from your vague question that you want set CellFunction
to be used for refine
function.
cell_markers = CellFunction("bool", mesh)
cell_markers.set_all(False)
Then do this
for c in cells(mesh):
if condition(c):
cell_markers[c] = True
or this
class MyDomain(SubDomain):
def inside(self, x, on_boundary):
return condition(x)
my_domain = MyDomain()
my_domain.mark(cell_markers, True)
where condition(c)
or condition(x)
is your condition on c
or x
. Note that first approach is more universal as you can base your condition on whatever property Cell
possesses. Second approach marks cell whose vertices and midpoint fulfills condition(x)
.
Finally
mesh = refine(mesh, cell_markers)