conspire/constitutive/hybrid/elastic/additive/
mod.rs1#[cfg(test)]
2mod test;
3
4use crate::{
5 constitutive::{
6 ConstitutiveError,
7 hybrid::Additive,
8 solid::{Solid, elastic::Elastic},
9 },
10 mechanics::{
11 CauchyStress, CauchyTangentStiffness, DeformationGradient, FirstPiolaKirchhoffStress,
12 FirstPiolaKirchhoffTangentStiffness, Scalar, SecondPiolaKirchhoffStress,
13 SecondPiolaKirchhoffTangentStiffness,
14 },
15};
16
17impl<C1, C2> Solid for Additive<C1, C2>
18where
19 C1: Elastic,
20 C2: Elastic,
21{
22 fn bulk_modulus(&self) -> Scalar {
23 self.0.bulk_modulus() + self.1.bulk_modulus()
24 }
25 fn shear_modulus(&self) -> Scalar {
26 self.0.shear_modulus() + self.1.shear_modulus()
27 }
28}
29
30impl<C1, C2> Elastic for Additive<C1, C2>
31where
32 C1: Elastic,
33 C2: Elastic,
34{
35 fn cauchy_stress(
41 &self,
42 deformation_gradient: &DeformationGradient,
43 ) -> Result<CauchyStress, ConstitutiveError> {
44 Ok(self.0.cauchy_stress(deformation_gradient)?
45 + self.1.cauchy_stress(deformation_gradient)?)
46 }
47 fn cauchy_tangent_stiffness(
53 &self,
54 deformation_gradient: &DeformationGradient,
55 ) -> Result<CauchyTangentStiffness, ConstitutiveError> {
56 Ok(self.0.cauchy_tangent_stiffness(deformation_gradient)?
57 + self.1.cauchy_tangent_stiffness(deformation_gradient)?)
58 }
59 fn first_piola_kirchhoff_stress(
65 &self,
66 deformation_gradient: &DeformationGradient,
67 ) -> Result<FirstPiolaKirchhoffStress, ConstitutiveError> {
68 Ok(self.0.first_piola_kirchhoff_stress(deformation_gradient)?
69 + self.1.first_piola_kirchhoff_stress(deformation_gradient)?)
70 }
71 fn first_piola_kirchhoff_tangent_stiffness(
77 &self,
78 deformation_gradient: &DeformationGradient,
79 ) -> Result<FirstPiolaKirchhoffTangentStiffness, ConstitutiveError> {
80 Ok(self
81 .0
82 .first_piola_kirchhoff_tangent_stiffness(deformation_gradient)?
83 + self
84 .1
85 .first_piola_kirchhoff_tangent_stiffness(deformation_gradient)?)
86 }
87 fn second_piola_kirchhoff_stress(
93 &self,
94 deformation_gradient: &DeformationGradient,
95 ) -> Result<SecondPiolaKirchhoffStress, ConstitutiveError> {
96 Ok(self.0.second_piola_kirchhoff_stress(deformation_gradient)?
97 + self.1.second_piola_kirchhoff_stress(deformation_gradient)?)
98 }
99 fn second_piola_kirchhoff_tangent_stiffness(
105 &self,
106 deformation_gradient: &DeformationGradient,
107 ) -> Result<SecondPiolaKirchhoffTangentStiffness, ConstitutiveError> {
108 Ok(self
109 .0
110 .second_piola_kirchhoff_tangent_stiffness(deformation_gradient)?
111 + self
112 .1
113 .second_piola_kirchhoff_tangent_stiffness(deformation_gradient)?)
114 }
115}