Appearance
第 7 章:Delaunization 算法与 Python 接口
Delaunization 算法
生成山脊与角落(Ridges and Corners)
在第一阶段,算法检测共面的面。限定共面面集合的每条边标记为山脊(ridge)。连接两条非共线山脊的每个点标记为角落(corner)。
默认情况下,如果两个面之间的角度小于 coplanarityAngle 且翻转公共边可能产生的表面变形小于 coplanarityDistance,则两个面被认为是共面的。
保护山脊与角落(Protecting Ridges and Corners)
一般来说,如果输入包含相邻表面之间的尖锐角度(通常小于 60°), conforming Delaunay 算法表现不佳。
山脊和角落细化算法通过定义一组保护这些实体的球体来精细化周围区域。位于这些球体内部的细化点会捕捉到球体表面,产生等腰三角形形状,非常适合 Delaunay 类型算法。
Conforming Delaunay Triangulation 算法
CDT 算法允许 Delaunizer 通过放宽 Delaunay 准则来生成近似 Delaunay 的网格。
在面经过细化以满足(可能放宽的)Delaunay 准则后,某些表面面可能缺失于背景 3D Delaunay 网格中。CDT 算法使用一系列 3D 面翻转将这些面插入背景三角剖分中。
优化单元(Optimizing Elements)
CDT 算法完成后,网格中单元的质量可能不是最佳的。算法执行额外的细化步骤,消除所有不满足用户指定质量标准的单元。质量标准包括:
- 单元内部的最大立体角
- 相邻单元的 circumscribed spheres 之间的最大比率
消除 Sliver(Eliminating Slivers)
Delaunization 的最后一步是消除 sliver 单元。算法使用 sliver exudation 技术的变体,为三角剖分中的节点分配权重并使用它们计算加权 Delaunay 三角剖分。权重有选择地增加以局部消除三角剖分中的 sliver。
sliverDistance 参数控制应用于网格节点的损伤量。如果启用 sliverPerturbation,算法会对网格顶点进行小幅扰动,从而在 sliver 单元的对角线附近添加点。
参考文献
[1] S.-W. Cheng, T. K. Dey, and J. R. Shewchuk, Delaunay Mesh Generation, Boca Raton, Florida: CRC Press, 2013.
[2] J. R. Shewchuk, "Mesh Generation for Domains with Small Angles," 16th Annual Symposium on Computational Geometry, Hong Kong, pp. 1–10, June 2000.
[3] J. R. Shewchuk, "Constrained Delaunay Tetrahedralizations and Provably Good Boundary Recovery," Proceedings of the 11th International Meshing Roundtable, Ithaca, NY, USA, pp. 181–204, September 2002.
[4] J. R. Shewchuk, "Updating and Constructing Constrained Delaunay and Constrained Regular Triangulations by Flips," 19th Annual Symposium on Computational Geometry, San Diego, CA, USA, pp. 181–190, June 2003.
[5] S.-W. Cheng et al., "Sliver Exudation," Journal of the ACM, vol. 47, no. 5, pp. 883–904, 2000.
[6] H. Edelsbrunner and D. Guoy, "An Experimental Study of Sliver Exudation," Proceedings of the 10th International Meshing Roundtable, Newport Beach, CA, USA, pp. 307–316, October 2001.
[7] J. Tournois, R. Srinivasan, and P. Alliez, "Perturbing Slivers in 3D Delaunay Meshes," Proceedings of the 18th International Meshing Roundtable, Salt Lake City, UT, USA, pp. 157–173, October 2009.
Python 接口
Sentaurus Mesh Python 模块可用于创建高级仿真流程,支持多种 Python 包和框架环境。
加载模块
python
import smesh创建 Tools 对象
python
smt = smesh.Tools("n24_msh.tdr")或者使用 TDR Python 对象:
python
smt = smesh.Tools(tdr_python_obj)实用方法(Utility Methods)
get_collection — 返回 TDR Collection 对象:
python
tdrCol = smt.get_collection()save_as — 保存输出为 TDR 文件:
python
smt.save_as("output.tdr")set_num_threads — 设置线程数:
python
smt.set_num_threads(4)工具方法(Tool Methods)
append — 周期性追加结构:
python
smt.append(axis="xmax", region_pairs={"Region_Nitride": "Region_Oxide"})create_profile — 创建分布:
python
smt.create_profile(src_file_name="cube_msh.tdr", dst_file_name="ecl.cmd")decimate — 移除短边:
python
smt.decimate(accuracy=0.1, short_edge=1e-3)slice / cut — 切割网格或边界:
python
smt.slice(location=[0, 0, 0], normal=[1, 0, 0])dual_contouring_surface — 双重轮廓表面重网格化:
python
smt.dual_contouring_surface(resolution=0.002, minAngle=2)dual_contouring_volume — 体积双重轮廓网格生成:
python
smt.dual_contouring_volume(resolution=0.002)delaunay_surface_remeshing — DelPSC 表面重网格化:
python
smt.delaunay_surface_remeshing(DelPSCAccuracy=0.0001, DelPSCRidgeAngle=95)reflection — 镜像网格:
python
smt.reflection(axis="xmax")extrude — 拉伸网格:
python
smt.extrude(spacingMethod="even", zCuts=[0.0, 0.1, 0.2])interpolate_mesh — 网格间插值:
python
smt.interpolate_mesh(src_mesh="source.tdr", dst_mesh="dest.tdr")voronoi — 生成 Voronoi 图:
python
smt.voronoi(region="Grain1")particle_generator — 界面粒子生成:
python
smt.particle_generator(brep_in="output.tdr", point_cloud="traps.txt",
trap_density=2e9, min_spacing=0.005)运行 Python 脚本
bash
gpythonsh <Python_script>.py或使用 IPython 交互模式:
bash
gpythonsh -m IPython