I am trying to solve a single truss element problem defined by two points A and B. In each point I have two DoF i.e. u1,u2,u3,u4.
I tried to use the tutorial for 2d beams see and an old thread `but I could not solve my problem defining the correct mesh and boundary condition.
So far I have this code:
import numpy as np from dolfin import * # Material variables E = Constant(1e5) nu = Constant(0.3) mu = E/2/(1+nu) lmbda = E*nu/(1+nu)/(1-2*nu) # Define Single Truss mesh from point A to point B with DoF 2 in each point # # mesh = Mesh(mesh) V = VectorFunctionSpace(mesh, 'Lagrange', degree=1) # Define Dirichlet boundary i.e. left point A is fixed # # def eps(v): return sym(grad(v)) def sigma(u): d = u.geometric_dimension() I = Identity(d) return lmbda * tr(eps(u)) * I + 2 * mu * eps(u) # Solution variables dx = Measure("dx") du = TrialFunction(V) U = Function(V) u = U.vector() u_ = TestFunction(V) d = U.geometric_dimension() I = Identity(d) f = Constant((0, 0)) # Assembly system a = inner(sigma(du), eps(u_)) * dx L = inner(f, u_) * dx K, f_vec = assemble_system(a, L, bc) # External force on point B f_vec = 0 f_vec = -1 # Solve system solve(K, u, f_vec)