This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Boundary Edge

+1 vote

Hi,

Is there a way to efficiently pull out the indices of the edges on the boundary for a 3D domain. In 2D this can easily be done by:

EdgeBoundary = BoundaryMesh(Magnetic.mesh(),"exterior").entity_map(1).array()

However, if you try to use this function for a 3D domain then you can only access the faces and vertices on the boundary but not the edges.

I also have to construct first order Nedelec elements so if there was a way to use

V = FunctionSpace(mesh, "N1curl", 1)

to obtain the boundary degrees of freedom then this would work too

asked Nov 10, 2014 by mwathen FEniCS Novice (710 points)

1 Answer

+1 vote

Hi, this is a possible solution

from dolfin import *
from numpy import concatenate as cat

mesh = UnitCubeMesh(1, 1, 1)
# Boundary cells of mesh
bdry_cells = BoundaryMesh(mesh, 'exterior').entity_map(2).array()
# Init face-edge connection
mesh.init(2, 1)
# Boundary edges of mesh
bdry_edges = set(cat([Face(mesh, f).entities(1) for f in bdry_cells]))
bdry_edges = list(bdry_edges) 
answered Nov 11, 2014 by MiroK FEniCS Expert (80,920 points)

Thanks for your help! How would I implement this in c++?

...