SKIRT / SKIRT9

SKIRT version 9 -- advanced radiative transfer in dusty systems
http://www.skirt.ugent.be
GNU Affero General Public License v3.0
35 stars 30 forks source link

New voro++ library version and retry Voronoi grid construction after removing invalid cells #100

Closed petercamps closed 3 years ago

petercamps commented 3 years ago

Motivation Recent tests by @bwvdnbro and myself reveal that the current mechanism in SKIRT sometimes fails to build a Voronoi tessellation for site lists imported from hydro simulations, especially for a large number of sites/cells (and correspondingly high site/cell density). One can then still resample to an octree grid to perform the radiative transfer simulation (see pull request #95) but that is not always an acceptable solution. Furthermore, the behavior sometimes differs between compilers.

Description This pull request attempts to address this situation with three changes:

Tests We tested the updated code with Voronoi grids up to 16 million sites. The retry process needs 3 iterations in the worst case and the number of discarded sites is very small compared to the total number. Although these adjustments represent a risk of changing the physics of the input model, it seems that the effect is small in practice. Also, the behavior is now identical on all tested compilers (Intel, GCC, Clang).

The results of the functional tests are compatible with but not identical to previous results:

Context A distinguishing feature of the Voro++ library is that it carries out cell-based calculations, computing the Voronoi cell for each site individually, rather than computing the Voronoi tessellation as a global network of vertices and edges. It is therefore particularly well-suited for applications that require cell-based properties such as the cell volume, the centroid position or the number of faces or vertices. Equally important in the context of SKIRT, it is easy to distribute the work over parallel execution threads because, after setting up a common search data structure holding all sites, the calculations for the various cells are mutually independent.

This approach also has an important drawback. Because cells are handled independently of each other, floating pointing rounding errors sometimes cause inconsistencies where the results for one cell do not properly match the corresponding results for a neighboring cell. This most often happens when the generating sites are very close to each other and/or form certain hard-to-calculate geometries. These problems manifest themselves either as empty cells or as asymmetries in the neighbor lists. To handle these situations, as described above, the updated version of the SKIRT VoronoiMeshSnapshot class now removes the sites corresponding to these invalid cells from the input list.