Skip to main content

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

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