After inserting nodes in several loops the external nodes are projected on the external edges and/or faces. If an edge i on which the node lies is part of an external edge of the unrefined mesh (i.e. iexternedg(i)$ >$0) and this edge is sharp then a projection is performed on this external edge. If not, the node is projected on an external face. To this end the faces to which the node belongs are determined. For each of these faces j a check is performed whether the face is external (i.e. iexternfa(j)$ >$0). If so, a projection is performed on the correct external face of the unrefined mesh. To this end a loop is performed starting with face iexternfa(j) using the adjacency relationships stored in fields ifacexted and iedgeextfa, until the correct face is found (i.e. the condition that the projection lies inside the face). While applying the adjacency relations field isharp is used to assure that sharp edges are not crossed.

Since projection may lead to bad elements it is performed in several loops. In each loop an increasing fraction of the motion from the actual position of the node to its projection on the external surface is performed. Each time a node is moved, the Jacobian determinant of all elements belonging to its ball is checked for positivity. If any Jacobian is negative, the size of the motion for this node in this iteration is decreased by half. If after three reductions there is still an element with a negative Jacobian the node is not moved at all in this iteration. If any reduction took place all nodes belonging to the ball are listed as bad nodes for further treatment in smoothbadvertex.f.