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

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