snappyHexMesh blockLevel uses excessive memory
Summary
snappyHexMesh can automatically 'block' a small gap by specifying an optional blockLevel
. This does a wall-distance like calculation and decides per cell if there is an 'opposite' surface as well. If the gap is too small (according to the blockLevel) the cell is marked for deletion.
The problem with the algorithm is that it walks from all surfaces over all of the mesh before in pass 2 deciding whether there is a combination of nearest surfaces that triggers cell deletion. This causes for large meshes and large numbers of surfaces there to be an excessive amount of wall-distance state being generated and compared.
Example case
Tutorial mesh/snappyHexMesh/opposite_walls
It is hard to measure the memory usage though since there are only 3 surfaces and they are tiny.
What is the current bug behaviour?
Memory usage scales with the number of surfaces. For e.g. a case with 100 stls it would store per cell and face 100 structures containing each a vector and some labels. This would cause the memory to run out.
What is the expected correct behavior?
Memory usage should be limited.
Relevant logs and/or images
Environment information
- OpenFOAM version : v2112
Possible fixes
Currently : walk all surfaces out over the whole mesh. Pass 2: decide which combinations form a valid small gap. Fix : do not walk beyond the size given by the originating surface (= 1/2<<blockLevel). This drastically limits the amount of information that needs to be stored.