meshx icon indicating copy to clipboard operation
meshx copied to clipboard

Generalizing code over similar mesh types

Open elrnv opened this issue 3 years ago • 0 comments

At the moment there is a lot of repeated code for manipulating similar types of meshes. The straightforward thing to do here is to figure out a trait system that makes sense. VertexPositions and VertexMesh traits were attempts at making some sort of generalization, but we need something then for meshes with uniformly shaped cells (tetmesh, uniform_poly_mesh) and unstructured meshes (unstructured_mesh, polymesh).

The poster example can be the sort_vertices_by_key function implemented on tetmesh and uniform_poly_mesh, but can also be implemented in a similar way on unstructured_mesh and polymesh.

Originally I expected intrinsic attributes to fill this space, but due to splitting borrows issue, (hard to borrow multiple fields at once from a mesh struct) that is probably not the way.

We need to answer: what is the best way to borrow multiple "common" fields from a mesh through a trait. We can always do this through macros, but having traits which can be used in generic code is much more convenient.

elrnv avatar Nov 13 '21 23:11 elrnv