| 1 |
# Copyright (C) 2009-2010 Harish Narayanan and Garth N. Wells |
| 2 |
# |
| 3 |
# This file is part of DOLFIN. |
| 4 |
# |
| 5 |
# DOLFIN is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU Lesser General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# DOLFIN is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU Lesser General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU Lesser General Public License |
| 16 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
# |
| 18 |
# Modified by Anders Logg 2011 |
| 19 |
# |
| 20 |
# First added: 2009-09-29 |
| 21 |
# Last changed: 2011-06-28 |
| 22 |
# |
| 23 |
# The bilinear form a(du, v) and linear form L(v) for |
| 24 |
# a hyperelastic model. |
| 25 |
# |
| 26 |
# Compile this form with FFC: ffc -l dolfin -feliminate_zeros -fprecompute_basis_const -fprecompute_ip_const HyperElasticity.ufl |
| 27 |
|
| 28 |
from ufl_legacy import (Coefficient, dx, FiniteElement, VectorElement, |
| 29 |
derivative, det, grad, inner, Identity, ln, tr, |
| 30 |
triangle, TestFunction, TrialFunction) |
| 31 |
|
| 32 |
# Function spaces |
| 33 |
element = VectorElement("Lagrange", triangle, 1) |
| 34 |
R = FiniteElement("Real", triangle, 0) |
| 35 |
|
| 36 |
# Trial and test functions |
| 37 |
du = TrialFunction(element) # Incremental displacement |
| 38 |
v = TestFunction(element) # Test function |
| 39 |
|
| 40 |
# Functions |
| 41 |
u = Coefficient(element) # Displacement from previous iteration |
| 42 |
B = Coefficient(element) # Body force per unit volume |
| 43 |
|
| 44 |
# Kinematics |
| 45 |
I = Identity(u.geometric_dimension()) # Identity tensor |
| 46 |
F = I + grad(u) # Deformation gradient |
| 47 |
C = F.T*F # Right Cauchy-Green tensor |
| 48 |
|
| 49 |
# Invariants of deformation tensors |
| 50 |
Ic = tr(C) |
| 51 |
J = det(F) |
| 52 |
|
| 53 |
# Elasticity parameters |
| 54 |
mu = Coefficient(R) |
| 55 |
lmbda = Coefficient(R) |
| 56 |
|
| 57 |
# Stored strain energy density (compressible neo-Hookean model) |
| 58 |
psi = (mu/2)*(Ic - 2) - mu*ln(J) + (lmbda/2)*(ln(J))**2 |
| 59 |
|
| 60 |
# Total potential energy |
| 61 |
Pi = psi*dx - inner(B, u)*dx |
| 62 |
|
| 63 |
# First variation of Pi (directional derivative about u in the direction of v) |
| 64 |
F = derivative(Pi, u, v) |
| 65 |
|
| 66 |
# Compute Jacobian of F |
| 67 |
J = derivative(F, u, du) |