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
//! Python wrappers for [`crate::ops::model`] — the physics declarations,
//! which produce a `Model`.
//!
//! Each one spans the **whole** support it is given (one zone per subspace);
//! heterogeneous physics compose with `|`.
use crateRelationSense;
use cratemodel;
use cratePyFiniteElementSpace;
use cratePyMesh;
use cratePyModel;
use cratePyNodeField;
use *;
use py_op;
/// `model.interface_transfer(side_a, side_b, target, variables, tol=1e-9)` —
/// the exchange law `j·n = h(c₁ − c₂)` across an interface between two bodies
/// that do **not** share their nodes, coupling into the model `target`.
///
/// `variables` lists the exchanged unknowns of `target`, each coupling into
/// the dual row `target` pairs it with: `["c_H2"]` on a `fick` model for a
/// coating, `["T"]` on a `heat_conduction` for a contact resistance, the
/// displacements on an `elasticity` for a bonded joint of finite stiffness.
/// Neither the dual row nor the nature is an argument: both are read from
/// `target`, and a variable `target` does not declare — or variables of two
/// natures — raise. `h_<variable>` is supplied at assembly time.
///
/// `side_a` and `side_b` are the two facing **boundary** FE spaces, which
/// must be conforming — same element type, same cell count, and local node
/// `k` of a cell facing local node `k` of its counterpart, within `tol`, a
/// **distance** in the length unit of the mesh. A non-matching interface
/// raises rather than being projected.
///
/// This is what lets the field **jump** across the interface: with a shared
/// node it could not. The jump is `q/h` for a flux density `q`.
/// `model.dirichlet(imposed_mesh, target, variable, sense="=")` — Dirichlet
/// constraint (a single sub-model) holding `variable` on the nodes of
/// `imposed_mesh`, via Lagrange multipliers.
///
/// `imposed_mesh` is the POI1 mesh of constrained nodes, one relation per
/// node. `target` is the model being constrained: `variable` must be one of
/// its primals, and its dual row is read from it — the `T → q` map is the
/// target's business, not something to retype. Each relation gets a multiplier
/// node of its own, minted beside its constrained node (`Model.multiplier_mesh()`
/// gives them back); its names are those of every constraint relation, `lambda`
/// and `imposed`. The imposed value `u_d` is written in the load field at the
/// multiplier node's `imposed` component — `Model.constraint_rhs` does it from
/// the constrained node.
///
/// **One variable, and one only** — compose for a clamp:
/// `dirichlet(nodes, m, "u_x") | dirichlet(nodes, m, "u_y")`.
///
/// `sense` (`"="`, the default, `">="` or `"<="`) turns the constraint
/// unilateral (`u ≥ u_d` / `u ≤ u_d`): the matrix carries the sense, and
/// `solve` runs its active-set loop. See the model chapter of the book for the
/// full semantics.
/// `model.mpc(terms, target, sense="=")` — multi-point constraint (a single
/// sub-model) imposing, per relation, `Σₖ aₖ·u(nodeₖ, varₖ) = g` via Lagrange
/// multipliers.
///
/// `terms` is a list of `(mesh, variable, coefficient)` tuples: each `mesh` is
/// a POI1 mesh (one node per relation), paired element-for-element with the
/// others (relation `r` = cell `r` of every mesh); each `variable` is a primal
/// of `target`, the model being constrained — the union of two models to tie
/// two bodies — whose dual row is read from it. Each relation gets a
/// multiplier node of its own, minted beside the node of the first term; `g`
/// is written in the load field at its `imposed` component (default `0`).
/// `sense` (`"="`, the default, `">="` or `"<="`) turns the relations
/// unilateral (`Σ aₖ·uₖ ≥ g` / `≤ g`): the matrix carries the sense, and
/// `solve` runs its active-set loop. See the constraints chapter of the book.
/// `model.embedded(immersed, host, target, variables, tol=1e-6)` — embedded
/// (immersed) constraint (a single sub-model) tying each node of `immersed` to
/// the interpolation of `host` at that node, via Lagrange multipliers.
///
/// `immersed` and `host` are meshes sharing one Coords (e.g. a bar embedded in
/// a volume). `target` is the model being constrained; `variables` lists the
/// primals of `target` to tie (e.g. `["u_x", "u_y", "u_z"]`), each dual row
/// read from it. The coupling weights are the host shape functions at each
/// immersed node, computed once at build by locating the node in the host (an
/// immersed node outside the host is an error); `tol` is the location
/// tolerance, a gap in the host's **reference** element, without dimension.
/// Each relation — one per immersed node and variable — gets a multiplier node
/// of its own; the right-hand side defaults to `0` (a rigid tie). See the
/// constraints chapter of the book.
/// `model.contact(slave, master, target, variables)` — node-to-surface contact
/// (a single sub-model): prevent the nodes of `slave` from penetrating the
/// oriented `master` surface mesh, one **unilateral** relation (`≥`) per slave
/// node.
///
/// Each slave node is paired at build with its closest master facet
/// (projection weights, facet normal, initial signed gap); the pairing is
/// then fixed (linearised, frictionless contact). The master surface must
/// be consistently oriented with its normal pointing toward the slave
/// body. `target` is the model being constrained; `variables` lists its
/// displacement primals, one per space dimension in ambient order (e.g.
/// `["u_x", "u_y"]`), each dual row read from it. Each relation gets a
/// multiplier node of its own, minted beside its slave node.
///
/// Solve with `solve`. The initial-gap right-hand side `-g0` is a load the
/// contact carries: `node_field.external_forces` returns it with the other
/// loads of the model. See the contact chapter of the book.
/// `model.update_contact(model, displacement)` — the model with its contacts
/// **updated** to the positions `X + u`: `X` the active configuration, `u` read
/// in `displacement` on each contact's variables (`u_x`, `u_y`, `u_z`; a node
/// or a component it lacks reads zero). Every other sub-model is shared as it
/// is; a model without contact comes back unchanged.
///
/// Each slave node is paired again with its closest master facet on `X + u`,
/// and its relation becomes the gap linearised there, written in total
/// displacement from `X`: the right-hand side the contact carries is `-g~`,
/// the gap of the new pairing measured on `X`. The multiplier nodes are kept,
/// so the unknowns `lambda` and the rows `imposed` stay the same; at `u = 0`,
/// the contact as it was built. A master facet collapsed by the displacement
/// is not detected here.
///
/// What large displacements call for: the step-by-step loop updates its
/// contacts each time it rebuilds its operator. See the contact chapter of the
/// book.