Yes, that solved the problem. However, I have a problem with using the mesh named cf. When I use cf instead of mesh, it gives error. This is a part of my original code:
# mesh
from dolfin import *
import sympy
mesh = Mesh()
mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim())
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh)
infile.read(mvc, "name_to_read")
cf = cpp.mesh.MeshFunctionSizet(mesh, MVC)
# Define Space
V = FunctionSpace(mesh, 'CG', 1)
W = VectorFunctionSpace(mesh, 'CG', 1)
WW = FunctionSpace(mesh, 'DG', 0)
p, q = TrialFunction(V), TestFunction(V)
u, v = TrialFunction(W), TestFunction(W)
# Boundary conditions
leftsup = CompiledSubDomain("((0 <= x[0] <= 0.5) && (0 <= x[1] <= 0.5))")
rightsup = CompiledSubDomain("((39.5 <= x[0] <= 40.0) && (0 <= x[1] <= 0.5))")
leftload = CompiledSubDomain("((9.5 <= x[0] <= 10.5) && (3.5 <= x[1] <= 4.0))")
rightload = CompiledSubDomain("((29.5 <= x[0] <= 30.5) && (3.5 <= x[1] <= 4.0))")
load = Expression("t", t = 0.0, degree=1)
def Crack(x):
return (19.99 < x[0] < 20.01) and (-0.0001 < x[1] < 0.4)
bcleftsup= DirichletBC(W, Constant((0.0,0.0)), leftsup, method="pointwise")
bcrightsup= DirichletBC(W, Constant((0.0,0.0)), rightsup, method="pointwise")
bcleftload = DirichletBC(W.sub(1), load, leftload, method="pointwise")
bcrightload = DirichletBC(W.sub(1), load, rightload, method="pointwise")
bc_u = [bcleftsup, bcrightsup, bcleftload, bcrightload]
bc_phi = [DirichletBC(V, Constant(1.0), Crack)]
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
boundaries.set_all(0)
leftload.mark(boundaries,1)
rightload.mark(boundaries,2)
plot(boundaries, interactive=True)
ds = Measure("ds")(subdomain_data=boundaries)
n = FacetNormal(mesh)
I define the boundaries in the code, I am using just one file for the mesh.
Thank you.