LLNL / axom

CS infrastructure components for HPC applications
BSD 3-Clause "New" or "Revised" License
157 stars 27 forks source link

Generalize vertex welding capability to other mesh types #125

Open kennyweiss opened 4 years ago

kennyweiss commented 4 years ago

Quest provides a function to "weld" vertices in a triangle mesh that are closer than a user- provided distance threshold. This function identifies sets of vertices at the same location, removes duplicate vertices and updates the vertex indices in the mesh's connectivity array.

https://github.com/LLNL/axom/blob/975fc516e6b4dfd4bb82f9c8495db90a7150f8fc/src/axom/quest/MeshTester.hpp#L120-L122

We've had requests from several users to generalize this capability to more types of meshes. Specifically, this should handle unstructured quad meshes in 2D and 3D.

Based on discussions with these users, something along the lines of the following interface would be ideal:

bool weldMeshVertices(         
          array<double>& x,           // [inout] x-coords of vertex positions
          array<double>& y,           // [inout] y-coords of vertex positions
          array<double>& z,           // [inout] z-coords of vertex positions
          array<int>& connectivity    // [inout] vertex indices of mesh elements
          double eps                  // distance threshold for welding
         );                           // return true if successful

where the weldMeshVertices() function would take an array of vertex positions and the connectivity array of the mesh, and return the resultant welded mesh vertices and connectivity using the provided input arrays.

Note that the welding operation does not require knowledge of the cell types since it is merely relabeling the vertex indices.

wnissen commented 3 years ago

We have code that is doing this in a naive way, probably O(n^2). It would certainly be nice to have a spatially accelerated version.

kennyweiss commented 2 years ago

Talk to @wnissen to discuss needs/priorities.

One idea would be to take in a blueprint mesh and return a blueprint mesh.

wnissen commented 2 years ago

Just thinking about this, would it be necessary to return a mesh? Seems like it would be more work to round-trip a mesh than to create a mapping of node ids. The coordinates wouldn't be involved in the return as long as the welding doesn't change any of them, which I think is a desirable property. So the result would be an array<int> of old->new vertex ids, same size as the original number of vertices.