conspire/constitutive/hybrid/
mod.rs1mod elastic;
4mod elastic_viscoplastic;
5mod hyperelastic;
6mod hyperelastic_viscoplastic;
7
8use crate::{constitutive::ConstitutiveError, mechanics::DeformationGradient};
9use std::{
10 any::type_name,
11 fmt::{self, Debug, Formatter},
12};
13
14#[derive(Clone)]
16pub struct Additive<C1, C2>(C1, C2);
17
18impl<C1, C2> From<(C1, C2)> for Additive<C1, C2> {
19 fn from((constitutive_model_1, constitutive_model_2): (C1, C2)) -> Self {
20 Self(constitutive_model_1, constitutive_model_2)
21 }
22}
23
24#[derive(Clone)]
26pub struct Multiplicative<C1, C2>(C1, C2);
27
28impl<C1, C2> From<(C1, C2)> for Multiplicative<C1, C2> {
29 fn from((constitutive_model_1, constitutive_model_2): (C1, C2)) -> Self {
30 Self(constitutive_model_1, constitutive_model_2)
31 }
32}
33
34pub trait MultiplicativeTrait {
36 fn deformation_gradients(
37 &self,
38 deformation_gradient: &DeformationGradient,
39 ) -> Result<(DeformationGradient, DeformationGradient), ConstitutiveError>;
40}
41
42impl<C1, C2> Debug for Additive<C1, C2> {
43 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
44 write!(
45 f,
46 "Additive({}, {})",
47 type_name::<C1>()
48 .rsplit("::")
49 .next()
50 .unwrap()
51 .split("<")
52 .next()
53 .unwrap(),
54 type_name::<C2>()
55 .rsplit("::")
56 .next()
57 .unwrap()
58 .split("<")
59 .next()
60 .unwrap()
61 )
62 }
63}
64
65impl<C1, C2> Debug for Multiplicative<C1, C2> {
66 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
67 write!(
68 f,
69 "Multiplicative({}, {})",
70 type_name::<C1>()
71 .rsplit("::")
72 .next()
73 .unwrap()
74 .split("<")
75 .next()
76 .unwrap(),
77 type_name::<C2>()
78 .rsplit("::")
79 .next()
80 .unwrap()
81 .split("<")
82 .next()
83 .unwrap()
84 )
85 }
86}