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

How to find direction / relative orientation / definiton of edge-related dofs in N1curl space

0 votes

The questions says all. It sounds very basic but I couldn't find any (easy) solution. Is there something similar like the "Cell.orientation()" parameter to find the relative or absolute direction of an edge-dof of a N1curl element?

I want to apply the correct sign for source term contributions, manually integrated as line integral over the according edge. I know there have been several questions about line integrals in 3D (e.g. : https://fenicsproject.org/qa/3569/edge-moments-for-nedelec-elements-in-3d), I assume there is still no FEniCS internal functionality for this?

asked Apr 24, 2017 by RR FEniCS User (3,330 points)

1 Answer

+1 vote
 
Best answer

Hi, the edge orientation is described in Marie Rognes's paper. If you prefer more hands on experience, consider the following experiment

from dolfin import *
import numpy as np

mesh = UnitCubeMesh(10, 2, 3)
V = FunctionSpace(mesh, 'N1curl', 1)  

# Let's conjecture that given edge (v0_index, v1_index) fenics sets the tangent
# in direction of vertices[v1_index]-vertices[v0_index]. Now for N1curl the dofs
# are int_edge edge_tangent*u. If we pass our tangent as u we shall see by the sign
# of dof evaluation if the tangent is right

Vdmap = V.dofmap()
x = mesh.coordinates()

u = Expression(('t0', 't1', 't2'), t0=0, t1=0, t2=0, degree=0)

mesh.init(3, 1)
mesh.init(1, 0)
elm = V.dolfin_element()
for cell in cells(mesh):
    cell_dofs = Vdmap.cell_dofs(cell.index())
    for ei, edge in enumerate(edges(cell)):
        v0, v1 = edge.entities(0)
        tau = x[v1]-x[v0]
        tau /= np.linalg.norm(tau)

        u.t0, u.t1, u.t2 = tau[0], tau[1], tau[2]

        sign = (1./edge.length())*elm.evaluate_dof(ei, 
                                                   u,
                                                   cell.get_vertex_coordinates(),
                                                   cell.orientation(),
                                                   cell)
        assert near(sign, 1.0, 1E-12) 
answered Apr 25, 2017 by MiroK FEniCS Expert (80,920 points)
selected Apr 25, 2017 by RR

Great answer, thank you!

...