1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
//! Reissner-Mindlin — the thick-shell formulation.
//!
//! The normal fibre stays straight but **not** normal: its rotation is an
//! independent field, so the transverse shear `γ = ∇w + θ` is a strain of its
//! own rather than something forced to zero. That is what makes the element work
//! for a thick shell, and what makes it need care for a thin one.
//!
//! ## The three strains
//!
//! In the local frame, with the transverse deflection `w` and the fibre
//! rotations `θ_x`, `θ_y`:
//!
//! ```text
//! membrane ε = [∂u/∂x, ∂v/∂y, ∂u/∂y + ∂v/∂x]
//! bending κ = [∂θ_y/∂x, −∂θ_x/∂y, ∂θ_y/∂y − ∂θ_x/∂x]
//! shear γ = [∂w/∂x + θ_y, ∂w/∂y − θ_x]
//! ```
//!
//! and the laws that carry them, for a homogeneous section:
//!
//! ```text
//! D_m = Eh/(1−ν²)·[[1, ν, 0], [ν, 1, 0], [0, 0, (1−ν)/2]]
//! D_b = D_m · h²/12
//! D_s = k_s·G·h k_s = 5/6
//! ```
//!
//! The bending law is the membrane one scaled by `h²/12`, which is the whole
//! content of « plane sections »: the same plane-stress material, integrated
//! across the thickness with a `z²` weight.
//!
//! ## Why the shear is integrated reduced
//!
//! As the shell thins, `D_s` (linear in `h`) overwhelms `D_b` (cubic in `h`) by
//! `1/h²`. Integrated at full quadrature, the shear term then imposes `γ = 0`
//! **pointwise**, which a linear element can only satisfy by refusing to bend at
//! all: the deflection collapses towards zero and no mesh refinement recovers it.
//! That is **shear locking**.
//!
//! Integrating the shear at a single point relaxes the constraint to a mean, the
//! element bends, and the answer converges. The [Timoshenko
//! beam](crate::models::timoshenko) once met the same locking and was answered
//! the same way; it has since been replaced by an element that is *exact*, and
//! owns its interpolation rather than integrating one. So this is now the only
//! multi-quadrature element in the crate — the pattern is general, its user is
//! not.
//!
//! The alternative to relaxing the constraint is not to have one:
//! [discrete Kirchhoff](super::kirchhoff) drops the shear strain outright, and
//! has nothing left to lock.
use crateSubElementField;
use crateABSENT_COMPONENT;
use crateResult;
use crate;
use crate;
/// The membrane law `D_m` of a homogeneous section (plane stress × thickness).
///
/// ```
/// # use pyrucast::models::shell::{self, ShellFormulation};
/// # use pyrucast::models::shell::thick;
/// // Plane stress × thickness: D_m is proportional to h.
/// let a = thick::membrane_law(210_000.0, 0.3, 0.01);
/// let b = thick::membrane_law(210_000.0, 0.3, 0.02);
/// assert!((b[0][0] - 2.0 * a[0][0]).abs() < 1e-6);
/// ```
/// The bending law `D_b = D_m · h²/12` — the same material, weighted by `z²`
/// across the thickness.
///
/// ```
/// # use pyrucast::models::shell::{self, ShellFormulation};
/// # use pyrucast::models::shell::thick;
/// // The same material weighted by z² over the thickness: D_b = D_m · h²/12.
/// let h = 0.01;
/// let m = thick::membrane_law(210_000.0, 0.3, h);
/// let b = thick::bending_law(210_000.0, 0.3, h);
/// assert!((b[0][0] - m[0][0] * h * h / 12.0).abs() < 1e-12);
/// ```
/// The transverse-shear modulus `k_s·G·h`.
///
/// ```
/// # use pyrucast::models::shell::{self, ShellFormulation};
/// # use pyrucast::models::shell::thick;
/// // k_s·G·h, with G = E / 2(1+ν).
/// let g = 210_000.0 / 2.6;
/// assert!((thick::shear_law(210_000.0, 0.3, 0.01, 5.0 / 6.0)
/// - 5.0 / 6.0 * g * 0.01).abs() < 1e-9);
/// ```
/// The shear-correction factor: the material's own `k_s` if it carries one,
/// `5/6` otherwise — the value for a homogeneous rectangular section.
///
/// ```
/// # use pyrucast::aggregate::Aggregate;
/// # use pyrucast::atoms::{ElementType, Node};
/// # use pyrucast::containers::element_field::SubElementField;
/// # use pyrucast::containers::finite_element_space::FiniteElementSpace;
/// # use pyrucast::containers::matrix::DofOrdering;
/// # use pyrucast::containers::mesh::{Mesh, SubMesh};
/// # use pyrucast::coords::Coords;
/// # use pyrucast::handle::Handle;
/// # use pyrucast::models::kernel::{assemble_block, reduce_cells};
/// # use pyrucast::models::shell;
/// # let coords = Handle::new(Coords::new(3).unwrap());
/// # let n: Vec<Node> = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
/// # .iter().map(|p| Node::create_in(coords.clone(), p).unwrap()).collect();
/// # let mut sm = SubMesh::new(coords.clone(), ElementType::TRI3);
/// # sm.add_cell(&[n[0].id(), n[1].id(), n[2].id()]).unwrap();
/// # let fes = FiniteElementSpace::lagrange1(&Mesh::from_submesh(sm)).unwrap();
/// # let zone = fes.get(0).unwrap();
/// # let support = zone.read().submesh().read().to_poi1().unwrap();
/// # let mat = Handle::new(SubElementField::from_uniform_per_component(
/// # zone.clone(), vec!["E".into(), "nu".into(), "h".into()],
/// # &[210_000.0, 0.3, 0.01]).unwrap());
/// # let ddl = || (vec!["f_x".to_string(), "f_y".to_string(), "f_z".to_string(),
/// # "m_x".to_string(), "m_y".to_string(), "m_z".to_string()],
/// # vec!["u_x".to_string(), "u_y".to_string(), "u_z".to_string(),
/// # "r_x".to_string(), "r_y".to_string(), "r_z".to_string()]);
/// # use pyrucast::models::shell::thick;
/// # use pyrucast::models::ElementLayout;
/// # use pyrucast::containers::field::ABSENT_COMPONENT;
/// // Without `k_s` in the material, the value of a homogeneous rectangular
/// // section: 5/6. A thick shell's optional contract is `["rho", "k_s"]`, and
/// // here both are missing.
/// let sans = ElementLayout {
/// material: vec![0, 1, 2],
/// optional_material: vec![ABSENT_COMPONENT, ABSENT_COMPONENT],
/// state: vec![],
/// };
/// assert!((thick::shear_factor(mat.read().point_values(0, 0)?, &sans) - 5.0 / 6.0).abs() < 1e-12);
/// // With it, the material's value wins.
/// # let propre = SubElementField::from_uniform_per_component(
/// # zone.clone(), vec!["E".into(), "nu".into(), "h".into(), "k_s".into()],
/// # &[210_000.0, 0.3, 0.01, 0.85])?;
/// let avec = ElementLayout {
/// material: vec![0, 1, 2],
/// optional_material: vec![ABSENT_COMPONENT, 3],
/// state: vec![],
/// };
/// assert!((thick::shear_factor(propre.point_values(0, 0)?, &avec) - 0.85).abs() < 1e-12);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```
/// Position of `k_s` in a thick shell's optional material (`["rho", "k_s"]`).
const K_S_SLOT: usize = 1;
/// The local element stiffness of one facet, carried to the global axes.
///
/// `full` carries the membrane and bending terms, `reduced` the transverse
/// shear — two [`CellGeom`] over the same cell, differing only by quadrature.
///
/// ```
/// # use pyrucast::aggregate::Aggregate;
/// # use pyrucast::atoms::{ElementType, Node};
/// # use pyrucast::containers::element_field::SubElementField;
/// # use pyrucast::containers::finite_element_space::FiniteElementSpace;
/// # use pyrucast::containers::matrix::{DofOrdering, Symmetry};
/// # use pyrucast::containers::mesh::{Mesh, SubMesh};
/// # use pyrucast::coords::Coords;
/// # use pyrucast::handle::Handle;
/// # use pyrucast::models::kernel::{assemble_block, reduce_cells};
/// # use pyrucast::models::shell;
/// # let coords = Handle::new(Coords::new(3).unwrap());
/// # let n: Vec<Node> = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
/// # .iter().map(|p| Node::create_in(coords.clone(), p).unwrap()).collect();
/// # let mut sm = SubMesh::new(coords.clone(), ElementType::TRI3);
/// # sm.add_cell(&[n[0].id(), n[1].id(), n[2].id()]).unwrap();
/// # let fes = FiniteElementSpace::lagrange1(&Mesh::from_submesh(sm)).unwrap();
/// # let zone = fes.get(0).unwrap();
/// # let support = zone.read().submesh().read().to_poi1().unwrap();
/// # let mat = Handle::new(SubElementField::from_uniform_per_component(
/// # zone.clone(), vec!["E".into(), "nu".into(), "h".into()],
/// # &[210_000.0, 0.3, 0.01]).unwrap());
/// # let ddl = || (vec!["f_x".to_string(), "f_y".to_string(), "f_z".to_string(),
/// # "m_x".to_string(), "m_y".to_string(), "m_z".to_string()],
/// # vec!["u_x".to_string(), "u_y".to_string(), "u_z".to_string(),
/// # "r_x".to_string(), "r_y".to_string(), "r_z".to_string()]);
/// # use pyrucast::models::shell::thick;
/// // Two `CellGeom`: the **full** quadrature for membrane and bending, the
/// // **reduced** one for transverse shear — that is what keeps a thin shell
/// // from locking.
/// # use pyrucast::models::ElementLayout;
/// # use pyrucast::containers::field::ABSENT_COMPONENT;
/// // `E`, `nu`, `h` in the contract's order; neither `rho` nor `k_s` here.
/// let lay = ElementLayout {
/// material: vec![0, 1, 2],
/// optional_material: vec![ABSENT_COMPONENT, ABSENT_COMPONENT],
/// state: vec![],
/// };
/// let (duals, primals) = ddl();
/// let bloc = assemble_block(
/// &[zone.clone(), zone.clone()], &support, &support, duals, primals,
/// DofOrdering::NodesThenVars, Symmetry::Full, &mat, None,
/// |geoms, m, _s, ke| thick::element_stiffness(&geoms[0], &geoms[1], m, &lay, ke),
/// )?;
/// // The block carries each node's six DOFs: 18 × 18 on a TRI3.
/// assert_eq!((bloc.n_rows(), bloc.n_cols()), (18, 18));
/// // And it is symmetric, like any stiffness.
/// let d = bloc.dense();
/// assert!((0..18).all(|i| (0..18).all(|j| (d[i * 18 + j] - d[j * 18 + i]).abs() < 1e-6)));
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```