Skip to main content

conspire/domain/fem/block/element/surface/linear/triangle/
mod.rs

1#[cfg(test)]
2pub mod test;
3
4use crate::{
5    fem::block::element::{
6        FiniteElement, IntegrationWeights, ParametricCoordinate, ParametricCoordinates,
7        ParametricReference, ShapeFunctions, ShapeFunctionsGradients,
8        surface::{M, linear::LinearSurfaceElement},
9    },
10    math::ScalarList,
11    units::Volume,
12};
13
14// When implement G=3, share the methods with cohesive linear wedge.
15
16const G: usize = 1;
17const N: usize = 3;
18const P: usize = N;
19
20pub type Triangle = LinearSurfaceElement<G, N>;
21
22impl FiniteElement<G, M, N, P> for Triangle {
23    fn integration_points() -> ParametricCoordinates<G, M> {
24        [[1.0 / 3.0; M]].into()
25    }
26    fn integration_weights(&self) -> &IntegrationWeights<G, Volume> {
27        &self.integration_weights
28    }
29    fn parametric_reference() -> ParametricReference<M, N> {
30        [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]].into()
31    }
32    fn parametric_weights() -> ScalarList<G> {
33        [1.0 / 2.0; G].into()
34    }
35    fn shape_functions(parametric_coordinate: ParametricCoordinate<M>) -> ShapeFunctions<N> {
36        let [xi_1, xi_2] = parametric_coordinate.into();
37        [1.0 - xi_1 - xi_2, xi_1, xi_2].into()
38    }
39    fn shape_functions_gradients(
40        _parametric_coordinate: ParametricCoordinate<M>,
41    ) -> ShapeFunctionsGradients<M, N> {
42        [[-1.0, -1.0], [1.0, 0.0], [0.0, 1.0]].into()
43    }
44}