# Explicite determination of DOFs of a pice-wise RT space

Hello,

I need to explicitly calculate some DOFs of a first order, pice-wise Raviart-Thomas space and then store them into the global solution vector. Unfortunately, my formulas assume, that the facet normal are always outward pointing, which is not the case in the reference element.

Let say we have a global facet: My initial thought was to determine the cell-local facet id and then check whether or not the facet normal of the reference element is outward pointing. If so, everything is fine, otherwise I would have to change the sign of the DOF, when storing it to the global vector. As the RT-Space is only pice-wise, as far as I understood, not permutations to keep the normal direction consistent for both elements sharing the facet is required.To check this assumption, I constructed the below given mesh and function space and tried to interpolate a function from the DG0-Space into my pice-wise RT space.

``````import numpy as np
from mpi4py import MPI

import basix
import dolfinx
import dolfinx.fem as dfem
import dolfinx.mesh as dmesh

# Create mesh
msh = dmesh.create_rectangle(MPI.COMM_WORLD, [np.array([0, 0]), np.array([2, 2])], [10, 10],
cell_type=dmesh.CellType.triangle, diagonal=dmesh.DiagonalType.crossed)

# Create pice-wise RT space
P_flux = basix.create_element(basix.ElementFamily.RT, basix.CellType.triangle,
fluxorder, basix.LagrangeVariant.equispaced, True)
V_flux = dfem.FunctionSpace(msh, basix.ufl_wrapper.BasixElement(P_flux))
F_flux = dfem.Function(V_flux)
``````

Taking exemplarily the (global) facet 282 shows, that my suggestion is wrong. Based on the entity-connectivity (2->1) facet 282 is locally the second facet in both element (171 and 186). Based on the reference cell, the facet-normal of the second facet on a triangle points into the cell. Within the below given picture I extracted the relevant values, to determine the RT-DOFs:

Based on the above example, the absolute values of the DOFs are quite easy to calculate. I simply take the scalar product of u with the normal (1, 0) and multiply it with the length of the facet. Question is now the sign within the global solution vector. Focusing on the cell 186 – the case where my suggestion seems to be wrong – the absolute value of the facet DOF is 0.00483. As the Reference facet normal points into the cell but u is pointing out of the cell, I thought the global sign its negative. Actually, the opposite is the case. Any suggestions how to determine the correct sign of the DOF would be very helpful.

Best wishes,
Maximilian

I think DOLFINx uses vertex numbers to decide on these orientations, something like this:

• Edges are oriented to point from the lower vertex number to the higher number.
• Normals to edges are a 90° rotation of the edge orientations (in 2D meshes at least)
• RT basis functions are oriented by these normals

Hello,

thank you for your reply! But does that mean, that the local orientation of the facet normal (which is stored as an ID within the basix-element) does not determine the orientation of the RT functions. Or in other words: If we extract the cell permutation data for a given cell (2D), and find out, that an edge is reverted, we could simply switch the identifier of the orientation of the reference normal and get thereby the orientation of the global normal respectively the knowledge if the RT functions of the actual cell-facet are based on an inward or outward normal?

Beste wishes,
Maximilian

Yes, if there’s a mismatch between Basix’s reference orientation and the orientation in the mesh, the orientation will be swapped during the push forward/pull back.

We wrote this up in “Construction of arbitrary order finite element degree-of-freedom maps on polygonal and polyhedral cell meshes” [doi: 10.1145/3524456, arXiv] if you want to see all the detail of how we do this.

Hallo,

my apologies for my late response. I’ve red the paper, prior to posting this question.

If I evaluate the permutation of facet 282 with respect to cell 186 (get_facet_permutations()[186*3+2]) I get the value zero. So there is no permutation, or in other words, the direction of the facet normal is not reversed due to differences between reference and actual cell. But this makes the determination of the sign of the DOF in the global DOF-vector a bit tricky. As there is no permutation I assumed, that I could determine this sign, by comparison of the direction of the reference normal (into the cell) and the direction of the vector, which we interpolated into the DRT space (out of the cell). But as described above, this does not work

The only thing that’s left is now the Piola mapping between reference and actual cell. Is it possible, that this changes not only the direction of the normal, but also its orientation with respect to the cell (normal is inward resp. outward pointing)?

Thanks for your help!
Maximilian