首页 > 解决方案 > 如何在gmsh中提取边界节点处的法线向量?

问题描述

我有一个 gmsh 的地理文件并将其网格化。然后我想在选定曲面的节点处提取法线向量。这怎么可能?

下面是我的 gmsh 地理文件。

//Construct a cube in GMSH

//Build a line
Point(1) = {0, 0, 0, 1.0};
Point(2) = {0, 0, 10, 1.0};
Line(1) = {1, 2};

//Extrude line to create a surface (square)
Extrude {10, 0, 0} {
  Line{1};
}

//Extrude surface to create a volume (cube)
Extrude {0, 10, 0} {
  Surface{5};
}

//Six surfaces of the cube
Physical Surface(28) = {18};
Physical Surface(29) = {26};
Physical Surface(30) = {22}; 
Physical Surface(31) = {14};
Physical Surface(32) = {27};
Physical Surface(33) = {5};

//Volume of the cube
Physical Volume(34) = {1};

标签: meshboundaryfenicsgmsh

解决方案


嗯,我不知道如何通过 GEO 文件脚本来做到这一点(不过,如果它存在,我不会感到惊讶)。

但是,它当然可以通过 GMSH API 使用getNormal()函数来完成。

getNormal()

tag使用参数坐标处的标记获取曲面的法线parametricCoordparametricCoord由成对的uv坐标给出,连接起来:[p1u, p1v, p2u, ...]. 以xyznormals分量的三元组形式返回,串联:.[n1x, n1y, n1z, n2x, ...]

输入: tag,parametricCoord

输出:normals

GMSH API 可通过 Python、C/C++ 和 Julia 获得。有关用法的详细信息,我建议直接查看GMSH 存储库中的 API 是如何定义的


推荐阅读