我生成了一个 gmsh 网格,我通过 Gmsh2D 将其导入 FiPy。我想处理表面面以设置边界条件,但我不知道如何。
在我在文档中找到的 FiPy 示例中,建议命名某些行以便稍后解决它们。将网格导入 fipy 后如何执行此操作?
// note: if you do not use any labels, all Cells will be included.
Physical Surface("Outer") = {1};
Physical Surface("Middle") = {2};
Physical Surface("Inner") = {3};
// label the "north-west" part of the exterior boundary
// note: you only need to label the Face elements
// (Physical Line in 2D and Physical Surface in 3D) that correspond
// to boundaries you are interested in. FiPy does not need them to
// construct the Mesh.
Physical Line("NW") = {5};
-----------------
编辑:
对于简单的表面,这将起作用:我忽略了mesh.exteriorFaces
. 对于一个简单的圆圈,这导致了简单的解决方案:
xfc, yfc = mesh.faceCenters() # returns x faceCenters coordinate, ...
xcc, ycc = mesh.cellCenters()
plot(xfc[where(mesh.exteriorFaces == False)],yfc[where(mesh.exteriorFaces == False)],'ro', label='inside')
plot(xfc[where(mesh.exteriorFaces == True)],yfc[where(mesh.exteriorFaces == True)],'ko', label='surface')
legend()
尽管如此,我仍在寻找有关如何从外部访问 gmsh 代码的答案,但这可能对其他人有所帮助:)