diff --git a/element/src/element.rs b/element/src/element.rs index 464f1545..b3e7f99b 100644 --- a/element/src/element.rs +++ b/element/src/element.rs @@ -27,6 +27,7 @@ pub struct CiarletElement { } impl CiarletElement { + #[allow(clippy::too_many_arguments)] pub fn create( family: ElementFamily, cell_type: ReferenceCellType, @@ -68,13 +69,13 @@ impl CiarletElement { let mut new_x = [vec![], vec![], vec![], vec![]]; let mut pn = 0; let mut all_pts = Array2D::::new((npts, tdim)); - for i in 0..tdim { - for _pts in &x[i] { + for (i, xi) in x.iter().enumerate() { + for _pts in xi { new_x[i].push(Array2D::::new((0, tdim))); } } - for i in 0..tdim + 1 { - for pts in &x[i] { + for xi in x.iter() { + for pts in xi { for j in 0..pts.shape().0 { for k in 0..tdim { *all_pts.get_mut(pn + j, k).unwrap() = *pts.get(j, k).unwrap(); @@ -93,13 +94,13 @@ impl CiarletElement { let mut pn = 0; let mut dn = 0; let mut all_mat = Array3D::::new((dim, value_size, npts)); - for i in 0..tdim { - for _mat in &m[i] { + for (i, mi) in m.iter().enumerate() { + for _mat in mi { new_m[i].push(Array3D::::new((0, value_size, 0))); } } - for i in 0..tdim + 1 { - for mat in &m[i] { + for mi in m.iter() { + for mat in mi { for j in 0..mat.shape().0 { for k in 0..value_size { for l in 0..mat.shape().2 { diff --git a/element/src/element/lagrange.rs b/element/src/element/lagrange.rs index 9525074f..cd7eecf9 100644 --- a/element/src/element/lagrange.rs +++ b/element/src/element/lagrange.rs @@ -205,10 +205,7 @@ pub fn create_new( // TODO: GLL points for e in 0..cell.entity_count(0) { let mut pts = vec![0.0; tdim]; - let vertex = &cell.vertices()[e * tdim..(e + 1) * tdim]; - for i in 0..tdim { - pts[i] = vertex[i]; - } + pts.copy_from_slice(&cell.vertices()[e * tdim..(e + 1) * tdim]); x[0].push(Array2D::::from_data(pts, (1, tdim))); m[0].push(Array3D::::from_data(vec![1.0], (1, 1, 1))); } @@ -219,13 +216,11 @@ pub fn create_new( let vn1 = cell.edges()[2 * e + 1]; let v0 = &cell.vertices()[vn0 * tdim..(vn0 + 1) * tdim]; let v1 = &cell.vertices()[vn1 * tdim..(vn1 + 1) * tdim]; - let mut n = 0; for i in 1..degree { - ident[n * degree] = 1.0; + ident[(i - 1) * degree] = 1.0; for j in 0..tdim { - pts[n * tdim + j] = v0[j] + i as f64 / degree as f64 * (v1[j] - v0[j]); + pts[(i - 1) * tdim + j] = v0[j] + i as f64 / degree as f64 * (v1[j] - v0[j]); } - n += 1; } x[1].push(Array2D::::from_data(pts, (degree - 1, tdim))); m[1].push(Array3D::::from_data( diff --git a/traits/src/cell.rs b/traits/src/cell.rs index 408369f2..8594552a 100644 --- a/traits/src/cell.rs +++ b/traits/src/cell.rs @@ -43,8 +43,8 @@ pub trait ReferenceCell { for (i, v) in vertices.iter().enumerate() { m[i % dim] += v; } - for i in 0..dim { - m[i] /= (vertices.len() / dim) as f64; + for mi in m.iter_mut() { + *mi /= (vertices.len() / dim) as f64; } m }