在将mesh导入Fipy之后,如何从python访问gmsh代码?

2024-09-30 00:25:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经生成了一个通过Gmsh2D导入FiPy的gmsh网格。我想处理曲面以设置边界条件,但我不知道如何设置

在我在文档中找到的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() 

IdentifiedSurfaceCells

尽管如此,我仍在寻找如何从外部访问gmsh代码的答案,但这可能对其他人有所帮助:)


Tags: thetoinyou网格wheresurfacelabel
1条回答
网友
1楼 · 发布于 2024-09-30 00:25:00

“外部”不是一个物理面,它是一组物理细胞。要访问“外部”的边界面,可以添加

Physical Line("Outer Boundary") = {1, 2, 3, 4, 5, 6, 7, 8};

应用到Gmsh脚本,然后使用

var.constrain(value, where=squaredCircle.physicalFaces["Outer Boundary"])

正如您所发现的,您始终可以访问mesh.exteriorFaces以获取定义整个网格边界的面(即,只有一面有一个单元的面)。用Physical Surface定义的Gmsh域不一定以mesh.exteriorFaces为边界

相关问题 更多 >

    热门问题