From f541c451cacceb7937cc3bebc5f9d622072288e5 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Tue, 25 Nov 2025 08:32:31 +0000 Subject: [PATCH 1/3] update for ndelement MappedFiniteElement trait --- src/geometry/geometry_map.rs | 8 +++- src/geometry/mixed/entity_geometry.rs | 8 ++-- src/geometry/mixed/geometry.rs | 8 ++-- .../single_element/entity_geometry.rs | 8 ++-- src/geometry/single_element/geometry.rs | 8 ++-- src/grid/local_grid/mixed/grid.rs | 42 ++++++++++++------- src/grid/local_grid/single_element/grid.rs | 37 +++++++++------- 7 files changed, 70 insertions(+), 49 deletions(-) diff --git a/src/geometry/geometry_map.rs b/src/geometry/geometry_map.rs index 06e66c7..25b4e43 100644 --- a/src/geometry/geometry_map.rs +++ b/src/geometry/geometry_map.rs @@ -1,6 +1,10 @@ //! Geometry map use crate::{traits::GeometryMap as GeometryMapTrait, types::RealScalar}; -use ndelement::{reference_cell, traits::FiniteElement, types::ReferenceCellType}; +use ndelement::{ + reference_cell, + traits::{FiniteElement, MappedFiniteElement}, + types::ReferenceCellType, +}; use rlst::{Array, DynArray, RlstScalar, ValueArrayImpl}; /// Single element geometry @@ -48,7 +52,7 @@ impl<'a, T: RealScalar, B2D: ValueArrayImpl, C2D: ValueArrayImpl { /// Create new pub fn new>( - element: &impl FiniteElement, + element: &(impl FiniteElement + MappedFiniteElement), points: &Array, geometry_points: &'a Array, entities: &'a Array, diff --git a/src/geometry/mixed/entity_geometry.rs b/src/geometry/mixed/entity_geometry.rs index a30c2a5..cd0e6ed 100644 --- a/src/geometry/mixed/entity_geometry.rs +++ b/src/geometry/mixed/entity_geometry.rs @@ -5,11 +5,11 @@ use crate::{ traits::Geometry, types::RealScalar, }; -use ndelement::traits::FiniteElement; +use ndelement::traits::MappedFiniteElement; /// Geometry of an entity #[derive(Debug)] -pub struct MixedEntityGeometry<'a, T: RealScalar, E: FiniteElement> { +pub struct MixedEntityGeometry<'a, T: RealScalar, E: MappedFiniteElement> { geometry: &'a MixedGeometry, element_index: usize, cell_index: usize, @@ -17,7 +17,7 @@ pub struct MixedEntityGeometry<'a, T: RealScalar, E: FiniteElement> { sub_entity_index: usize, } -impl<'a, T: RealScalar, E: FiniteElement> MixedEntityGeometry<'a, T, E> { +impl<'a, T: RealScalar, E: MappedFiniteElement> MixedEntityGeometry<'a, T, E> { /// Create new pub fn new( geometry: &'a MixedGeometry, @@ -36,7 +36,7 @@ impl<'a, T: RealScalar, E: FiniteElement> MixedEntityGeometry<'a, T, E> { } } -impl Geometry for MixedEntityGeometry<'_, T, E> { +impl Geometry for MixedEntityGeometry<'_, T, E> { type T = T; type Point<'a> = Point<'a, T> diff --git a/src/geometry/mixed/geometry.rs b/src/geometry/mixed/geometry.rs index 8a5ba30..d349ce9 100644 --- a/src/geometry/mixed/geometry.rs +++ b/src/geometry/mixed/geometry.rs @@ -11,7 +11,7 @@ use ndelement::{ }; use ndelement::{ reference_cell, - traits::{ElementFamily, FiniteElement}, + traits::{ElementFamily, MappedFiniteElement}, types::ReferenceCellType, }; use rlst::{DynArray, rlst_dynamic_array}; @@ -19,7 +19,7 @@ use std::collections::HashMap; use std::fmt::{Debug, Formatter}; /// Single element geometry -pub struct MixedGeometry { +pub struct MixedGeometry { points: DynArray, cells: Vec>, elements: Vec>, @@ -27,7 +27,7 @@ pub struct MixedGeometry { pub(crate) insertion_indices_to_cell_indices: Vec, } -impl Debug for MixedGeometry { +impl Debug for MixedGeometry { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { f.debug_struct("MixedGeometry") .field("points", &self.points) @@ -115,7 +115,7 @@ where } } -impl MixedGeometry { +impl MixedGeometry { /// Create single element geometry pub fn new( cell_types_in: &[ReferenceCellType], diff --git a/src/geometry/single_element/entity_geometry.rs b/src/geometry/single_element/entity_geometry.rs index 7fe6efa..4bcfca5 100644 --- a/src/geometry/single_element/entity_geometry.rs +++ b/src/geometry/single_element/entity_geometry.rs @@ -5,18 +5,18 @@ use crate::{ traits::Geometry, types::RealScalar, }; -use ndelement::traits::FiniteElement; +use ndelement::traits::MappedFiniteElement; /// Geometry of an entity #[derive(Debug)] -pub struct SingleElementEntityGeometry<'a, T: RealScalar, E: FiniteElement> { +pub struct SingleElementEntityGeometry<'a, T: RealScalar, E: MappedFiniteElement> { geometry: &'a SingleElementGeometry, cell_index: usize, sub_entity_dimension: usize, sub_entity_index: usize, } -impl<'a, T: RealScalar, E: FiniteElement> SingleElementEntityGeometry<'a, T, E> { +impl<'a, T: RealScalar, E: MappedFiniteElement> SingleElementEntityGeometry<'a, T, E> { /// Create new pub fn new( geometry: &'a SingleElementGeometry, @@ -33,7 +33,7 @@ impl<'a, T: RealScalar, E: FiniteElement> SingleElementEntityGeometry<'a, T, E> } } -impl Geometry for SingleElementEntityGeometry<'_, T, E> { +impl Geometry for SingleElementEntityGeometry<'_, T, E> { type T = T; type Point<'a> = Point<'a, T> diff --git a/src/geometry/single_element/geometry.rs b/src/geometry/single_element/geometry.rs index 29cc7e2..a627331 100644 --- a/src/geometry/single_element/geometry.rs +++ b/src/geometry/single_element/geometry.rs @@ -10,20 +10,20 @@ use ndelement::{ }; use ndelement::{ reference_cell, - traits::{ElementFamily, FiniteElement}, + traits::{ElementFamily, FiniteElement, MappedFiniteElement}, types::ReferenceCellType, }; use rlst::{DynArray, rlst_dynamic_array}; use std::fmt::{Debug, Formatter}; /// Single element geometry -pub struct SingleElementGeometry { +pub struct SingleElementGeometry { points: DynArray, cells: DynArray, elements: Vec, } -impl Debug for SingleElementGeometry { +impl Debug for SingleElementGeometry { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { f.debug_struct("SingleElementGeometry") .field("points", &self.points) @@ -85,7 +85,7 @@ where } } -impl SingleElementGeometry { +impl SingleElementGeometry { /// Create single element geometry pub fn new( cell_type: ReferenceCellType, diff --git a/src/grid/local_grid/mixed/grid.rs b/src/grid/local_grid/mixed/grid.rs index 3795a7a..dde180a 100644 --- a/src/grid/local_grid/mixed/grid.rs +++ b/src/grid/local_grid/mixed/grid.rs @@ -25,7 +25,7 @@ use ndelement::{ ciarlet::{CiarletElement, LagrangeElementFamily}, map::IdentityMap, reference_cell, - traits::{ElementFamily, FiniteElement}, + traits::{ElementFamily, FiniteElement, MappedFiniteElement}, types::{Continuity, ReferenceCellType}, }; use rlst::dense::{base_array::BaseArray, data_container::VectorContainer}; @@ -34,8 +34,11 @@ use std::collections::HashMap; /// Mixed grid entity #[derive(Debug)] -pub struct MixedGridEntity<'a, T: RealScalar, E: FiniteElement> -{ +pub struct MixedGridEntity< + 'a, + T: RealScalar, + E: FiniteElement + MappedFiniteElement, +> { grid: &'a MixedGrid, cell_type: ReferenceCellType, cell_index: usize, @@ -45,7 +48,7 @@ pub struct MixedGridEntity<'a, T: RealScalar, E: FiniteElement> +impl<'e, T: RealScalar, E: FiniteElement + MappedFiniteElement> MixedGridEntity<'e, T, E> { /// Create new @@ -69,8 +72,8 @@ impl<'e, T: RealScalar, E: FiniteElement> } } } -impl> Entity - for MixedGridEntity<'_, T, E> +impl + MappedFiniteElement> + Entity for MixedGridEntity<'_, T, E> { type T = T; type EntityDescriptor = ReferenceCellType; @@ -123,14 +126,14 @@ impl> Entit pub struct MixedGridEntityIter< 'a, T: RealScalar, - E: FiniteElement, + E: FiniteElement + MappedFiniteElement, > { grid: &'a MixedGrid, entity_type: ReferenceCellType, index: usize, } -impl<'a, T: RealScalar, E: FiniteElement> +impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> MixedGridEntityIter<'a, T, E> { /// Create new @@ -142,8 +145,8 @@ impl<'a, T: RealScalar, E: FiniteElement> } } } -impl<'a, T: RealScalar, E: FiniteElement> Iterator - for MixedGridEntityIter<'a, T, E> +impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> + Iterator for MixedGridEntityIter<'a, T, E> { type Item = MixedGridEntity<'a, T, E>; @@ -155,7 +158,10 @@ impl<'a, T: RealScalar, E: FiniteElement> I /// Serial mixed element grid #[derive(Debug)] -pub struct MixedGrid> { +pub struct MixedGrid< + T: RealScalar, + E: FiniteElement + MappedFiniteElement, +> { topology: MixedTopology, geometry: MixedGeometry, } @@ -190,7 +196,9 @@ impl ConvertToSerializable } } -impl> MixedGrid { +impl + MappedFiniteElement> + MixedGrid +{ /// Create new pub fn new(topology: MixedTopology, geometry: MixedGeometry) -> Self { Self { topology, geometry } @@ -249,8 +257,8 @@ impl MixedGrid> { } } -impl> Grid - for MixedGrid +impl + MappedFiniteElement> + Grid for MixedGrid { type T = T; type Entity<'a> @@ -358,8 +366,10 @@ impl> Grid } #[cfg(feature = "mpi")] -impl> - DistributableGrid for MixedGrid +impl< + T: RealScalar + Equivalence, + E: FiniteElement + MappedFiniteElement, +> DistributableGrid for MixedGrid { type ParallelGrid<'a, C: Communicator + 'a> = ParallelGridImpl<'a, C, MixedGrid>>; diff --git a/src/grid/local_grid/single_element/grid.rs b/src/grid/local_grid/single_element/grid.rs index 4cd1569..f87658e 100644 --- a/src/grid/local_grid/single_element/grid.rs +++ b/src/grid/local_grid/single_element/grid.rs @@ -24,7 +24,7 @@ use ndelement::{ ciarlet::{CiarletElement, LagrangeElementFamily}, map::IdentityMap, reference_cell, - traits::{ElementFamily, FiniteElement}, + traits::{ElementFamily, FiniteElement, MappedFiniteElement}, types::{Continuity, ReferenceCellType}, }; use rlst::dense::{base_array::BaseArray, data_container::VectorContainer}; @@ -35,7 +35,7 @@ use rlst::{SliceArray, rlst_dynamic_array}; pub struct SingleElementGridEntity< 'a, T: RealScalar, - E: FiniteElement, + E: FiniteElement + MappedFiniteElement, > { grid: &'a SingleElementGrid, cell_index: usize, @@ -43,7 +43,7 @@ pub struct SingleElementGridEntity< entity_index: usize, } -impl<'e, T: RealScalar, E: FiniteElement> +impl<'e, T: RealScalar, E: FiniteElement + MappedFiniteElement> SingleElementGridEntity<'e, T, E> { /// Create new @@ -61,8 +61,8 @@ impl<'e, T: RealScalar, E: FiniteElement> } } } -impl> Entity - for SingleElementGridEntity<'_, T, E> +impl + MappedFiniteElement> + Entity for SingleElementGridEntity<'_, T, E> { type T = T; type EntityDescriptor = ReferenceCellType; @@ -111,14 +111,14 @@ impl> Entit pub struct SingleElementGridEntityIter< 'a, T: RealScalar, - E: FiniteElement, + E: FiniteElement + MappedFiniteElement, > { grid: &'a SingleElementGrid, entity_type: ReferenceCellType, index: usize, } -impl<'a, T: RealScalar, E: FiniteElement> +impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> SingleElementGridEntityIter<'a, T, E> { /// Create new @@ -130,8 +130,8 @@ impl<'a, T: RealScalar, E: FiniteElement> } } } -impl<'a, T: RealScalar, E: FiniteElement> Iterator - for SingleElementGridEntityIter<'a, T, E> +impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> + Iterator for SingleElementGridEntityIter<'a, T, E> { type Item = SingleElementGridEntity<'a, T, E>; @@ -143,7 +143,10 @@ impl<'a, T: RealScalar, E: FiniteElement> I /// Serial single element grid #[derive(Debug)] -pub struct SingleElementGrid> { +pub struct SingleElementGrid< + T: RealScalar, + E: FiniteElement + MappedFiniteElement, +> { topology: SingleTypeTopology, geometry: SingleElementGeometry, } @@ -178,7 +181,9 @@ impl ConvertToSerializable } } -impl> SingleElementGrid { +impl + MappedFiniteElement> + SingleElementGrid +{ /// Create new pub fn new(topology: SingleTypeTopology, geometry: SingleElementGeometry) -> Self { Self { topology, geometry } @@ -221,8 +226,8 @@ impl SingleElementGrid> { } } -impl> Grid - for SingleElementGrid +impl + MappedFiniteElement> + Grid for SingleElementGrid { type T = T; type Entity<'a> @@ -320,8 +325,10 @@ impl> Grid } #[cfg(feature = "mpi")] -impl> - DistributableGrid for SingleElementGrid +impl< + T: RealScalar + Equivalence, + E: FiniteElement + MappedFiniteElement, +> DistributableGrid for SingleElementGrid { type ParallelGrid<'a, C: Communicator + 'a> = ParallelGridImpl<'a, C, SingleElementGrid>>; From f3cd8543e8e272e4d32ef9b6f717117f12617ba4 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Tue, 25 Nov 2025 08:37:07 +0000 Subject: [PATCH 2/3] simplify --- src/geometry/geometry_map.rs | 8 ++--- src/grid/local_grid/mixed/grid.rs | 35 +++++++++------------- src/grid/local_grid/single_element/grid.rs | 30 +++++++++---------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/src/geometry/geometry_map.rs b/src/geometry/geometry_map.rs index 25b4e43..7aa1f77 100644 --- a/src/geometry/geometry_map.rs +++ b/src/geometry/geometry_map.rs @@ -1,10 +1,6 @@ //! Geometry map use crate::{traits::GeometryMap as GeometryMapTrait, types::RealScalar}; -use ndelement::{ - reference_cell, - traits::{FiniteElement, MappedFiniteElement}, - types::ReferenceCellType, -}; +use ndelement::{reference_cell, traits::MappedFiniteElement, types::ReferenceCellType}; use rlst::{Array, DynArray, RlstScalar, ValueArrayImpl}; /// Single element geometry @@ -52,7 +48,7 @@ impl<'a, T: RealScalar, B2D: ValueArrayImpl, C2D: ValueArrayImpl { /// Create new pub fn new>( - element: &(impl FiniteElement + MappedFiniteElement), + element: &impl MappedFiniteElement, points: &Array, geometry_points: &'a Array, entities: &'a Array, diff --git a/src/grid/local_grid/mixed/grid.rs b/src/grid/local_grid/mixed/grid.rs index dde180a..793c294 100644 --- a/src/grid/local_grid/mixed/grid.rs +++ b/src/grid/local_grid/mixed/grid.rs @@ -37,7 +37,7 @@ use std::collections::HashMap; pub struct MixedGridEntity< 'a, T: RealScalar, - E: FiniteElement + MappedFiniteElement, + E: MappedFiniteElement, > { grid: &'a MixedGrid, cell_type: ReferenceCellType, @@ -48,7 +48,7 @@ pub struct MixedGridEntity< geometry_cell_index: usize, } -impl<'e, T: RealScalar, E: FiniteElement + MappedFiniteElement> +impl<'e, T: RealScalar, E: MappedFiniteElement> MixedGridEntity<'e, T, E> { /// Create new @@ -72,8 +72,8 @@ impl<'e, T: RealScalar, E: FiniteElement + } } } -impl + MappedFiniteElement> - Entity for MixedGridEntity<'_, T, E> +impl> Entity + for MixedGridEntity<'_, T, E> { type T = T; type EntityDescriptor = ReferenceCellType; @@ -126,14 +126,14 @@ impl + Mapp pub struct MixedGridEntityIter< 'a, T: RealScalar, - E: FiniteElement + MappedFiniteElement, + E: MappedFiniteElement, > { grid: &'a MixedGrid, entity_type: ReferenceCellType, index: usize, } -impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> +impl<'a, T: RealScalar, E: MappedFiniteElement> MixedGridEntityIter<'a, T, E> { /// Create new @@ -145,8 +145,8 @@ impl<'a, T: RealScalar, E: FiniteElement + } } } -impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> - Iterator for MixedGridEntityIter<'a, T, E> +impl<'a, T: RealScalar, E: MappedFiniteElement> Iterator + for MixedGridEntityIter<'a, T, E> { type Item = MixedGridEntity<'a, T, E>; @@ -158,10 +158,7 @@ impl<'a, T: RealScalar, E: FiniteElement + /// Serial mixed element grid #[derive(Debug)] -pub struct MixedGrid< - T: RealScalar, - E: FiniteElement + MappedFiniteElement, -> { +pub struct MixedGrid> { topology: MixedTopology, geometry: MixedGeometry, } @@ -196,9 +193,7 @@ impl ConvertToSerializable } } -impl + MappedFiniteElement> - MixedGrid -{ +impl> MixedGrid { /// Create new pub fn new(topology: MixedTopology, geometry: MixedGeometry) -> Self { Self { topology, geometry } @@ -257,8 +252,8 @@ impl MixedGrid> { } } -impl + MappedFiniteElement> - Grid for MixedGrid +impl> Grid + for MixedGrid { type T = T; type Entity<'a> @@ -366,10 +361,8 @@ impl + Mapp } #[cfg(feature = "mpi")] -impl< - T: RealScalar + Equivalence, - E: FiniteElement + MappedFiniteElement, -> DistributableGrid for MixedGrid +impl> + DistributableGrid for MixedGrid { type ParallelGrid<'a, C: Communicator + 'a> = ParallelGridImpl<'a, C, MixedGrid>>; diff --git a/src/grid/local_grid/single_element/grid.rs b/src/grid/local_grid/single_element/grid.rs index f87658e..bf9294b 100644 --- a/src/grid/local_grid/single_element/grid.rs +++ b/src/grid/local_grid/single_element/grid.rs @@ -35,7 +35,7 @@ use rlst::{SliceArray, rlst_dynamic_array}; pub struct SingleElementGridEntity< 'a, T: RealScalar, - E: FiniteElement + MappedFiniteElement, + E: MappedFiniteElement, > { grid: &'a SingleElementGrid, cell_index: usize, @@ -43,7 +43,7 @@ pub struct SingleElementGridEntity< entity_index: usize, } -impl<'e, T: RealScalar, E: FiniteElement + MappedFiniteElement> +impl<'e, T: RealScalar, E: MappedFiniteElement> SingleElementGridEntity<'e, T, E> { /// Create new @@ -61,8 +61,8 @@ impl<'e, T: RealScalar, E: FiniteElement + } } } -impl + MappedFiniteElement> - Entity for SingleElementGridEntity<'_, T, E> +impl> Entity + for SingleElementGridEntity<'_, T, E> { type T = T; type EntityDescriptor = ReferenceCellType; @@ -111,14 +111,14 @@ impl + Mapp pub struct SingleElementGridEntityIter< 'a, T: RealScalar, - E: FiniteElement + MappedFiniteElement, + E: MappedFiniteElement, > { grid: &'a SingleElementGrid, entity_type: ReferenceCellType, index: usize, } -impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> +impl<'a, T: RealScalar, E: MappedFiniteElement> SingleElementGridEntityIter<'a, T, E> { /// Create new @@ -130,8 +130,8 @@ impl<'a, T: RealScalar, E: FiniteElement + } } } -impl<'a, T: RealScalar, E: FiniteElement + MappedFiniteElement> - Iterator for SingleElementGridEntityIter<'a, T, E> +impl<'a, T: RealScalar, E: MappedFiniteElement> Iterator + for SingleElementGridEntityIter<'a, T, E> { type Item = SingleElementGridEntity<'a, T, E>; @@ -145,7 +145,7 @@ impl<'a, T: RealScalar, E: FiniteElement + #[derive(Debug)] pub struct SingleElementGrid< T: RealScalar, - E: FiniteElement + MappedFiniteElement, + E: MappedFiniteElement, > { topology: SingleTypeTopology, geometry: SingleElementGeometry, @@ -181,7 +181,7 @@ impl ConvertToSerializable } } -impl + MappedFiniteElement> +impl> SingleElementGrid { /// Create new @@ -226,8 +226,8 @@ impl SingleElementGrid> { } } -impl + MappedFiniteElement> - Grid for SingleElementGrid +impl> Grid + for SingleElementGrid { type T = T; type Entity<'a> @@ -325,10 +325,8 @@ impl + Mapp } #[cfg(feature = "mpi")] -impl< - T: RealScalar + Equivalence, - E: FiniteElement + MappedFiniteElement, -> DistributableGrid for SingleElementGrid +impl> + DistributableGrid for SingleElementGrid { type ParallelGrid<'a, C: Communicator + 'a> = ParallelGridImpl<'a, C, SingleElementGrid>>; From cca3b052e446e553694a3f184a360067df9dd313 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Tue, 25 Nov 2025 13:44:39 +0000 Subject: [PATCH 3/3] unused import --- src/geometry/single_element/geometry.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/geometry/single_element/geometry.rs b/src/geometry/single_element/geometry.rs index a627331..72c7ddf 100644 --- a/src/geometry/single_element/geometry.rs +++ b/src/geometry/single_element/geometry.rs @@ -6,11 +6,12 @@ use crate::types::RealScalar; use ndelement::{ ciarlet::{CiarletElement, lagrange}, map::IdentityMap, + traits::FiniteElement, types::Continuity, }; use ndelement::{ reference_cell, - traits::{ElementFamily, FiniteElement, MappedFiniteElement}, + traits::{ElementFamily, MappedFiniteElement}, types::ReferenceCellType, }; use rlst::{DynArray, rlst_dynamic_array};