mesh.mark_entities() vs RelabeledMesh() #3126
-
I want to mark cells in a mesh directly with import firedrake as fd
from firedrake import conditional, And, Or
from firedrake.cython.dmcommon import CELL_SETS_LABEL
def test_mark_entities_mesh_mark_entities_2d():
label_name = "test_label"
label_value = 999
mesh = fd.UnitSquareMesh(40, 8)
x, y = fd.SpatialCoordinate(mesh)
V = fd.FunctionSpace(mesh, "DP", 0)
f = fd.Function(V).interpolate(conditional(x < 0.25, 1., 0.))
mesh.mark_entities(f, label_name, label_value)
#mesh = fd.RelabeledMesh(mesh,
# [f],
# [label_value])
plex = mesh.topology.topology_dm
value = fd.assemble(fd.Constant(1.0) * fd.dx(label_value, domain=mesh))
print(value)
if __name__ == "__main__":
test_mark_entities_mesh_mark_entities_2d() but the result of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are right. This PR #3128 allows for using
with
. |
Beta Was this translation helpful? Give feedback.
You are right. This PR #3128 allows for using
label_name=CELL_SETS_LABEL
andlabel_name=FACE_SETS_LABEL
and also make them defaults.Your example will then work by replacing:
with
.