Skip to content
Discussion options

You must be logged in to vote

Here's an old (i.e. used to work, interfaces might have changed mildly) snippet of code that colours facets of a mesh:

from firedrake import *
from firedrake.cython import dmcommon

def mark_mesh(mesh):
    dm = mesh.topology_dm
    dim = mesh.geometric_dimension()
    sec = dm.getCoordinateSection()
    coords = dm.getCoordinatesLocal()
    dm.removeLabel(dmcommon.FACE_SETS_LABEL)
    dm.createLabel(dmcommon.FACE_SETS_LABEL)

    nface = dm.getStratumSize("exterior_facets", 1)
    if nface == 0:
        return mesh
    faces = dm.getStratumIS("exterior_facets", 1).indices

    for face in faces:
        vertices = dm.vecGetClosure(sec, coords, face).reshape(dim, dim)  # assumes simplices…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@kothah
Comment options

@pefarrell
Comment options

@kothah
Comment options

Answer selected by kothah
Comment options

You must be logged in to vote
1 reply
@kothah
Comment options

Comment options

You must be logged in to vote
1 reply
@CABA1998
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants