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