Hello,
I have an oriented triangulated surface mesh in $\mathbb{R}^3$ given as a Fenics XML file.
The orientation is given in terms of the ordering of the vertices for each <triangle>
tag. In particular, if a triangle is given by
$t=[v_0, v_1, v_2]$ then there is an induced normal direction by this ordering, say, we always take
$n = \mathrm{normalize}(e_1 \times e_2)$ where $e_1 := p_1 - p_0$ and $e_2 := p_2 - p_0$, and $p_i$ are the geometric points corresponding to vertex indices $v_i$.
My orientation of the triangles is consistent in the sense that the normals computed this way all point either "upwards" or "downwards", but don't flip.
I now try to mimic this in Fenics by deriving from Expression:
class MySurfaceNormal(Expression):
def __init__
...
def eval_cell(self, values, x, ufc_cell):
cell = Cell(self._mesh, ufc_cell.index)
n = cell.cell_normal()
values[0] = n[0]
values[1] = n[1]
values[2] = n[2]
However the resulting normals are not consistently oriented - some point upwards, some downwards, though the normal space they span looks pretty correct. My guess is that this has to do with Dolfin's internal (local?) indexing scheme for vertex coordinates. A quick look at dolfin/io/XMLMesh::read_mesh
suggests that at least the import preserves the order of the indices in each cell, so I probably haven't understood completely the local indexing or connectivity
vector in MeshTopology
, or mixed up something else (maybe with DoF indices?).
Q: How can I get the normals for the surface mesh that come from the initial vertex ordering in each triangle, following the choice of cross product mentioned above?
I am aware of Marie Rognes' nice article on solving PDEs on the Moebius strip and sphere, but there she's using a global normal field to define the orientation of each cell, using init_cell_orientations
. Still, I should be able to deduce an orientation by the ordering of the triangles.
Thanks!