ndgrid/geometry/single_element/
entity_geometry.rs1use super::SingleElementGeometry;
3use crate::{
4 geometry::{Point, PointIter},
5 traits::Geometry,
6 types::Scalar,
7};
8use ndelement::traits::MappedFiniteElement;
9
10#[derive(Debug)]
12pub struct SingleElementEntityGeometry<'a, T: Scalar, E: MappedFiniteElement> {
13 geometry: &'a SingleElementGeometry<T, E>,
14 cell_index: usize,
15 sub_entity_dimension: usize,
16 sub_entity_index: usize,
17}
18
19impl<'a, T: Scalar, E: MappedFiniteElement> SingleElementEntityGeometry<'a, T, E> {
20 pub fn new(
22 geometry: &'a SingleElementGeometry<T, E>,
23 cell_index: usize,
24 sub_entity_dimension: usize,
25 sub_entity_index: usize,
26 ) -> Self {
27 Self {
28 geometry,
29 cell_index,
30 sub_entity_dimension,
31 sub_entity_index,
32 }
33 }
34}
35
36impl<T: Scalar, E: MappedFiniteElement> Geometry for SingleElementEntityGeometry<'_, T, E> {
37 type T = T;
38 type Point<'a>
39 = Point<'a, T>
40 where
41 Self: 'a;
42 type PointIter<'a>
43 = PointIter<'a, T>
44 where
45 Self: 'a;
46
47 fn points(&self) -> PointIter<'_, T> {
48 let gdim = self.geometry.dim();
49 let mut pts = vec![];
50 for index in self
51 .geometry
52 .element()
53 .entity_closure_dofs(self.sub_entity_dimension, self.sub_entity_index)
54 .unwrap()
55 {
56 let i = self.geometry.cells()[[*index, self.cell_index]];
57 pts.push((
58 i,
59 &self.geometry.points().data().unwrap()[i * gdim..(i + 1) * gdim],
60 ))
61 }
62
63 PointIter::new(pts)
64 }
65
66 fn point_count(&self) -> usize {
67 self.geometry.cells().shape()[0]
68 }
69
70 fn degree(&self) -> usize {
71 self.geometry.element().lagrange_superdegree()
72 }
73}