[Cleanup] We are pre-allocating too much space for the mesh.
As of https://github.com/GEOSX/GEOSX/pull/1143 we are pre-allocating 200 edges per node among other things. This is a huge waste of space for internally generated meshes as well as many if not most external meshes. We need to be smarter about this. For internal meshes it should be easy enough to compute the max connectivities. For external meshes is there some way PAMELA could give us this information?
@francoishamon @AntoineMazuyer @rrsettgast
Let me introduce this issue to my meshing team. Unfortunately, A node connected to a thousand of edges can happen in unstructured mesh.
@corbett5 Will it be possible to provide a raw estimation of the number of edges per vertices to preallocate ? Will it be a problem if some reallocation is done at some point ? If I remember well, the pre allocation thing was done to increase performance because we realized that it was time consuming to push back everything.
The way our current algorithm is we need to know an upper bound at mesh construction time. Currently this is hard coded to 200, but it would be nice if PAMELA could provide us with a bound based on the actual mesh both so we don't over-allocate as much and so we stop running into these kinds of problems.
@corbett5 @rrsettgast @francoishamon
To start, I want to react to the comments I read in the PR stating that those values are very (too?) big.
Let's consider a ball, and mesh it with tetrahedra.
It's easy to demonstrate that the total number of inner faces (i.e. faces that are not on the border), the total of tetrahedra
and the total number of outer faces
verify this equation :
Now, take the case that there is only one point in the center of the ball, and the every other points are in the boundary of the ball. As a consequence we have .
So, , and
is the total number of faces connected to the center vertex.
In this mesh that verify the statement above, there is 52 tetrahedra, so 78 faces are connected to the central node.
As you can see, it's not a bad quality mesh. So I can easily consider having a mesh at some points going over the threshold of the 100.
@AntoineMazuyer Thanks for the illustration.
To complete, PAMELA (or maybe GEOSX if we are considering other mesh generator at some points), can compute this number before generating the faces and the edges.
Issue https://github.com/GEOSX/GEOSX/issues/1762 gathers all request about mesh performances. And we're back to a more acceptable pre-allocation size. Closing in favor of the #1762