Skip to content

Commit e847828

Browse files
committed
cargo fmt
1 parent 41fb885 commit e847828

File tree

4 files changed

+59
-51
lines changed

4 files changed

+59
-51
lines changed

pysplashsurf/src/sph_interpolation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
use crate::utils::*;
12
use numpy as np;
23
use numpy::prelude::*;
34
use numpy::{Element, PyArray1, PyArray2, PyUntypedArray};
45
use pyo3::PyResult;
56
use pyo3::exceptions::PyValueError;
67
use pyo3::prelude::*;
78
use pyo3_stub_gen::derive::*;
9+
use splashsurf_lib::kernel::KernelType;
810
use splashsurf_lib::nalgebra::SVector;
911
use splashsurf_lib::{
1012
Real,
1113
nalgebra::{Unit, Vector3},
1214
sph_interpolation::SphInterpolator,
1315
};
14-
use splashsurf_lib::kernel::KernelType;
15-
use crate::utils::*;
1616

1717
enum PySphInterpolatorWrapper {
1818
F32(SphInterpolator<f32>),
@@ -55,7 +55,7 @@ impl PySphInterpolator {
5555
densities,
5656
R::from_float(particle_rest_mass),
5757
R::from_float(compact_support_radius),
58-
KernelType::CubicSpline
58+
KernelType::CubicSpline,
5959
)))
6060
} else {
6161
Err(pyerr_scalar_type_mismatch())

splashsurf/src/reconstruct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ pub fn reconstruction_pipeline<'a, I: Index, R: Real>(
11531153
particle_densities,
11541154
particle_rest_mass,
11551155
params.compact_support_radius,
1156-
params.kernel_type
1156+
params.kernel_type,
11571157
))
11581158
} else {
11591159
None

splashsurf_lib/src/dense_subdomains.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ use std::sync::atomic::{AtomicUsize, Ordering};
1616
use thread_local::ThreadLocal;
1717

1818
use crate::density_map::sequential_compute_particle_densities_filtered;
19-
use crate::kernel::{CubicSplineKernel, KernelType, Poly6Kernel, SpikyKernel, SymmetricKernel3d, WendlandQuinticC2Kernel};
19+
use crate::kernel::{
20+
CubicSplineKernel, KernelType, Poly6Kernel, SpikyKernel, SymmetricKernel3d,
21+
WendlandQuinticC2Kernel,
22+
};
2023
use crate::marching_cubes::marching_cubes_lut::marching_cubes_triangulation_iter;
2124
use crate::mesh::{HexMesh3d, TriMesh3d};
2225
use crate::neighborhood_search::{
@@ -726,7 +729,7 @@ pub fn density_grid_loop_auto(
726729
squared_support_with_margin: f32,
727730
particle_rest_mass: f32,
728731
kernel_support: f32,
729-
kernel_type: &KernelType
732+
kernel_type: &KernelType,
730733
) {
731734
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
732735
{
@@ -787,7 +790,7 @@ pub fn density_grid_loop_auto(
787790
particle_rest_mass,
788791
&CubicSplineKernel::new(kernel_support),
789792
);
790-
},
793+
}
791794
KernelType::Poly6 => {
792795
density_grid_loop_scalar::<i64, f32, Poly6Kernel<f32>>(
793796
levelset_grid,
@@ -801,7 +804,7 @@ pub fn density_grid_loop_auto(
801804
particle_rest_mass,
802805
&Poly6Kernel::new(kernel_support),
803806
);
804-
},
807+
}
805808
KernelType::Spiky => {
806809
density_grid_loop_scalar::<i64, f32, SpikyKernel<f32>>(
807810
levelset_grid,
@@ -815,7 +818,7 @@ pub fn density_grid_loop_auto(
815818
particle_rest_mass,
816819
&SpikyKernel::new(kernel_support),
817820
);
818-
},
821+
}
819822
KernelType::WendlandQuinticC2 => {
820823
density_grid_loop_scalar::<i64, f32, WendlandQuinticC2Kernel<f32>>(
821824
levelset_grid,
@@ -829,9 +832,8 @@ pub fn density_grid_loop_auto(
829832
particle_rest_mass,
830833
&WendlandQuinticC2Kernel::new(kernel_support),
831834
);
832-
},
835+
}
833836
}
834-
835837
}
836838

837839
pub fn density_grid_loop_scalar<I: Index, R: Real, K: SymmetricKernel3d<R>>(
@@ -914,8 +916,8 @@ pub fn density_grid_loop_neon(
914916
kernel_support: f32,
915917
kernel_type: &KernelType,
916918
) {
917-
use core::arch::aarch64::*;
918919
use crate::kernel::NeonKernel;
920+
use core::arch::aarch64::*;
919921
const LANES: usize = 4;
920922

921923
// Ensure that we can safely compute global MC vertex positions via u32 indices per dimension
@@ -1053,8 +1055,8 @@ pub fn density_grid_loop_neon(
10531055
}
10541056
}
10551057
}
1056-
1057-
match kernel_type {
1058+
1059+
match kernel_type {
10581060
KernelType::CubicSpline => {
10591061
density_grid_loop::<kernel::CubicSplineKernelNeonF32>(
10601062
levelset_grid,
@@ -1068,7 +1070,7 @@ pub fn density_grid_loop_neon(
10681070
particle_rest_mass,
10691071
kernel_support,
10701072
);
1071-
},
1073+
}
10721074
KernelType::Poly6 => {
10731075
density_grid_loop::<kernel::Poly6KernelNeonF32>(
10741076
levelset_grid,
@@ -1082,7 +1084,7 @@ pub fn density_grid_loop_neon(
10821084
particle_rest_mass,
10831085
kernel_support,
10841086
);
1085-
},
1087+
}
10861088
KernelType::Spiky => {
10871089
density_grid_loop::<kernel::SpikyKernelNeonF32>(
10881090
levelset_grid,
@@ -1096,7 +1098,7 @@ pub fn density_grid_loop_neon(
10961098
particle_rest_mass,
10971099
kernel_support,
10981100
);
1099-
},
1101+
}
11001102
KernelType::WendlandQuinticC2 => {
11011103
density_grid_loop::<kernel::WendlandQuinticC2KernelNeonF32>(
11021104
levelset_grid,
@@ -1110,7 +1112,7 @@ pub fn density_grid_loop_neon(
11101112
particle_rest_mass,
11111113
kernel_support,
11121114
);
1113-
},
1115+
}
11141116
}
11151117
}
11161118

@@ -1133,7 +1135,7 @@ pub fn density_grid_loop_avx(
11331135
use core::arch::x86::*;
11341136
#[cfg(target_arch = "x86_64")]
11351137
use core::arch::x86_64::*;
1136-
1138+
11371139
use crate::kernel::AvxKernel;
11381140

11391141
const LANES: usize = 8;
@@ -1252,7 +1254,8 @@ pub fn density_grid_loop_avx(
12521254
let w_ij = evaluate_contribution(k, grid_xs, grid_ys);
12531255

12541256
unsafe {
1255-
let prev_val = _mm256_loadu_ps(levelset_grid.as_ptr().add(flat_point_idx));
1257+
let prev_val =
1258+
_mm256_loadu_ps(levelset_grid.as_ptr().add(flat_point_idx));
12561259
let val = _mm256_fmadd_ps(w_ij, v_i_ps, prev_val);
12571260
_mm256_storeu_ps(levelset_grid.as_mut_ptr().add(flat_point_idx), val);
12581261
}
@@ -1290,7 +1293,7 @@ pub fn density_grid_loop_avx(
12901293
particle_rest_mass,
12911294
kernel_support,
12921295
);
1293-
},
1296+
}
12941297
KernelType::Poly6 => {
12951298
density_grid_loop::<kernel::Poly6KernelAvxF32>(
12961299
levelset_grid,
@@ -1304,7 +1307,7 @@ pub fn density_grid_loop_avx(
13041307
particle_rest_mass,
13051308
kernel_support,
13061309
);
1307-
},
1310+
}
13081311
KernelType::Spiky => {
13091312
density_grid_loop::<kernel::SpikyKernelAvxF32>(
13101313
levelset_grid,
@@ -1318,7 +1321,7 @@ pub fn density_grid_loop_avx(
13181321
particle_rest_mass,
13191322
kernel_support,
13201323
);
1321-
},
1324+
}
13221325
KernelType::WendlandQuinticC2 => {
13231326
density_grid_loop::<kernel::WendlandQuinticC2KernelAvxF32>(
13241327
levelset_grid,
@@ -1332,7 +1335,7 @@ pub fn density_grid_loop_avx(
13321335
particle_rest_mass,
13331336
kernel_support,
13341337
);
1335-
},
1338+
}
13361339
}
13371340
}
13381341

splashsurf_lib/src/sph_interpolation.rs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
//! Functions for interpolating quantities (e.g. normals, scalar fields) by evaluating SPH sums
22
33
use crate::Real;
4-
use crate::kernel::{CubicSplineKernel, KernelType, Poly6Kernel, SpikyKernel, SymmetricKernel3d, WendlandQuinticC2Kernel};
5-
use crate::profile;
64
use crate::ThreadSafe;
5+
use crate::kernel::{
6+
CubicSplineKernel, KernelType, Poly6Kernel, SpikyKernel, SymmetricKernel3d,
7+
WendlandQuinticC2Kernel,
8+
};
9+
use crate::profile;
710
use nalgebra::{SVector, Unit, Vector3};
811
use rayon::prelude::*;
912
use rstar::RTree;
@@ -63,7 +66,7 @@ impl<R: Real> SphInterpolator<R> {
6366
particle_densities: &[R],
6467
particle_rest_mass: R,
6568
compact_support_radius: R,
66-
kernel_type: KernelType
69+
kernel_type: KernelType,
6770
) -> Self {
6871
assert_eq!(particle_positions.len(), particle_densities.len());
6972

@@ -137,21 +140,16 @@ impl<R: Real> SphInterpolator<R> {
137140
interpolation_points,
138141
normals,
139142
),
140-
KernelType::Poly6 => interpolate_normals_helper::<R, Poly6Kernel<R>>(
141-
self,
142-
interpolation_points,
143-
normals,
144-
),
145-
KernelType::Spiky => interpolate_normals_helper::<R, SpikyKernel<R>>(
146-
self,
147-
interpolation_points,
148-
normals,
149-
),
150-
KernelType::WendlandQuinticC2 => interpolate_normals_helper::<R, WendlandQuinticC2Kernel<R>>(
151-
self,
152-
interpolation_points,
153-
normals,
154-
),
143+
KernelType::Poly6 => {
144+
interpolate_normals_helper::<R, Poly6Kernel<R>>(self, interpolation_points, normals)
145+
}
146+
KernelType::Spiky => {
147+
interpolate_normals_helper::<R, SpikyKernel<R>>(self, interpolation_points, normals)
148+
}
149+
KernelType::WendlandQuinticC2 => interpolate_normals_helper::<
150+
R,
151+
WendlandQuinticC2Kernel<R>,
152+
>(self, interpolation_points, normals),
155153
}
156154
}
157155

@@ -245,7 +243,11 @@ impl<R: Real> SphInterpolator<R> {
245243
profile!("interpolate_quantity_inplace");
246244
assert_eq!(particle_quantity.len(), self.tree.size());
247245

248-
fn interpolate_quantity_helper<R: Real, T: InterpolationQuantity<R>, K: SymmetricKernel3d<R> + Sync>(
246+
fn interpolate_quantity_helper<
247+
R: Real,
248+
T: InterpolationQuantity<R>,
249+
K: SymmetricKernel3d<R> + Sync,
250+
>(
249251
sph: &SphInterpolator<R>,
250252
particle_quantity: &[T],
251253
interpolation_points: &[Vector3<R>],
@@ -283,7 +285,8 @@ impl<R: Real> SphInterpolator<R> {
283285
let r = dx.norm();
284286

285287
// Unchecked access is fine as we asserted before that the slice has the correct length
286-
let A_j = unsafe { particle_quantity.get_unchecked(p_j.data.index).clone() };
288+
let A_j =
289+
unsafe { particle_quantity.get_unchecked(p_j.data.index).clone() };
287290
let W_ij = kernel.evaluate(r);
288291

289292
interpolated_value += A_j.scale(vol_j * W_ij);
@@ -319,13 +322,15 @@ impl<R: Real> SphInterpolator<R> {
319322
interpolated_values,
320323
first_order_correction,
321324
),
322-
KernelType::WendlandQuinticC2 => interpolate_quantity_helper::<R, T, WendlandQuinticC2Kernel<R>>(
323-
self,
324-
particle_quantity,
325-
interpolation_points,
326-
interpolated_values,
327-
first_order_correction,
328-
),
325+
KernelType::WendlandQuinticC2 => {
326+
interpolate_quantity_helper::<R, T, WendlandQuinticC2Kernel<R>>(
327+
self,
328+
particle_quantity,
329+
interpolation_points,
330+
interpolated_values,
331+
first_order_correction,
332+
)
333+
}
329334
}
330335
}
331336
}

0 commit comments

Comments
 (0)