Reputation: 13
I want to solve a heat diffusion problem with an "L-shape" geometry, defined by the code below:
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)")
Now I want to define the "Top" and "Right" boundaries as Dirichlet boundaries with constant values as 1 and 0. And I want define the "Inner" and "Right" as Neumann boundaries with flux equal to 0. How should I go about setting up the constraints? I used:
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)
But all I got was "AttributeError: 'Gmsh2D' object has no attribute 'Front'" error. How can I fix this? Thank you very much.
Upvotes: 1
Views: 194
Reputation: 2484
The use of Gmsh-defined cells and faces is demonstrated in the docstring for Gmsh2D
. Specifically, you want:
mesh.physicalFaces["Front"]
etc., which should be defined in your Gmsh script as a Physical Line
, not a Physical Surface
.
Upvotes: 1