Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Oct 25, 2023
1 parent da8775e commit 60ee344
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions grid/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl Geometry for SerialGeometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn Fn(usize, &mut TMut) + 'a> {
) -> GeomF<'a, TMut> {
let npts = points.shape().0;
let mut table = Array4D::<f64>::new(element.tabulate_array_shape(0, npts));
element.tabulate(points, 0, &mut table);
Expand Down Expand Up @@ -199,7 +199,7 @@ impl Geometry for SerialGeometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn FnMut(usize, &mut TMut) + 'a> {
) -> GeomFMut<'a, TMut> {
let mut data = Array4D::<f64>::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);
Expand Down Expand Up @@ -295,7 +295,7 @@ impl Geometry for SerialGeometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn Fn(usize, &mut TMut) + 'a> {
) -> GeomF<'a, TMut> {
let tdim = points.shape().1;
let mut data = Array4D::<f64>::new(element.tabulate_array_shape(1, points.shape().0)); // TODO: Memory is assigned here. Can we avoid this?
element.tabulate(points, 1, &mut data);
Expand Down Expand Up @@ -361,7 +361,7 @@ impl Geometry for SerialGeometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn FnMut(usize, &mut [f64]) + 'a> {
) -> GeomFMut<'a, [f64]> {
let gdim = self.dim();
let tdim = points.shape().1;
let mut js = zero_matrix((gdim * tdim, points.shape().0));
Expand Down
11 changes: 7 additions & 4 deletions traits/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub enum Ownership {
Ghost(usize, usize),
}

pub type GeomF<'a, T> = Box<dyn Fn(usize, &mut T) + 'a>;
pub type GeomFMut<'a, T> = Box<dyn FnMut(usize, &mut T) + 'a>;

pub trait Geometry {
//! Grid geometry
//!
Expand Down Expand Up @@ -44,7 +47,7 @@ pub trait Geometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn Fn(usize, &mut TMut) + 'a>;
) -> GeomF<'a, TMut>;

/// Compute the physical coordinates of a set of points in a given cell
fn compute_points<
Expand All @@ -66,7 +69,7 @@ pub trait Geometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn FnMut(usize, &mut TMut) + 'a>;
) -> GeomFMut<'a, TMut>;

/// Compute the normals to a set of points in a given cell
fn compute_normals<
Expand All @@ -90,7 +93,7 @@ pub trait Geometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn Fn(usize, &mut TMut) + 'a>;
) -> GeomF<'a, TMut>;

/// Evaluate the jacobian at a set of points in a given cell
///
Expand All @@ -112,7 +115,7 @@ pub trait Geometry {
&'a self,
element: &impl FiniteElement,
points: &'a T,
) -> Box<dyn FnMut(usize, &mut [f64]) + 'a>;
) -> GeomFMut<[f64]>;

/// Evaluate the determinand of the jacobian at a set of points in a given cell
///
Expand Down

0 comments on commit 60ee344

Please sign in to comment.