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
//! The **Voigt** representation of a symmetric tensor — the kinematic
//! hypothesis that fixes its layout, the names that go with it, and the algebra
//! on top.
//!
//! Nothing here belongs to one physics. [`Kinematics`] is used by elasticity,
//! plasticity and damage alike; the invariants by anything reading a stress.
//! The type used to be called `Kinematics` and to live in
//! `models/elasticity.rs` — a name and a place that said elasticity where it
//! meant *how a 3-D problem is reduced*.
//!
//! Voigt order is `[xx, yy, zz, yz, xz, xy]`, with **engineering** shear.
use ;
/// Which 2-D assumption (or 3-D solid) to use for the constitutive matrix.
///
/// ```
/// # use pyrucast::models::tensor::Kinematics;
/// # use pyrucast::models::continuum::elastic;
/// // The chosen kinematics decides the number of Voigt components.
/// assert_eq!(elastic::constitutive(210e3, 0.3, Kinematics::PlaneStress, 2).len(), 3);
/// assert_eq!(elastic::constitutive(210e3, 0.3, Kinematics::Axisymmetric, 2).len(), 4);
/// assert_eq!(elastic::constitutive(210e3, 0.3, Kinematics::Full3D, 3).len(), 6);
/// ```
/// # use pyrucast::models::tensor::Kinematics;
/// Axis suffixes for the vector components, indexed by spatial direction.
const AXES: = ;
/// Where each **axisymmetric** Voigt slot `[rr, zz, θθ, rz]` sits in the full
/// 3-D order [`TENSOR_SUFFIXES`] (`[xx, yy, zz, yz, xz, xy]`). The whole
/// axisymmetric specialisation of this law is this one index map: the state and
/// the radial return stay full 3-D, only the projection in and out changes.
const AXI_TO_3D: = ;
pub
pub
/// Project the full 3-D stress to the kinematics's Voigt slot `r`.
/// 2-D order is `[xx, yy, xy]`; 3-D is the full `[xx, yy, zz, yz, xz, xy]`.
pub
/// How many stress components [`voigt_names`] lists — the same answer without
/// building the list.
///
/// A behaviour kernel needs the *count* at every Gauss point (to know where its
/// state variables start) and never the names; allocating a `Vec<String>` to
/// read its length was one allocation per point.
pub
/// The Voigt components of a symmetric tensor of the continuum under `prefix`,
/// in the order the laws' indices assume: `[xx, yy, xy]` in plane 2-D,
/// `[xx, yy, zz, xy]` on a body of revolution (`zz` the hoop), the six
/// `[xx, yy, zz, yz, xz, xy]` in 3-D — the hoop `θθ` named `zz` after Cast3M
/// (`x = r`, `y = z`). The strain a law reads and the stress it writes share
/// this layout, each under its own name.
pub
/// First invariant `I₁ = tr(σ)`.
///
/// ```
/// # use pyrucast::models::tensor;
/// # use pyrucast::models::plasticity::law;
/// // I₁ = tr(σ) : la part sphérique, trois fois la pression moyenne.
/// assert_eq!(tensor::i1(&[1.0, 2.0, 3.0, 9.0, 9.0, 9.0]), 6.0);
/// ```
/// # use pyrucast::models::tensor;
/// The stress deviator `s = σ − (I₁/3)·I` (same Voigt order).
///
/// ```
/// # use pyrucast::models::tensor;
/// # use pyrucast::models::plasticity::law;
/// // The deviator is trace-free, and leaves the shears untouched.
/// let s = tensor::deviator(&[3.0, 0.0, 0.0, 0.0, 0.0, 5.0]);
/// assert!(tensor::i1(&s).abs() < 1e-12);
/// assert_eq!(s[5], 5.0);
/// ```
/// # use pyrucast::models::tensor;
/// Second deviatoric invariant `J₂ = ½ s:s` (off-diagonals counted twice).
///
/// ```
/// # use pyrucast::models::tensor;
/// # use pyrucast::models::plasticity::law;
/// // J₂ = ½ s:s, the off-diagonal terms counted **twice**.
/// assert_eq!(tensor::j2(&[0.0, 0.0, 0.0, 0.0, 0.0, 1.0]), 1.0);
/// // Pressure insensitive: adding a spherical part changes nothing.
/// let a = tensor::j2(&[1.0, -1.0, 0.0, 0.0, 0.0, 0.0]);
/// let b = tensor::j2(&[101.0, 99.0, 100.0, 0.0, 0.0, 0.0]);
/// assert!((a - b).abs() < 1e-9);
/// ```
/// # use pyrucast::models::tensor;
/// Third deviatoric invariant `J₃ = det(s)`.
///
/// ```
/// # use pyrucast::models::tensor;
/// # use pyrucast::models::plasticity::law;
/// // J₃ = det(s) — what distinguishes tension from compression, and makes
/// // the Lode angle of the four-parameter criteria.
/// assert!(tensor::j3(&[1.0, 1.0, 1.0, 0.0, 0.0, 0.0]).abs() < 1e-12);
/// assert!(tensor::j3(&[2.0, -1.0, -1.0, 0.0, 0.0, 0.0]) > 0.0);
/// ```
/// # use pyrucast::models::tensor;
/// von Mises equivalent stress `q = √(3 J₂)`.
///
/// ```
/// # use pyrucast::models::tensor;
/// # use pyrucast::models::plasticity::law;
/// // q = √(3 J₂). En traction uniaxiale, q vaut la contrainte appliquée.
/// let q = tensor::von_mises_stress(&[300.0, 0.0, 0.0, 0.0, 0.0, 0.0]);
/// assert!((q - 300.0).abs() < 1e-9);
/// ```
/// # use pyrucast::models::tensor;
/// `½(D + Dᵀ)` — exact, and the identity on an already-symmetric matrix.
pub