#[cfg(test)]
mod test;
use crate::{
constitutive::{
hybrid::{Additive, Hybrid},
solid::{elastic::Elastic, Solid},
Constitutive, ConstitutiveError, Parameters,
},
mechanics::{
CauchyStress, CauchyTangentStiffness, DeformationGradient, FirstPiolaKirchoffStress,
FirstPiolaKirchoffTangentStiffness, Scalar, SecondPiolaKirchoffStress,
SecondPiolaKirchoffTangentStiffness,
},
};
impl<'a, C1: Elastic<'a>, C2: Elastic<'a>> Constitutive<'a> for Additive<C1, C2> {
fn new(_parameters: Parameters<'a>) -> Self {
panic!()
}
}
impl<'a, C1: Elastic<'a>, C2: Elastic<'a>> Solid<'a> for Additive<C1, C2> {
fn get_bulk_modulus(&self) -> &Scalar {
panic!()
}
fn get_shear_modulus(&self) -> &Scalar {
panic!()
}
}
impl<'a, C1: Elastic<'a>, C2: Elastic<'a>> Elastic<'a> for Additive<C1, C2> {
fn calculate_cauchy_stress(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<CauchyStress, ConstitutiveError> {
Ok(self
.get_constitutive_model_1()
.calculate_cauchy_stress(deformation_gradient)?
+ self
.get_constitutive_model_2()
.calculate_cauchy_stress(deformation_gradient)?)
}
fn calculate_cauchy_tangent_stiffness(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<CauchyTangentStiffness, ConstitutiveError> {
Ok(self
.get_constitutive_model_1()
.calculate_cauchy_tangent_stiffness(deformation_gradient)?
+ self
.get_constitutive_model_2()
.calculate_cauchy_tangent_stiffness(deformation_gradient)?)
}
fn calculate_first_piola_kirchoff_stress(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<FirstPiolaKirchoffStress, ConstitutiveError> {
Ok(self
.get_constitutive_model_1()
.calculate_first_piola_kirchoff_stress(deformation_gradient)?
+ self
.get_constitutive_model_2()
.calculate_first_piola_kirchoff_stress(deformation_gradient)?)
}
fn calculate_first_piola_kirchoff_tangent_stiffness(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<FirstPiolaKirchoffTangentStiffness, ConstitutiveError> {
Ok(self
.get_constitutive_model_1()
.calculate_first_piola_kirchoff_tangent_stiffness(deformation_gradient)?
+ self
.get_constitutive_model_2()
.calculate_first_piola_kirchoff_tangent_stiffness(deformation_gradient)?)
}
fn calculate_second_piola_kirchoff_stress(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<SecondPiolaKirchoffStress, ConstitutiveError> {
Ok(self
.get_constitutive_model_1()
.calculate_second_piola_kirchoff_stress(deformation_gradient)?
+ self
.get_constitutive_model_2()
.calculate_second_piola_kirchoff_stress(deformation_gradient)?)
}
fn calculate_second_piola_kirchoff_tangent_stiffness(
&self,
deformation_gradient: &DeformationGradient,
) -> Result<SecondPiolaKirchoffTangentStiffness, ConstitutiveError> {
Ok(self
.get_constitutive_model_1()
.calculate_second_piola_kirchoff_tangent_stiffness(deformation_gradient)?
+ self
.get_constitutive_model_2()
.calculate_second_piola_kirchoff_tangent_stiffness(deformation_gradient)?)
}
}