use crate::{
constitutive::solid::hyperviscoelastic::Hyperviscoelastic,
fem::{
ElementModelError, NodalCoordinates,
block::{
Block, element::FiniteElementError,
element::solid::hyperviscoelastic::HyperviscoelasticFiniteElement,
},
solid::{
elastic_hyperviscous::ElasticHyperviscousElements,
hyperviscoelastic::HyperviscoelasticElements,
},
},
math::Quantity,
units::Energy,
};
impl<C, F, const G: usize, const M: usize, const N: usize, const P: usize>
HyperviscoelasticElements<3> for Block<C, F, G, M, N, P>
where
C: Hyperviscoelastic,
F: HyperviscoelasticFiniteElement<C, G, M, N, P>,
Self: ElasticHyperviscousElements<3>,
{
fn helmholtz_free_energy(
&self,
nodal_coordinates: &NodalCoordinates<3>,
) -> Result<Quantity<Energy>, ElementModelError> {
self.elements()
.iter()
.zip(self.connectivity())
.map(|(element, nodes)| {
element.helmholtz_free_energy(
self.constitutive_model(),
&Self::element_coordinates(nodal_coordinates, nodes),
)
})
.sum::<Result<_, FiniteElementError>>()
.map_err(|error| ElementModelError::upstream(error, self))
}
}