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
//! Python wrappers for [`crate::ops::matrix`] — the assemblers, which
//! produce a `Matrix`.
use cratePyElementField;
use cratePyMatrix;
use cratePyModel;
use *;
use py_op;
/// Assemble the stiffness matrix `K` of `model`.
///
/// One matrix covers every unknown of the model, multipliers included: a physics
/// contributes its block, a constraint the two halves `C` and `Cᵀ` of its
/// relations. Boundary conditions have no special status — they are sub-models
/// like the others.
///
/// # Parameters
///
/// - `model`: the physics and the constraints to assemble.
/// - `materials`: the material data, zone by zone. Every sub-model that needs
/// some picks the zone whose FE subspace is its own; a sub-model without
/// material (a constraint) ignores it.
///
/// # Returns
///
/// The matrix, assembled on the configuration active at the call.
///
/// # Raises
///
/// `RuntimeError` if no zone of `materials` lies on the FE subspace of a
/// sub-model with the components its physics requires.
/// Assemble the mass matrix `M` of `model`, or its heat-capacity matrix `C`.
///
/// Mechanics assembles the consistent mass `M = ∫ ρ N_i N_j`, heat conduction the
/// capacity `C = ∫ ρ c_p N_i N_j`. A physics without a mass term (a boundary
/// exchange, a constraint) contributes nothing.
///
/// # Parameters
///
/// - `model`: the physics to assemble.
/// - `materials`: the material data, zone by zone, as for [`stiffness`]. It must
/// carry `rho` on a mechanical zone, `rho` and `cp` on a thermal one: the
/// stiffness does not read them, so the material field holds them only if
/// given.
///
/// # Returns
///
/// The matrix, assembled on the configuration active at the call.
///
/// # Raises
///
/// `RuntimeError` if `rho` or `cp` is missing on a zone that needs it.
/// Lump an assembled matrix into a diagonal one, each term the sum of its row.
///
/// Applied to a consistent mass or capacity matrix, it yields the lumped
/// (diagonal) mass, which conserves the total mass:
/// `Σ_i M_lump[i,i] = Σ_ij M[i,j]`. It is the cheap, uncoupled form explicit
/// time schemes use.
///
/// # Parameters
///
/// - `matrix`: an assembled, square matrix whose row `i` and column `i` carry
/// the same node.
///
/// # Returns
///
/// A new matrix with the rows and the columns of `matrix`, in the same order,
/// and one diagonal block per row support: it is solved, multiplied by a field
/// and saved like `matrix`, which is left untouched.
///
/// # Raises
///
/// `RuntimeError` if `matrix` has no assembled values (an output of `|` or
/// `filter`, before `assemble()`).
/// Assemble the geometric (initial-stress) stiffness `K_g` of `model`.
///
/// `K_g[(i,a),(j,b)] = δ_ab ∫ ∇N_i · σ · ∇N_j` is the stiffening a stress in
/// place brings: the term of buckling and of prestressed analyses. It does not
/// depend on the constitutive law. A physics without geometric stiffness (heat
/// conduction, a constraint) contributes nothing.
///
/// # Parameters
///
/// - `model`: the physics to assemble.
/// - `materials`: the material data, zone by zone, as for [`stiffness`].
/// - `stress`: the current Cauchy stress at the Gauss points, components
/// `sigma_*` — typically what `element_field.integrate_behavior` returns. Each
/// zone is picked by its FE subspace, like `materials`.
///
/// # Returns
///
/// The matrix, assembled on the configuration active at the call.
///
/// # Raises
///
/// `RuntimeError` if `stress` lacks a `sigma_*` component on a mechanical zone.
/// Assemble the consistent (algorithmic) tangent `K_t = ∫ Bᵀ D_alg B` of `model`.
///
/// `D_alg` is the derivative of the step `ε(B) ↦ σ(B)`, the state at A held
/// fixed: both ends of the step are in its definition, hence the same inputs as
/// `element_field.integrate_behavior`. This is the matrix that gives a Newton
/// iteration its quadratic convergence.
///
/// A linear physics (conduction, diffusion, exchanges, trusses, beams, shells)
/// and the constraints have no law to differentiate: their tangent is their
/// stiffness, assembled without reading `deformation`.
///
/// # Parameters
///
/// - `model`: the physics and the constraints to assemble.
/// - `materials`: the material data, zone by zone, as for [`stiffness`].
/// - `deformation`: the input of the laws at the end of the step, `ε(B)` — from
/// `element_field.deformation`.
/// - `prev`: the state at A, the converged output of the previous step; on a
/// first step, `element_field.initial_state(model, materials)`.
/// - `dt`: the time increment; `None` when no law depends on the rate.
///
/// # Returns
///
/// The matrix, assembled on the configuration active at the call.
///
/// # Raises
///
/// `RuntimeError` if a non-linear law of `model` has no tangent of its own
/// (`model.mazars`, `model.damage_tc`, `model.damage_sic_sic`): the call fails
/// rather than return an empty block.
///
/// # Notes
///
/// `D_alg` is evaluated at each Gauss point during the assembly: no field of
/// moduli is stored between the law and this function.