Hi, I am solving linear elasticity problem. I want to save displacement (solution) in txt file for all the nodes. any idea.
Thanks in advance
from dolfin import *
mesh = UnitSquareMesh(2,2)
E, nu = Constant(10.0), Constant(0.3)
plot(mesh, title = 'mesh', interactive = True)
ndim = mesh.geometry().dim()
def eps(v):
return sym(grad(v))
def eps_dev(du):
return dev(eps(du))
zero_v=Constant((0.,)*ndim)
f=zero_v
V = VectorFunctionSpace(mesh, 'Lagrange', 1)
u = TrialFunction(V)
v = TestFunction(V)
du = Function(V)
mu = E/(2.0*(1.0 + nu))
lmbda = E*nu/((1.0 + nu )*(1.0-2.0*nu))
EDef = ( mu*tr(eps(du)*eps(du)) + 0.5*lmbda*tr(eps(du))**2 )*dx - dot(f,du)*dx
EDer = derivative(EDef,du,v)
J = derivative(EDer,du,u)
class top(SubDomain):
def inside(self,x,on_boundary):
tol = 1e-10
return abs(x[1]-1.0) < tol and on_boundary
class bottom(SubDomain):
def inside(self,x,on_boundary):
tol = 1e-10
return abs(x[1]) < tol and on_boundary
Top = top()
Bottom = bottom()
bclx= DirichletBC(V.sub(0), Constant(0.0), Bottom)
bcly = DirichletBC(V.sub(1), Constant(0.0), Bottom)
bcty = DirichletBC(V.sub(1), Constant(1.0), Top)
bc_u = [bclx, bcly, bcty]
solve(EDer==0,du, J = J, bcs=bc_u)