Hi All,
I wonder is there any way to specify the FaceVariable based on the naming
from gmsh ? For example, I name my sub domain in gmsh as "top" and
"bottom". In Fipy, I would like to do something similar to following:
velocityX_Top = (1-Epsilon*Epsilon)/(Epsilon*Epsilon)*(yFace +
Epsilon*np.sqrt(1-xFace*xFace))
velocityY_Top =
(1-Epsilon*Epsilon)/Epsilon*(xFace*yFace)/(np.sqrt(1-xFace*xFace))
velocityX_Bottom = yFace
velocityY_Bottom = -xFace
velocityVector = FaceVariable(mesh=mesh.physicalCells["top"], rank=1)
velocityVector[0] = velocityX_Top
velocityVector[1] = velocityY_Top
velocityVector = FaceVariable(mesh=mesh.physicalCells["bottom"], rank=1)
velocityVector[0] = velocityX_Bottom
velocityVector[1] = velocityY_Bottom
I think it gives me error because the mesh.physicalCells is cell index, not
face index. But is there any way I could do get all face index using sub
domain ID?
I have attached the complete and minimal code to demonstrate what I try to
achieve.
Thanks!
Zhekai
from fipy import *
import numpy as np
import matplotlib as matplotlib_plot
import scipy.interpolate
mesh = Gmsh2D('''
lc = 2e-2;
Point(1) = {-1, 0, 0, lc};
Point(2) = {0, 0, 0, lc};
Point(3) = {1, 0, 0, lc};
Point(4) = {0,-0.1,0,lc};
Ellipse(5) = {1,2,2,4};
Ellipse(6) = {4,2,2,3};
Line(7) = {3,2};
Line(8) = {2,1};
Circle(9) = {1,2,3};
Line Loop(9) = {6,7, 8,5};
Line Loop(10) = {-6,-5,9};
Plane Surface (11) = {9};
Plane Surface (12) = {10};
Physical Surface("top") = {11};
Physical Surface("bottom") = {12};
Physical Line("interface") = {5, 6};
''' % locals())
phi_1 = CellVariable(name = "solution variable",
mesh = mesh,
hasOld = True,
value = 0.5) # doctest: +GMSH
viewer = Matplotlib2DViewer(vars=phi_1, title="final solution", cmap =
matplotlib_plot.cm.hot,datamin = 0., datamax = 1.)
#viewer.plot()
#
xFace,yFace=mesh.faceCenters
Epsilon = 0.1
velocityX_Top = (1-Epsilon*Epsilon)/(Epsilon*Epsilon)*(yFace +
Epsilon*np.sqrt(1-xFace*xFace))
velocityY_Top =
(1-Epsilon*Epsilon)/Epsilon*(xFace*yFace)/(np.sqrt(1-xFace*xFace))
velocityX_Bottom = yFace
velocityY_Bottom = -xFace
velocityVector = FaceVariable(mesh=mesh.physicalCells["top"], rank=1)
velocityVector[0] = velocityX_Top
velocityVector[1] = velocityY_Top
_______________________________________________
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]