Hello,
I would like to apply DirichletBC on selected nodes for a 3D mesh. The problem is that FENICS expect facets and not vertices. So around this problem I implemented three functions.
def DirichletBC_On_Vertices(mesh,group,V,c,num):
bc=[]
for vertex in vertices(mesh):
if group[vertex]==num:
bc.append(DirichletBC(V,c,"near(x[0],"+str(vertex.point().x())+") && near(x[1],"+str(vertex.point().y())+") && near(x[2],"+str(vertex.point().z())+")",method="pointwise"))
return bc
def DirichletBC_On_Faces(mesh,group,V,c,num):
bc=[]
for face in faces(mesh):
if group[face]==num:
for vertex in vertices(face):
bc.append(DirichletBC(V,c,"near(x[0],"+str(vertex.point().x())+") && near(x[1],"+str(vertex.point().y())+") && near(x[2],"+str(vertex.point().z())+")",method="pointwise"))
return bc
def DirichletBC_On_Edges(mesh,group,V,c,num):
bc=[]
#bc1=[]
for edge in edges(mesh):
if group[edge]==num:
for vertex in vertices(edge):
bc.append(DirichletBC(V,c,"near(x[0],"+str(vertex.point().x())+") && near(x[1],"+str(vertex.point().y())+") && near(x[2],"+str(vertex.point().z())+")",method="pointwise"))
return bc
Theses functions seems to work for a little mesh. When I used a big mesh, ii have a problem with python ( infinity of Calling DOLFIN just-in-time (JIT) compiler, this may take some time). I think the problem is related to the repetition of this line:
DirichletBC(V,c,"near(x[0],"+str(vertex.point().x())+") && near(x[1],"+str(vertex.point().y())+") && near(x[2],"+str(vertex.point().z())+")",method="pointwise"
Do you have a solution to optimize this code ?
In my case i have a mark on my nodes is it possible to apply directly values on nodes without using facets?
Thank you very much !
Arnaud