Skip to main content

conspire/domain/fem/solid/hyperviscoelastic/
mod.rs

1use crate::{
2    fem::{
3        Blocks, ElementModelError, Model, NodalCoordinates,
4        solid::elastic_hyperviscous::ElasticHyperviscousElements,
5    },
6    math::Quantity,
7    units::Energy,
8};
9
10pub trait HyperviscoelasticElements<const D: usize>
11where
12    Self: ElasticHyperviscousElements<D>,
13{
14    fn helmholtz_free_energy(
15        &self,
16        nodal_coordinates: &NodalCoordinates<D>,
17    ) -> Result<Quantity<Energy>, ElementModelError>;
18}
19
20impl<B, const D: usize> HyperviscoelasticElements<D> for Model<B, D>
21where
22    B: HyperviscoelasticElements<D>,
23{
24    fn helmholtz_free_energy(
25        &self,
26        nodal_coordinates: &NodalCoordinates<D>,
27    ) -> Result<Quantity<Energy>, ElementModelError> {
28        self.blocks.helmholtz_free_energy(nodal_coordinates)
29    }
30}
31
32impl<B1, B2, const D: usize> HyperviscoelasticElements<D> for Blocks<B1, B2>
33where
34    B1: HyperviscoelasticElements<D>,
35    B2: HyperviscoelasticElements<D>,
36{
37    fn helmholtz_free_energy(
38        &self,
39        nodal_coordinates: &NodalCoordinates<D>,
40    ) -> Result<Quantity<Energy>, ElementModelError> {
41        Ok(self.0.helmholtz_free_energy(nodal_coordinates)?
42            + self.1.helmholtz_free_energy(nodal_coordinates)?)
43    }
44}