conspire 0.6.0

The Rust interface to conspire.
Documentation
#[cfg(test)]
pub mod test;

use crate::{
    fem::block::element::{
        ElementNodalCoordinates, ElementNodalEitherCoordinates, ElementNodalReferenceCoordinates,
        FiniteElement, ParametricCoordinate, ParametricCoordinates, ParametricReference,
        ShapeFunctions, ShapeFunctionsGradients,
        cohesive::{
            CohesiveFiniteElement, M, Separations,
            linear::{LinearCohesiveElement, LinearCohesiveFiniteElement},
        },
        surface::linear::Triangle,
    },
    math::ScalarList,
    mechanics::NormalGradients,
};

// This should share integration_points() and parametric_weights() with Triangle<G=3> when get to it.

const G: usize = 3;
const N: usize = 6;
const P: usize = 3;

pub type Wedge = LinearCohesiveElement<G, N>;

impl FiniteElement<G, M, N, P> for Wedge {
    fn integration_points() -> ParametricCoordinates<G, M> {
        [
            [1.0 / 6.0, 1.0 / 6.0],
            [2.0 / 3.0, 1.0 / 6.0],
            [1.0 / 6.0, 2.0 / 3.0],
        ]
        .into()
    }
    fn integration_weights(&self) -> &ScalarList<G> {
        &self.integration_weights
    }
    fn parametric_reference() -> ParametricReference<M, N> {
        Triangle::parametric_reference()
            .into_iter()
            .chain(Triangle::parametric_reference())
            .collect()
    }
    fn parametric_weights() -> ScalarList<G> {
        [1.0 / 6.0; G].into()
    }
    fn scaled_jacobians<const I: usize>(
        nodal_coordinates: ElementNodalEitherCoordinates<I, N>,
    ) -> ScalarList<P> {
        Triangle::scaled_jacobians(Self::nodal_mid_surface(&nodal_coordinates))
    }
    fn shape_functions(parametric_coordinate: ParametricCoordinate<M>) -> ShapeFunctions<P> {
        Triangle::shape_functions(parametric_coordinate)
    }
    fn shape_functions_gradients(
        parametric_coordinate: ParametricCoordinate<M>,
    ) -> ShapeFunctionsGradients<M, P> {
        Triangle::shape_functions_gradients(parametric_coordinate)
    }
}

impl From<ElementNodalReferenceCoordinates<N>> for Wedge {
    fn from(reference_nodal_coordinates: ElementNodalReferenceCoordinates<N>) -> Self {
        Self::from_linear(reference_nodal_coordinates)
    }
}

impl CohesiveFiniteElement<G, N, P> for Wedge {
    fn nodal_mid_surface<const I: usize>(
        nodal_coordinates: &ElementNodalEitherCoordinates<I, N>,
    ) -> ElementNodalEitherCoordinates<I, P> {
        Self::nodal_mid_surface_linear(nodal_coordinates)
    }
    fn nodal_separations(nodal_coordinates: &ElementNodalCoordinates<N>) -> Separations<P> {
        Self::nodal_separations_linear(nodal_coordinates)
    }
    fn normal_gradients_full(
        nodal_mid_surface: &ElementNodalCoordinates<P>,
    ) -> NormalGradients<N, G> {
        Self::normal_gradients_full_linear(nodal_mid_surface)
    }
    fn signs() -> ScalarList<N> {
        Self::signs_linear()
    }
}

impl LinearCohesiveFiniteElement<G, N, P> for Wedge {}