Debian Codegraph @

demo/undocumented/elastodynamics/cpp/ElastoDynamics.ufl

raw
1 # Copyright (c) 2009 Mirko Maraldi 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 # First added: 2009-01-22
19 # Last changed: 2009-01-27
20 #
21 # The bilinear form and linear form for linear elastodynamics
22 # using the generalised-alpha method
23 #
24 # Compile this form with FFC: ffc -l dolfin ElastoDynamics.ufl.
25
26 from ufl_legacy import (Coefficient, ds, dx, FiniteElement, VectorElement,
27 Identity, inner, grad, tr, sym,
28 triangle, TestFunction, TrialFunction)
29
30 element = VectorElement("Lagrange", triangle, 1)
31 DG0 = FiniteElement("Discontinuous Lagrange", triangle, 0)
32
33 # Test and trial functions
34 r = TestFunction(element)
35 u = TrialFunction(element)
36
37 # Fields from previous time step
38 u0 = Coefficient(element) # displacement
39 v0 = Coefficient(element) # velocity
40 a0 = Coefficient(element) # acceleration
41 p0 = Coefficient(element) # external load
42
43 # External forces
44 f = Coefficient(element) # body forces
45 p = Coefficient(element) # externally applied loads
46
47 # Material parameters
48 rho = Coefficient(DG0) # mass density
49 eta = Coefficient(DG0) # damping coefficient
50 lmbda = Coefficient(DG0) # Lame coefficient
51 mu = Coefficient(DG0) # Lame coefficient
52
53 # Time stepping parameters
54 alpha_m = Coefficient(DG0)
55 alpha_f = Coefficient(DG0)
56 beta = Coefficient(DG0)
57 gamma = Coefficient(DG0)
58 dt = Coefficient(DG0)
59
60 factor_m1 = rho*(1.0-alpha_m)/(beta*dt*dt)
61 factor_m2 = rho*(1.0-alpha_m)/(beta*dt)
62 factor_m3 = rho*(1.0-alpha_m-2.0*beta)/(2.0*beta)
63
64 factor_d1 = eta*(1.0-alpha_f)*gamma/(beta*dt)
65 factor_d2 = eta*((1.0-alpha_f)*gamma-beta)/beta
66 factor_d3 = eta*(gamma-2.0*beta)*(1.0-alpha_f)*dt/(2.0*beta)
67
68 # Stress tensor
69 def sigma(r):
70 return 2.0*mu*sym(grad(r)) + lmbda*tr(sym(grad(r)))*Identity(r.geometric_dimension())
71
72 # Forms
73 a = factor_m1*inner(r, u)*dx \
74 +factor_d1*inner(r, u)*dx \
75 +(1.0-alpha_f)*inner(grad(r), sigma(u))*dx
76
77 L = factor_m1*inner(r, u0)*dx + factor_m2*inner(r, v0)*dx + factor_m3*inner(r, a0)*dx \
78 + factor_d1*inner(r, u0)*dx + factor_d2*inner(r, v0)*dx + factor_d3*inner(r, a0)*dx \
79 - alpha_f*inner(grad(r), sigma(u0))*dx \
80 + inner(r, f)*dx + (1.0-alpha_f)*inner(r, p)*ds(3) + alpha_f*inner(r, p0)*ds(3)
81