Hello
The below illustrates how you can apply a point load on a cantilever beam:
from dolfin import *
L = 10
W = 1
mesh = RectangleMesh(Point(0, 0), Point(L, W), 20, 3)
V = VectorFunctionSpace(mesh, 'P', 2)
tol = 1e-6
class LeftEdge(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and abs(x[0]) < tol
class RightEdge(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and abs(x[0] - L) < tol
def eps(v):
return sym(grad(v))
E = Constant(200e9)
nu = Constant(0.3)
model = "plane_stress"
mu = E/(2*(1+nu))
lmbda = E*nu/(1+nu)/(1-2*nu)
if model == "plane_stress":
lmbda = 2*mu*lmbda/(lmbda+2*mu)
def sigma(v):
return lmbda*tr(eps(v))*Identity(2) + 2.0*mu*eps(v)
left_edge = LeftEdge()
right_edge = RightEdge()
boundaries = MeshFunction('size_t', mesh, mesh.topology().dim()-1)
boundaries.set_all(0)
left_edge.mark(boundaries, 2)
#Zero Dirichlet B.C on the left side
bc = DirichletBC(V, Constant((0, 0)), boundaries , 2)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
class PointLoad(UserExpression):
def __init__(self, **kwargs):
super().__init__()
self.point = kwargs['point']
self.value = kwargs['value']
def eval(self, value, x):
if near (x[0], self.point[0]) and near(x[1], self.point[1]):
value[0] = self.value[0]
value[1] = self.value[1]
else:
value[0] = 0
value[1] = 0
def value_shape(self):
return (2,)
#End Load
T = PointLoad(point=(10.,1.), value=(0,-1e9), degree=1)
#Solve
a = inner(sigma(u), eps(v))*dx
L =dot(T, v)*ds
# Compute solution
u = Function(V)
solve(a == L, u, bc)
File("disp.pvd") << u