I tried that method as following but it seems like does not work. I just try to keep update the normal vector in deformed mesh for radial stress calculation and keep the rest of the calculation in undeformed mesh. The problem might be about, I am solving displacement (u) in “mesh” but trying to map it by “copy_mesh”…But I am not sure about it.

```
> from dolfin import *
> import numpy as np
> import copy
> # Optimization options for the form compiler
> parameters["form_compiler"]["cpp_optimize"] = True
> ffc_options = {"optimize": True, \
> "eliminate_zeros": True, \
> "precompute_basis_const": True, \
> "precompute_ip_const": True}
>
> # Create mesh and define function space
> mesh = UnitCubeMesh(6, 4, 4)
> mesh_copy = Mesh(mesh)
> V = VectorFunctionSpace(mesh, "Lagrange", 2)
>
> # Mark boundary subdomians
> left = CompiledSubDomain("near(x[0], side) && on_boundary", side = 0.0)
> right = CompiledSubDomain("near(x[0], side) && on_boundary", side = 1.0)
>
> # Define Dirichlet boundary (x = 0 or x = 1)
> c = Expression(("0.0", "0.0", "0.0"),degree=1)
> r = Expression(("scale*0.0",
> "scale*(y0 + (x[1] - y0)*cos(theta) - (x[2] - z0)*sin(theta) - x[1])",
> "scale*(z0 + (x[1] - y0)*sin(theta) + (x[2] - z0)*cos(theta) - x[2])"),
> scale = 0.5, y0 = 0.5, z0 = 0.5, theta = pi/3,degree=1,domain=mesh)
>
> bcl = DirichletBC(V, c, left)
> bcr = DirichletBC(V, r, right)
> bcs = [bcl, bcr]
>
>
> load_start =0
> load_stop =pi/3
> load_step =15
>
> def normal_deformed(mesh_copy,u,V):
> mesh_copy.bounding_box_tree().build(mesh_copy)
> X = mesh_copy.coordinates()
> X += np.vstack(map(u, X))
> x = SpatialCoordinate(mesh_copy)
> normal = Expression(('x[0]', 'x[1]', 'x[2]'),degree=1,domain=mesh_copy)
> unit = normal / sqrt(dot(normal,normal))
> asd=project(unit,V)
> aaa11=asd.vector().array()
> print("Deformed1",aaa11[102:105])
> print("Deformed2",aaa11[198:201])
> print("Deformed3",aaa11[798:801])
> #theta=project(theta1,P3)
> #mesh.bounding_box_tree().build(mesh1)
> return dot(normal,normal)
>
> def normal_undeformed(mesh_copy,u,V):
> x = SpatialCoordinate(mesh)
> normal = Expression(('x[0]', 'x[1]', 'x[2]'),degree=1,domain=mesh)
> unit = normal / sqrt(dot(normal,normal))
> asd=project(unit,V)
> aaa11=asd.vector().array()
> print("Undeformed1",aaa11[102:105])
> print("Undeformed2",aaa11[198:201])
> print("Undeformed3",aaa11[798:801])
> #theta=project(theta1,P3)
> #mesh.bounding_box_tree().build(mesh1)
> return dot(normal,normal)
>
>
>
>
> inc_load = np.linspace(load_start,load_stop,load_step+1)
> # Define functions
> du = TrialFunction(V) # Incremental displacement
> v = TestFunction(V) # Test function
> u = Function(V) # Displacement from previous iteration
> B = Constant((0.0, -0.5, 0.0)) # Body force per unit volume
> T = Constant((0.1, 0.0, 0.0)) # Traction force on the boundary
>
> # Kinematics
> d = u.geometric_dimension()
> I = Identity(d) # Identity tensor
> F = I + grad(u) # Deformation gradient
> C = F.T*F # Right Cauchy-Green tensor
>
> # Invariants of deformation tensors
> Ic = tr(C)
> J = det(F)
>
> # Elasticity parameters
> E, nu = 10.0, 0.3
> mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
>
> # Stored strain energy density (compressible neo-Hookean model)
> psi = (mu/2)*(Ic - 3) - mu*ln(J) + (lmbda/2)*(ln(J))**2
>
> # Total potential energy
> Pi = psi*dx - dot(B, u)*dx - dot(T, u)*ds
>
> # Compute first variation of Pi (directional derivative about u in the direction of v)
> F = derivative(Pi, u, v)
>
> # Compute Jacobian of F
> J = derivative(F, u, du)
>
>
>
> P3_Def_v= VectorFunctionSpace(mesh_copy, "CG", 1)
> P3_UnDef_v= VectorFunctionSpace(mesh, "CG", 1)
> P3_Def= FunctionSpace(mesh_copy, "CG", 1)
> P3_UnDef= FunctionSpace(mesh, "CG", 1)
> normal_def=Function (P3_Def, name="Deformed Normal")
> normal_undef=Function (P3_UnDef, name="Undeformed Normal")
>
> for t in inc_load:
> r.theta=t
> # Solve variational problem
> solve(F == 0, u, bcs, J=J)
> print("t is",t)
> normal_def.assign(project(normal_deformed(mesh_copy,u,P3_Def_v),P3_Def))
> normal_undef.assign(project(normal_undeformed(mesh,u,P3_UnDef_v),P3_UnDef))
>
>
> # Save solution in VTK format
> file = File("displacement.pvd");
> file << u;
>
> # Plot and hold solution
> plot(u, mode = "displacement", interactive = True)
```