ndgrid/traits/
geometry_map.rs

1//! Map from reference to physical space.
2
3use crate::types::Scalar;
4use rlst::{Array, MutableArrayImpl};
5
6/// A geometry map allows the computation of maps from reference to physical space and their derivatives.
7///
8/// A geometry map is typically initialised with a number of points on a reference entity.
9/// We can then for each physical entity compute
10/// - The associated physical points as maps from the reference points.
11/// - The jacobian of the map at the physical points.
12/// - The jacobians, transformation determinants and the normals of the physical entity.
13pub trait GeometryMap {
14    /// Scalar type
15    type T: Scalar;
16
17    /// The topoloical dimension of the entity being mapped.
18    ///
19    /// The topological dimension is e.g. two for a triangle, independent
20    /// of whether it is embedded in two or three dimensional space.
21    fn entity_topology_dimension(&self) -> usize;
22
23    /// The geometric dimension of the physical space.
24    fn geometry_dimension(&self) -> usize;
25
26    /// The number of reference points that this map uses.
27    fn point_count(&self) -> usize;
28
29    /// Write the physical points for the entity with index `entity_index` into `points`
30    ///
31    /// `points` should have shape [geometry_dimension, npts] and use column-major ordering.
32    fn physical_points<Array2Impl: MutableArrayImpl<Self::T, 2>>(
33        &self,
34        entity_index: usize,
35        points: &mut Array<Array2Impl, 2>,
36    );
37
38    /// Write the jacobians at the physical points for the entity with index `entity_index` into `jacobians`
39    ///
40    /// `jacobians` should have shape [geometry_dimension, entity_topology_dimension, npts] and use column-major ordering
41    fn jacobians<Array3MutImpl: MutableArrayImpl<Self::T, 3>>(
42        &self,
43        entity_index: usize,
44        jacobians: &mut Array<Array3MutImpl, 3>,
45    );
46
47    /// Write the jacobians, their inverses and their determinants for the entity with
48    /// index `entity_index` into `jacobians`, `inverse_jacobians` and `jdets`.
49    ///
50    /// `jacobians` should have shape [geometry_dimension, entity_topology_dimension, npts] and use column-major ordering;
51    /// `inverse_jacobians` should have shape [entity_topology_dimension, geometry_dimension, npts] and use column-major ordering;
52    /// `jdets` should have shape \[npts\];
53    fn jacobians_inverses_dets<Array3MutImpl: MutableArrayImpl<Self::T, 3>>(
54        &self,
55        entity_index: usize,
56        jacobians: &mut Array<Array3MutImpl, 3>,
57        inverse_jacobians: &mut Array<Array3MutImpl, 3>,
58        jdets: &mut [Self::T],
59    );
60
61    /// Write the jacobians, their inverses, their determinants, and the normals at the physical points for the entity with
62    /// index `entity_index` into `jacobians`, `inverse_jacobians`, `jdets` and `normals`.
63    ///
64    /// `jacobians` should have shape [geometry_dimension, entity_topology_dimension, npts] and use column-major ordering;
65    /// `inverse_jacobians` should have shape [entity_topology_dimension, geometry_dimension, npts] and use column-major ordering;
66    /// `jdets` should have shape \[npts\];
67    /// `normals` should have shape [geometry_dimension, npts] and use column-major ordering
68    fn jacobians_inverses_dets_normals<
69        Array2Impl: MutableArrayImpl<Self::T, 2>,
70        Array3MutImpl: MutableArrayImpl<Self::T, 3>,
71    >(
72        &self,
73        entity_index: usize,
74        jacobians: &mut Array<Array3MutImpl, 3>,
75        inverse_jacobians: &mut Array<Array3MutImpl, 3>,
76        jdets: &mut [Self::T],
77        normals: &mut Array<Array2Impl, 2>,
78    );
79}