ndgrid/traits/
geometry_map.rs

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