Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Aug 30, 2023
1 parent 6c1421d commit 7e4127b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
17 changes: 9 additions & 8 deletions element/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct CiarletElement {
}

impl CiarletElement {
#[allow(clippy::too_many_arguments)]
pub fn create(
family: ElementFamily,
cell_type: ReferenceCellType,
Expand Down Expand Up @@ -68,13 +69,13 @@ impl CiarletElement {
let mut new_x = [vec![], vec![], vec![], vec![]];
let mut pn = 0;
let mut all_pts = Array2D::<f64>::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::<f64>::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();
Expand All @@ -93,13 +94,13 @@ impl CiarletElement {
let mut pn = 0;
let mut dn = 0;
let mut all_mat = Array3D::<f64>::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::<f64>::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 {
Expand Down
11 changes: 3 additions & 8 deletions element/src/element/lagrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<f64>::from_data(pts, (1, tdim)));
m[0].push(Array3D::<f64>::from_data(vec![1.0], (1, 1, 1)));
}
Expand All @@ -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::<f64>::from_data(pts, (degree - 1, tdim)));
m[1].push(Array3D::<f64>::from_data(
Expand Down
4 changes: 2 additions & 2 deletions traits/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7e4127b

Please sign in to comment.