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

face orientation using MeshEditor

0 votes

I am creating a mesh of codimension one, i.e. a 2D-manifold in 3D space. I am using the MeshEditor. It is very important that the face orientation, that is the direction of the normal, is correct.

I tried to manipulate the orientation by changing the vertex sequence in the cell specification. A sketch of code:

    nodes = []
    cells = []
    cell_ids = []

    # fill the list with data
    for c in cells:
        # compute normal according to right-hand rule
        if wrong_direction:
            tmp = c[0]
            c[0] = c[1]
            c[1] = tmp


    mesh_editor.init_vertices(nodes.shape[0])
    mesh_editor.init_cells(cells.shape[0])

    [mesh_editor.add_vertex(i,n) for i,n in enumerate(nodes)]
    [mesh_editor.add_cell(i,c) for i,c in enumerate(cells)]
    mesh_editor.close()

Is this the correct way?

asked Jun 30, 2016 by sg FEniCS Novice (260 points)

1 Answer

0 votes

I suggest you to take a look at dolfin/mesh/BoundaryComputation.cpp, and in particular at the method BoundaryComputation::reorder. It seems to me that a similar method is being used.

Francesco

answered Jul 9, 2016 by francesco.ballarin FEniCS User (4,070 points)
...