Skip to main content

conspire/domain/fem/block/element/linear/tetrahedron/
mod.rs

1#[cfg(test)]
2mod test;
3
4use crate::{
5    fem::block::element::{
6        FiniteElement, IntegrationWeights, ParametricCoordinate, ParametricCoordinates,
7        ParametricReference, ShapeFunctions, ShapeFunctionsGradients,
8        linear::{LinearElement, LinearFiniteElement, M},
9    },
10    math::ScalarList,
11    units::Volume,
12};
13
14const G: usize = 1;
15const N: usize = 4;
16const P: usize = N;
17
18pub type Tetrahedron = LinearElement<G, N>;
19
20impl FiniteElement<G, M, N, P> for Tetrahedron {
21    fn integration_points() -> ParametricCoordinates<G, M> {
22        [[0.25; M]].into()
23    }
24    fn integration_weights(&self) -> &IntegrationWeights<G, Volume> {
25        &self.integration_weights
26    }
27    fn parametric_reference() -> ParametricReference<M, N> {
28        [
29            [0.0, 0.0, 0.0],
30            [1.0, 0.0, 0.0],
31            [0.0, 1.0, 0.0],
32            [0.0, 0.0, 1.0],
33        ]
34        .into()
35    }
36    fn parametric_weights() -> ScalarList<G> {
37        [1.0 / 6.0; G].into()
38    }
39    fn shape_functions(parametric_coordinate: ParametricCoordinate<M>) -> ShapeFunctions<N> {
40        let [xi_1, xi_2, xi_3] = parametric_coordinate.into();
41        [1.0 - xi_1 - xi_2 - xi_3, xi_1, xi_2, xi_3].into()
42    }
43    fn shape_functions_gradients(
44        _parametric_coordinate: ParametricCoordinate<M>,
45    ) -> ShapeFunctionsGradients<M, N> {
46        [
47            [-1.0, -1.0, -1.0],
48            [1.0, 0.0, 0.0],
49            [0.0, 1.0, 0.0],
50            [0.0, 0.0, 1.0],
51        ]
52        .into()
53    }
54}
55
56impl LinearFiniteElement<G, N> for Tetrahedron {}