conspire/domain/partition/feti/block/solid/elastic/vem/
mod.rs1use crate::{
2 constitutive::solid::elastic::Elastic,
3 domain::{
4 ElementModelError,
5 feti::block::element::{DecomposableElements, ElementSystem, ElementSystems, positions},
6 },
7 vem::{
8 NodalCoordinates,
9 block::{
10 Block,
11 element::{VirtualElementError, solid::elastic::ElasticVirtualElement},
12 },
13 },
14};
15
16impl<C, F> DecomposableElements for Block<C, F>
17where
18 C: Elastic,
19 F: ElasticVirtualElement<C>,
20{
21 fn element_systems(
22 &self,
23 nodal_coordinates: &NodalCoordinates,
24 ) -> Result<ElementSystems, ElementModelError> {
25 let elements = self
26 .elements()
27 .iter()
28 .zip(self.elements_nodes())
29 .map(|(element, nodes)| {
30 let coordinates = Self::element_coordinates(nodal_coordinates, nodes);
31 let forces = element.nodal_forces(self.constitutive_model(), &coordinates)?;
32 let stiffnesses =
33 element.nodal_stiffnesses(self.constitutive_model(), &coordinates)?;
34 Ok::<_, VirtualElementError>(ElementSystem::pack(
35 nodes.to_vec(),
36 |a, i| forces[a][i].value(),
37 |a, b, i, j| stiffnesses[a][b][i][j].value(),
38 ))
39 })
40 .collect::<Result<Vec<_>, _>>()
41 .map_err(|error| ElementModelError::upstream(error, self))?;
42 Ok(ElementSystems {
43 positions: positions(nodal_coordinates),
44 elements,
45 })
46 }
47}