# Node renumbering in a 2D mesh

I have a 2D domain which is discretized using Q4 elements. I have the nodal positions and the element connectivity matrix. I would now like to renumber the nodes in such a way that all the interior nodes are labeled first followed the boundary nodes.

At present, the bandwidth of the stiffness matrix is not of concern. Hence the node numbers can be arbitrary as long as all the interior nodes are numbered first. Such kind of numbering makes the implementation of certain domain decomposition methods easy to write.

Can someone suggest an efficient algorithm to accomplish this?

The first idea that comes to my mind:

1. Create a multimap Edge2Quad, where edge numbers serve as keys, and quadrilateral element numbers as values.
2. Traverse all of your edges and fill the Edge2Quad multimap. $$\mathcal O(N_\text{edges})$$
3. Now, all interior edges will happen to belong to two quads, while the boundary ones will belong to exactly one.
4. By traversing your multimap, you will be able to mark the nodes as interior or boundary. $$O(N_\text{edges})$$
5. Perform node reordering. $$O(N_\text{nodes})$$

Of course, you can simplify this by using only arrays and just counting up.

• The standard Q4 element is a bilinear quadrilateral rather than a triangle, but the approach could still work with minor modification. – origimbo Jan 31 '19 at 17:05
• @origimbo thanks for pointing it out!!!! Did not read the question with the required attention. – Anton Menshov Jan 31 '19 at 17:18
• @Menshov. Thanks. Can you please elaborate step 5 in your answer - Given a set of set interior nodes and boundary nodes how does one reorder them and update the element connectivity matrix and the nodal position array. – Salil S. Kulkarni Jan 31 '19 at 17:45
• @SalilS.Kulkarni I would just use a simple local2global array of size $N_\text{nodes}$. And access elements through it. – Anton Menshov Jan 31 '19 at 18:08
• Filling and accessing the multimap is O(Nedges log(Nedges)) rather than O(Nedges) – BrunoLevy Aug 23 '20 at 17:46