Contrib snapEdgeDescription

From OpenFOAMWiki

This is the old snapEdge algorithm. I will write down the new algorithm once I get the time.

The idea behind snapEdge is pretty straightforward and I will try to describe it below. The implementation however was not straightforward (as I thought it would be), but below is a description of how I want it to work.


The first step is to extract the features from the STL.

An STL is just a collection of triangles and every edge thus has 2 triangles associated to it.

If it doesnt, it is a an edge and will be added to the feature lines.

Otherwise the dot product of the face normals is calculated (and normalized)

If it is equal to 1 it means that the two planes are parallel and if it is equal to 0 the planes are perpendicular.

The feaureAngle then decides which edges should be included in the features used for the snapping.


The next step is to perform the same operation on the patches. (This step requires special care for parallel processing as it may extract false edges on the processor boundaries, which has not yet been included)

We now have a set of (mesh) edges that we want to attach (or snap) to the feature lines.


The third step is to loop over all the features and for each edge we calculate the distance for both points to that feature. If the distance to the feature is smaller than the tolerance * | edge length | we associate that edge to that feature line. It also needs to have the closest point inside the 2 points on the feature line. Note that the 2 points on the edge does not have to belong to the same feature.

If the edge already is associated with another feature line we check which one is best suited among the two features. This is based on angle and distance to the feature line. An edge may be close to the feature but is disregarded if the angle is too large.

After this step the 2 points on every edge have a final destination point on the associated feature line. This is the position to which the point want to move.


The fourth step is to check for overlaps. Two edges may be mapped in such a way that they occupy the same segment on the feature line. Thus every final destination point for each edge is mapped to other final destination points edges. If they overlap we need to decide which one we want to actually move, the other edge will be ignored.. This is also based on angle and proximity. Although a point may be close it shouldn't be mapped if the edge is not parallell enough. This is set by the parallellAngle criteria. If the edge angles are below this, the closest point will be chosen, ottherwise the angle will decide.

We now have all the info we need to move the points and the last step is to actually move the points. However, we do not move them to the edge in 1 go, since I have found that it is more stable to use underrelaxation as this will capture corners better.

There is also a reason why we associated edges to features and not points as this will allow a point to be associated with multiple features and corners can be captured better.

--Niklas 20:13, 7 September 2010 (CEST)