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
//! The material row of one cell, read **by position** — the shape every
//! constitutive law of the continuum receives.
//!
//! One reader for the three families: a stateless law, a return-map law and a
//! direct-update law all get the same thing, because the question « where does
//! this law's third material constant sit in this field? » was settled once for
//! the zone, and has nothing to do with how the law integrates.
//!
//! Neither accessor returns a `Result` or an `Option`: the presence of a
//! required component was proved when the layout was resolved, and an absent
//! *optional* one yields the caller's default rather than a value to unwrap.
use crateABSENT_COMPONENT;
/// The material of one cell, plus where each component of a law's contract sits
/// in it.
///
/// ```
/// # use pyrucast::aggregate::Aggregate;
/// # use pyrucast::atoms::{ElementType, Node};
/// # use pyrucast::containers::element_field::SubElementField;
/// # use pyrucast::containers::field::SubField;
/// # use pyrucast::containers::finite_element_space::FiniteElementSpace;
/// # use pyrucast::containers::mesh::{Mesh, SubMesh};
/// # use pyrucast::coords::Coords;
/// # use pyrucast::handle::Handle;
/// # use pyrucast::models::continuum::material::MatRead;
/// # let coords = Handle::new(Coords::new(2).unwrap());
/// # let n: Vec<Node> = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.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()])?;
/// # let fes = FiniteElementSpace::lagrange1(&Mesh::from_submesh(sm))?;
/// // Un matériau rangé « à l'envers » du contrat de la loi.
/// let materiau = SubElementField::from_uniform_per_component(
/// fes.get(0)?, vec!["nu".into(), "E".into()], &[0.3, 210_000.0])?;
/// let idx = materiau.resolve_components(&["E", "nu"], "material")?;
/// let mat = MatRead::new(materiau.point_values(0, 0)?, &idx, &[]);
/// // La table absorbe l'écart : `E` reste le premier du contrat.
/// assert_eq!(mat.get(0), 210_000.0);
/// # Ok::<(), pyrucast::PyrucastError>(())
/// ```