How to plot normal unit vector of faces in a 2D mesh?

The facet normal of an interior interface to either side as discussed here: Integrating over an interior surface
You can the project this restriction to a CG1-space and visualize it with Paraview.
Code for projecting a normal to a exterior interface has been done at: How to compute curvature of a boundary
and looks like. This can easily be modified for an interior interface.

mesh = Mesh(UnitDiscMesh.create(MPI.comm_world, 100, 1, 2))
n = FacetNormal(mesh)
V = VectorFunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(u,v)*ds
l = inner(n, v)*ds
A = assemble(a, keep_diagonal=True)
L = assemble(l)

A.ident_zeros()
nh = Function(V)

solve(A, nh.vector(), L)
File("nh.pvd") << nh
5 Likes