~ubuntu-branches/ubuntu/utopic/ffc/utopic

« back to all changes in this revision

Viewing changes to bench/HyperElasticity.ufl

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2013-06-26 14:48:32 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130626144832-1xd8htax4s3utybz
Tags: 1.2.0-1
* New upstream release.
* debian/control:
  - Bump required version for python-ufc, python-fiat, python-instant
    and python-ufl in Depends field.
  - Bump Standards-Version to 3.9.4.
  - Remove DM-Upload-Allowed field.
  - Bump required debhelper version in Build-Depends.
  - Remove cdbs from Build-Depends.
  - Use canonical URIs for Vcs-* fields.
* debian/compat: Bump to compatibility level 9.
* debian/rules: Rewrite for debhelper (drop cdbs).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 Harish Narayanan
 
2
#
 
3
# This file is part of FFC.
 
4
#
 
5
# FFC 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
# FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>.
 
17
#
 
18
# First added:  2009-09-29
 
19
# Last changed: 2011-07-01
 
20
#
 
21
# The bilinear form a(u, v) and linear form L(v) for
 
22
# a hyperelastic model. (Copied from dolfin/demo/pde/hyperelasticity/cpp)
 
23
#
 
24
# Compile this form with FFC: ffc HyperElasticity.ufl.
 
25
 
 
26
# Coefficient spaces
 
27
element = VectorElement("Lagrange", tetrahedron, 1)
 
28
 
 
29
# Coefficients
 
30
v  = TestFunction(element)      # Test function
 
31
du = TrialFunction(element)     # Incremental displacement
 
32
u  = Coefficient(element)       # Displacement from previous iteration
 
33
 
 
34
B  = Coefficient(element)       # Body force per unit mass
 
35
T  = Coefficient(element)       # Traction force on the boundary
 
36
 
 
37
# Kinematics
 
38
I = Identity(v.cell().d)        # Identity tensor
 
39
F = I + grad(u)                 # Deformation gradient
 
40
C = F.T*F                       # Right Cauchy-Green tensor
 
41
E = (C - I)/2                   # Euler-Lagrange strain tensor
 
42
E = variable(E)
 
43
 
 
44
# Material constants
 
45
mu    = Constant(tetrahedron) # Lame's constants
 
46
lmbda = Constant(tetrahedron)
 
47
 
 
48
# Strain energy function (material model)
 
49
psi = lmbda/2*(tr(E)**2) + mu*tr(E*E)
 
50
 
 
51
S = diff(psi, E)                # Second Piola-Kirchhoff stress tensor
 
52
P = F*S                         # First Piola-Kirchoff stress tensor
 
53
 
 
54
# The variational problem corresponding to hyperelasticity
 
55
L = inner(P, grad(v))*dx - inner(B, v)*dx #- inner(T, v)*ds
 
56
a = derivative(L, u, du)