Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/equations/linear_elasticity_1d.jl
5586 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
@doc raw"""
9
LinearElasticityEquations1D(;rho::Real, lambda::Real, mu::Real)
10
11
Linear elasticity equations in one space dimension. The equations are given by
12
```math
13
\partial_t
14
\begin{pmatrix}
15
v_1 \\ \sigma_{11}
16
\end{pmatrix}
17
+
18
\partial_x
19
\begin{pmatrix}
20
-\frac{1}{\rho} \sigma_{11} \\ -\frac{\rho}{c_1^2} v_1
21
\end{pmatrix}
22
=
23
\begin{pmatrix}
24
0 \\ 0
25
\end{pmatrix}.
26
```
27
The variables are the deformation velocity `v_1` and the stress `\sigma_{11}`.
28
29
The parameters are the constant density of the material `\rho`
30
and the Lamé parameters `\lambda` and `\mu`.
31
From these, one can compute the dilatational wave speed as
32
```math
33
c_1^2= \frac{\lambda + 2 * \mu}{\rho}
34
```
35
In one dimension the linear elasticity equations reduce to a wave equation.
36
37
For reference, see
38
- Aleksey Sikstel (2020)
39
Analysis and numerical methods for coupled hyperbolic conservation laws
40
[DOI: 10.18154/RWTH-2020-07821](https://doi.org/10.18154/RWTH-2020-07821)
41
"""
42
struct LinearElasticityEquations1D{RealT <: Real} <:
43
AbstractLinearElasticityEquations{1, 2}
44
rho::RealT # Constant density of the material
45
c1::RealT # Dilatational wave speed
46
E::RealT # Young's modulus
47
end
48
49
function LinearElasticityEquations1D(; rho::Real, mu::Real, lambda::Real)
50
if !(rho > 0)
51
throw(ArgumentError("Density rho must be positive."))
52
end
53
if !(mu > 0)
54
throw(ArgumentError("Shear modulus mu (second Lamé parameter) must be positive."))
55
end
56
57
c1_squared = (lambda + 2 * mu) / rho
58
59
# Young's modulus
60
# See for reference equation (11-11) in
61
# https://cns.gatech.edu/~predrag/courses/PHYS-4421-04/lautrup/book/elastic.pdf
62
E = mu * (3 * lambda + 2 * mu) / (lambda + mu)
63
return LinearElasticityEquations1D(rho, sqrt(c1_squared), E)
64
end
65
66
function varnames(::typeof(cons2cons), ::LinearElasticityEquations1D)
67
return ("v1", "sigma11")
68
end
69
function varnames(::typeof(cons2prim), ::LinearElasticityEquations1D)
70
return ("v1", "sigma11")
71
end
72
73
"""
74
initial_condition_convergence_test(x, t, equations::LinearElasticityEquations1D)
75
76
A smooth initial condition used for convergence tests.
77
This requires that the material parameters `rho` is a positive integer
78
and `c1` is equal to one.
79
"""
80
function initial_condition_convergence_test(x, t,
81
equations::LinearElasticityEquations1D)
82
@unpack rho = equations
83
84
v1 = sinpi(2 * t) * cospi(2 * x[1] / rho)
85
sigma11 = -cospi(2 * t) * sinpi(2 * x[1] * rho)
86
87
return SVector(v1, sigma11)
88
end
89
90
# Calculate 1D flux for a single point
91
@inline function flux(u, orientation::Integer, equations::LinearElasticityEquations1D)
92
@unpack rho, c1 = equations
93
v1, sigma11 = u
94
f1 = -sigma11 / rho
95
f2 = -rho * c1^2 * v1
96
97
return SVector(f1, f2)
98
end
99
100
"""
101
have_constant_speed(::LinearElasticityEquations1D)
102
103
Indicates whether the characteristic speeds are constant, i.e., independent of the solution.
104
Queried in the timestep computation [`StepsizeCallback`](@ref) and [`linear_structure`](@ref).
105
106
# Returns
107
- `True()`
108
"""
109
@inline have_constant_speed(::LinearElasticityEquations1D) = True()
110
111
@inline function max_abs_speed_naive(u_ll, u_rr, orientation::Integer,
112
equations::LinearElasticityEquations1D)
113
return equations.c1
114
end
115
116
# Required for `StepsizeCallback`
117
@inline function max_abs_speeds(equations::LinearElasticityEquations1D)
118
return equations.c1
119
end
120
121
# More refined estimates for minimum and maximum wave speeds for HLL-type fluxes
122
@inline function min_max_speed_davis(u_ll, u_rr, orientation::Integer,
123
equations::LinearElasticityEquations1D)
124
@unpack c1 = equations
125
126
λ_min = -c1
127
λ_max = c1
128
129
return λ_min, λ_max
130
end
131
132
# Convert conservative variables to primitive
133
@inline cons2prim(u, equations::LinearElasticityEquations1D) = u
134
@inline cons2entropy(u, ::LinearElasticityEquations1D) = u
135
136
# Useful for e.g. limiting indicator variable selection
137
@inline function velocity(u, equations::LinearElasticityEquations1D)
138
return u[1]
139
end
140
141
@doc raw"""
142
energy_kinetic(u, equations::LinearElasticityEquations1D)
143
144
Calculate kinetic energy for a conservative state `u` as
145
```math
146
E_{kin} = \frac{1}{2} \rho v_1^2
147
```
148
"""
149
@inline function energy_kinetic(u, equations::LinearElasticityEquations1D)
150
return 0.5f0 * equations.rho * u[1]^2
151
end
152
153
@doc raw"""
154
energy_internal(u, equations::LinearElasticityEquations1D)
155
156
Calculate internal energy for a conservative state `u` as
157
```math
158
E_{int} = \frac{1}{2} \frac{\sigma_{11}^2}{E}
159
```
160
"""
161
@inline function energy_internal(u, equations::LinearElasticityEquations1D)
162
return 0.5f0 * u[2]^2 / equations.E
163
end
164
165
"""
166
energy_total(u, equations::LinearElasticityEquations1D)
167
168
Calculate total energy for a conservative state `u` as the sum of
169
[`energy_kinetic`](@ref) and [`energy_internal`](@ref).
170
"""
171
@inline function energy_total(u, equations::LinearElasticityEquations1D)
172
return energy_kinetic(u, equations) + energy_internal(u, equations)
173
end
174
175
"""
176
entropy(u, equations::LinearElasticityEquations1D)
177
178
Calculate entropy for a conservative state `u`,
179
here same as [`energy_total(u, equations::AbstractLinearElasticityEquations)`](@ref).
180
"""
181
@inline entropy(u, equations::LinearElasticityEquations1D) = energy_total(u, equations)
182
end # muladd
183
184