Hi
I am solving a Hyperelasticity problem (compressible neo-Hookean model). I want to add a new term to the strain energy function: C[0,0]*cos(theta)
Where (\theta) is defined in XY plane in global coordinate system:
Now I want to evaluate the parameter \theta in elementwise fashion. To be more specific I want to consider the orientation of the XY plane with elements orientation. This figure shows what I am looking at:
In general, I want to map the XY plane (in global coordinate system) on the outer facet of each element (e.g. I need to define the \theta in local or element coordinate system) and \theta is constant in each element. That is why I think I need to solve it elementwise (I have never done it before!). I just need to figure out how I should consider the orientation of XY plane with orientation of elements. Does anybody know how I can do that in FEniCS?
This is my minimal work for a simple unit cube (The cube example is for simplicity but I am looking for a general solution working for any type of geometry like a sphere etc):
from dolfin import *
import numpy as np
mesh = UnitCubeMesh(2, 2, 2)
V = VectorFunctionSpace(mesh, "Lagrange", 1)
# Define boundary
class Left(SubDomain):
def inside(self, x, on_boundary):
return abs(x[0] - 0.0) < DOLFIN_EPS and on_boundary
class Right(SubDomain):
def inside(self, x, on_boundary):
return abs(x[0] - 1.0) < DOLFIN_EPS and on_boundary
boundaries = MeshFunction('size_t', mesh, mesh.topology().dim()-1)
subdomains = MeshFunction('size_t', mesh, mesh.topology().dim())
left = Left()
right = Right()
boundaries.set_all(0)
left.mark(boundaries, 1)
right.mark(boundaries, 2)
dx = Measure('dx', domain=mesh, subdomain_data=subdomains, metadata={'quadrature_degree': 2})
ds = Measure('ds', domain=mesh, subdomain_data=boundaries, metadata={'quadrature_degree': 2})
bcl = DirichletBC(V, Constant((0,0,0)), boundaries, 1)
# Define functions
du = TrialFunction(V) # Incremental displacement
v = TestFunction(V) # Test function
u = Function(V) # Displacement from previous iteration
# 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)
force = Constant((1.0, 0.0, 0.0))
# Elasticity parameters
E, nu = 10.0, 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
theta = 0
# The last term is the new term added to strain energy function that includes theta parameter
psi = (mu/2)*(Ic - 3) - mu*ln(J) + (lmbda/2)*(ln(J))**2 + C[0,0]*cos(theta)
Pi = psi*dx - dot(force, u)*ds(2)
F = derivative(Pi, u, v)
# Compute Jacobian of F
J = derivative(F, u, du)
# Solve variational problem
solve(F == 0, u, bcl, J=J,)