Hi
I have a unit cube and I want to have only 1 element along each edge. I want to implement a bi-axial tension simulation. With that, I want to fix the left and bottom faces and apply equal normal stretch (Non-Zero Dirichlet boundary condition) on the right and top faces. However it seems like that the boundary conditions are not applied on the left and right boundaries as shown here:
However I am expecting something like this:
Does anybody know the right way to apply such Dirichlet boundary conditions? Here is the code:
from fenics import *
mu = 1
lambda_ = 1.25
# Create mesh and define function space
mesh = BoxMesh(Point(0, 0, 0), Point(1, 1, 1), 1, 1, 1)
V = VectorFunctionSpace(mesh, 'CG', 1)
# Define boundary condition
tol = 1E-14
def LEFT(x, on_boundary):
return on_boundary and x[0] < tol
def RIGHT(x, on_boundary):
return on_boundary and abs(x[0] - 1.0) < tol
def BOTTOM(x, on_boundary):
return on_boundary and x[1] < tol
def TOP(x, on_boundary):
return on_boundary and abs(x[1] - 1.0) < tol
bc_left = DirichletBC(V, Constant((0, 0, 0)), LEFT)
bc_right = DirichletBC(V, Constant((0.1, 0, 0)), RIGHT)
bc_bottom = DirichletBC(V, Constant((0, 0, 0)), BOTTOM)
bc_top = DirichletBC(V, Constant((0, 0.1, 0)), TOP)
bc_all = [bc_left,bc_right, bc_bottom, bc_top]
# Define strain and stress
def epsilon(u):
return 0.5*(nabla_grad(u) + nabla_grad(u).T)
def sigma(u):
return lambda_*nabla_div(u)*Identity(d) + 2*mu*epsilon(u)
# Define variational problem
u = TrialFunction(V)
d = u.geometric_dimension()
v = TestFunction(V)
f = Constant((0, 0, 0))
T = Constant((0, 0, 0))
a = inner(sigma(u), epsilon(v))*dx
L = dot(f, v)*dx + dot(T, v)*ds
# Compute solution
u = Function(V)
solve(a == L, u, bc_all)
File("displacement.pvd") << u