diff --git a/grid/src/grid.rs b/grid/src/grid.rs index 6c99d5b4..a780c122 100644 --- a/grid/src/grid.rs +++ b/grid/src/grid.rs @@ -5,7 +5,7 @@ use bempp_tools::arrays::{zero_matrix, AdjacencyList, Array4D, Mat}; use bempp_traits::arrays::{AdjacencyListAccess, Array4DAccess}; use bempp_traits::cell::{ReferenceCell, ReferenceCellType}; use bempp_traits::element::{Continuity, ElementFamily, FiniteElement}; -use bempp_traits::grid::{Geometry, Grid, Ownership, Topology}; +use bempp_traits::grid::{Geometry, Grid, Ownership, Topology, GeomF, GeomFMut}; use itertools::izip; use rlst_dense::{ rlst_static_mat, RandomAccessByRef, RandomAccessMut, RawAccess, Shape, SizeIdentifier, @@ -134,7 +134,7 @@ impl Geometry for SerialGeometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box { + ) -> GeomF<'a, TMut> { let npts = points.shape().0; let mut table = Array4D::::new(element.tabulate_array_shape(0, npts)); element.tabulate(points, 0, &mut table); @@ -199,7 +199,7 @@ impl Geometry for SerialGeometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box { + ) -> GeomFMut<'a, TMut> { let mut data = Array4D::::new(element.tabulate_array_shape(1, points.shape().0)); // TODO: Memory is assigned here. Can we avoid this? let mut axes = rlst_static_mat![f64, TwoByThree]; element.tabulate(points, 1, &mut data); @@ -295,7 +295,7 @@ impl Geometry for SerialGeometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box { + ) -> GeomF<'a, TMut> { let tdim = points.shape().1; let mut data = Array4D::::new(element.tabulate_array_shape(1, points.shape().0)); // TODO: Memory is assigned here. Can we avoid this? element.tabulate(points, 1, &mut data); @@ -361,7 +361,7 @@ impl Geometry for SerialGeometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box { + ) -> GeomFMut<'a, [f64]> { let gdim = self.dim(); let tdim = points.shape().1; let mut js = zero_matrix((gdim * tdim, points.shape().0)); diff --git a/traits/src/grid.rs b/traits/src/grid.rs index c23009cb..f9c39fe5 100644 --- a/traits/src/grid.rs +++ b/traits/src/grid.rs @@ -12,6 +12,9 @@ pub enum Ownership { Ghost(usize, usize), } +pub type GeomF<'a, T> = Box; +pub type GeomFMut<'a, T> = Box; + pub trait Geometry { //! Grid geometry //! @@ -44,7 +47,7 @@ pub trait Geometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box; + ) -> GeomF<'a, TMut>; /// Compute the physical coordinates of a set of points in a given cell fn compute_points< @@ -66,7 +69,7 @@ pub trait Geometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box; + ) -> GeomFMut<'a, TMut>; /// Compute the normals to a set of points in a given cell fn compute_normals< @@ -90,7 +93,7 @@ pub trait Geometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box; + ) -> GeomF<'a, TMut>; /// Evaluate the jacobian at a set of points in a given cell /// @@ -112,7 +115,7 @@ pub trait Geometry { &'a self, element: &impl FiniteElement, points: &'a T, - ) -> Box; + ) -> GeomFMut<[f64]>; /// Evaluate the determinand of the jacobian at a set of points in a given cell ///