I am running this code now, and getting the error above
from dolfin import *
import mshr
import numpy as np
from future import print_function
from fenics import *
from future import print_function
from dolfin import *
from future import division
import matplotlib.pyplot as plt
from ufl import nabla_div
from mshr import *
from dolfin import mesh as module
Load mesh and define function space
L = 8.
W = 1.
n0 = int(L6)
n1 = int(W6)
n2 = int(W*6)
Mesh for cantilever beam
Omega = BoxMesh(Point(0, 0, 0), Point(L, W, W), 10, 3, 3)
= Box(0., 0., 0., d0, d1, d2, n0, n1, n2)
Omega.init()
V = VectorFunctionSpace(Omega, “CG”, 1)
tol = 1.e-8 # tolerance
Left boundary
class Left(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], 0.0)
Right boundary
class Right(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], 8.0)
Point (8,0.5,0.5) at which load is added
class point(SubDomain):
def inside(self, x, on_boundary):
return near(x[0],8.) and near(x[1],0.5,1e-2) and near(x[2],0.5,1e-2)
#Boundary segments
left = Left()
pt = point()
right = Right()
Initialize mesh function for boundary domains
#boundaries = MeshFunction(“size_t”, Omega, file)#“size_t”, mesh, 2, mesh.domains()
#boundaries.set_all(0)
#left.mark(boundaries, 1)
#pt.mark(boundaries, 2)
boundaries = MeshFunction(“size_t”, Omega,0) #mesh omega yerinde kalmisti
#boundaries = CellFunction(‘size_t’, mesh)
boundaries.set_all(0)
left.mark(boundaries, 1)
pt.mark(boundaries, 2)
#all_boundary.mark(boundaries, 1)
Define variational problem
f = Constant((0.0, 0.0, 00.0))
E = 210000.0
nu = 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(Enu/((1 + nu)(1 - 2*nu)))
Strain
def eps(v):
return sym(grad(v))
model = “plane_stress”
mu = E/2/(1+nu)
lmbda = Enu/(1+nu)/(1-2nu)
if model == “plane_stress”:
lmbda = 2mulmbda/(lmbda+2*mu)
def sigma(v):
return lmbdatr(eps(v))Identity(3) + 2.0mueps(v)
ds = ds(subdomain_data=boundaries)
Define variational problem
ds= Measure(“ds”)(subdomain_data=boundaries)
g_T= Constant((0.0, 0.0, -0.3))
du = TrialFunction(V)
u_ = TestFunction(V)
a = inner(sigma(du), eps(u_))*dx
left_end_displacement = Constant((0.0, 0.0, 0.0))
#bc = [DirichletBC(V, left_end_displacement, left)]
bc = [DirichletBC(V, left_end_displacement, left),DirichletBC(V, g_T, pt, method=“pointwise”)]
l= dot(f, v)*dx +dot(v,g_T)*ds(2)
u = Function(V)
solve(a ==l, u, bc);