我想用下面的代码定义的“L 形”几何形状来解决热扩散问题:
from fipy import CellVariable, Gmsh2D, TransientTerm, DiffusionTerm
from fipy import Matplotlib2DViewer, Viewer
from fipy.tools import numerix
cellSize_1 = 0.05
mesh = Gmsh2D('''
cellSize = %(cellSize_1)g;
Point(1) = {0, 0, 0, cellSize};
Point(2) = {0, 5, 0, cellSize};
Point(3) = {1, 5, 0, cellSize};
Point(4) = {1, 1, 0, cellSize};
Point(5) = {4, 1, 0, cellSize};
Point(6) = {4, 0, 0, cellSize};
Line(7) = {1, 2};
Line(8) = {2, 3};
Line(9) = {3, 4};
Line(10) = {4, 5};
Line(11) = {5, 6};
Line(12) = {6, 1};
Physical Surface("Top") = {8};
Physical Surface("Inner") = {9, 10};
Physical Surface("Right") = {11};
Physical Surface("Inner") = {12, 7};
Line Loop(13) = {7, 8, 9, 10, 11, 12};
Plane Surface(14) = {13};
''' % locals()) # doctest: +GMSH
# Using this mesh, we can construct a solution variable
phi = CellVariable(name = "solution variable",
mesh = mesh,
value = 0.) # doctest: +GMSH
# We can now create a Viewer to see the mesh
viewer = None
from builtins import input
if __name__ == '__main__':
try:
viewer = Viewer(vars=phi, datamin=-1, datamax=3)
viewer.plotMesh()
except:
print("Unable to create a viewer for an irregular mesh (try "+
"Matplotlib2DViewer or MayaviViewer)")
现在我想将“顶部”和“右”边界定义为狄利克雷边界,常数值为 1 和 0。我想将“内”和“右”定义为通量等于 0 的诺伊曼边界。我应该怎么走关于设置约束?我用了:
phi.constrain(1, where = mesh.Front)
phi.constrain(0, where = mesh.Top)
phi.faceGrad.constrain(0 * mesh.faceNormals, where = mesh.Inner)
phi.faceGrad.constrain(0 * mesh.faceNormals, where = mesh.Outter)
但我得到的只是“AttributeError:'Gmsh2D'对象没有属性'Front'”错误。我怎样才能解决这个问题?非常感谢你。