We present several algorithms for evaluating point containment in constructive solid geometry (CSG) trees with unbounded primitives. Three algorithms are presented based on postfix, prefix, and infix notations of the CSG binary expression tree. We show that prefix and infix notations enable short-circuiting logic, which reduces the number of primitives that must be checked during point containment. To evaluate the performance of the algorithms, each algorithm was implemented in the OpenMC Monte Carlo particle transport code, which relies on CSG to represent solid bodies through which subatomic particles travel. Two sets of tests were carried out. First, the execution time to generate a high-resolution rasterized image of a 2D slice of a detailed CSG model of the ITER tokamak was measured. Use of both prefix and infix notations offered significant speedup over the postfix notation that has traditionally been used in particle transport codes, with infix resulting in a 6$\times$ reduction in execution time relative to postfix. We then measured the execution time of neutron transport simulations of the same ITER model using each of the algorithms. The results and performance improvements reveal the same trends as for the rasterization test, with a 4.59$\times$ overall speedup using the infix notation relative to the original postfix notation in OpenMC.
翻译:本文提出了几种用于评估包含无界图元的构造实体几何(CSG)树中点包含判定的算法。基于CSG二叉表达式树的后缀、前缀和中缀表示法,我们提出了三种算法。研究表明,前缀和中缀表示法能够实现短路逻辑,从而减少点包含判定过程中需要检查的图元数量。为了评估算法的性能,每种算法均在OpenMC蒙特卡洛粒子输运程序中实现,该程序依赖CSG来表示亚原子粒子穿行的实体几何。我们进行了两组测试。首先,测量了生成ITER托卡马克详细CSG模型二维切片的高分辨率栅格化图像的执行时间。使用前缀和中缀表示法相比传统粒子输运程序中使用的后缀表示法均实现了显著加速,其中中缀表示法相对于后缀表示法使执行时间减少了6倍。随后,我们使用每种算法测量了同一ITER模型的中子输运模拟执行时间。结果与性能改进趋势与栅格化测试一致,在OpenMC中使用中缀表示法相对于原始后缀表示法实现了整体4.59倍的加速。