# Copyright (c) 2005 Johan Jansson (johanjan@math.chalmers.se)
# Licensed under the GNU GPL Version 2
#
# First added:  2005
# Last changed: 2006-03-28
#
# The bilinear form for classical linear elasticity (Navier)
# Compile this form with FFC: ffc Elasticity.form.

K1 = VectorElement("Lagrange", "triangle", 1)
K2 = VectorElement("Lagrange", "triangle", 1)
K3 = FiniteElement("Lagrange", "triangle", 1)

K = K1 + K2

(v_0, v_1) = TestFunctions(K)
(U1_0, U1_1) = TrialFunctions(K)
(U0_0, U0_1) = Functions(K)

mu = Function(K3)
lmbda = Function(K3)
f = Function(K2)

# Dimension of domain
d = K1.cell_dimension()

def epsilon(u):
    return 0.5 * (grad(u) + transp(grad(u)))

def E(e):
    Ee = mult(mu, e) + mult(lmbda, mult(trace(e), Identity(d)))
    return Ee
        
sigma = E(epsilon(U1_0))

a = (dot(U1_1, v_0) - dot(sigma, epsilon(v_1))) * dx
