Skip to content

Commit 6745a82

Browse files
committed
Replace usage of discrete kernel
1 parent 3a72591 commit 6745a82

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

CHANGELOG.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
The following changes are present in the `main` branch of the repository and are not yet part of a release:
44

5-
- Py: Major refactor of the Python bindings, interface is simplified and more "pythonic"
6-
- Merged distinct F64/F32 classes and functions and infer data type automatically
7-
- Nearly all inputs and outputs are now zero-copy (e.g. mesh vertices and faces can be accessed as attributes without copies)
8-
- Py: Add a function for a plain marching cubes reconstruction without any SPH interpolation
9-
- Lib: Add support for "dense" density maps (borrowed & owned) as input for the marching cubes triangulation, useful for the Python bindings
5+
- Py: Major refactor of the Python bindings, interface is much simpler and more "pythonic"
6+
- Unified separate F64/F32 classes and functions and infer data type automatically
7+
- Nearly all inputs, outputs and attributes are now zero-copy (e.g. mesh vertices and faces can be accessed as attributes without copies)
8+
- Py: Add a function for a plain marching cubes reconstruction from a contiguous 3D array without any SPH interpolation
9+
- Lib: Add support for "dense" `DensityMap` (borrowed & owned) as input for the marching cubes triangulation, useful for the Python bindings
10+
- Lib: Replace usage of `DiscreteSquaredDistanceCubicKernel` by standard `CubicSplineKernel` for SPH interpolation (no noticeable performance difference)
1011
- Lib: Enforce that `Index` types are signed integers implementing the `num_traits::Signed` trait. Currently, the reconstruction does not work (correctly) with unsigned integers.
1112
- Lib: Make most fields of `SurfaceReconstruction` public
1213
- CLI: Add some tests for the `reconstruction_pipeline` function
1314
- CLI: Fix post-processing when particle AABB filtering is enabled
1415
- Lib: Support subdomain "ghost particle" margins to be up to the size of the subdomain itself (previously limited to half the size)
1516
- CLI/Lib: Option to automatically disable subdomain decomposition for very small grids
16-
- Lib: Support for non-owned data in `MeshAttribute`, avoids copies in CLI and Python package
17+
- Lib: Support for borrowed data in `MeshAttribute`, avoids copies in CLI and Python package
1718

1819
## Version 0.12.0
1920

splashsurf_lib/src/density_map.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! indices, even if the density map is only generated for a smaller subdomain.
2525
2626
use crate::aabb::Aabb3d;
27-
use crate::kernel::DiscreteSquaredDistanceCubicKernel;
27+
use crate::kernel::{CubicSplineKernel, SymmetricKernel3d};
2828
use crate::mesh::{HexMesh3d, MeshWithData, OwnedMeshAttribute};
2929
use crate::neighborhood_search::NeighborhoodList;
3030
use crate::uniform_grid::UniformGrid;
@@ -163,7 +163,7 @@ pub fn sequential_compute_particle_densities_filtered<
163163
init_density_storage(particle_densities, particle_positions.len());
164164

165165
// Pre-compute the kernel which can be queried using squared distances
166-
let kernel = DiscreteSquaredDistanceCubicKernel::new::<f64>(1000, compact_support_radius);
166+
let kernel = CubicSplineKernel::new(compact_support_radius);
167167

168168
for (i, particle_i_position) in particle_positions
169169
.iter()
@@ -176,8 +176,8 @@ pub fn sequential_compute_particle_densities_filtered<
176176
.iter()
177177
.map(|&j| &particle_positions[j])
178178
{
179-
let r_squared = (particle_j_position - particle_i_position).norm_squared();
180-
particle_i_density += kernel.evaluate(r_squared);
179+
let r = (particle_j_position - particle_i_position).norm();
180+
particle_i_density += kernel.evaluate(r);
181181
}
182182
particle_i_density *= particle_rest_mass;
183183
particle_densities[i] = particle_i_density;
@@ -198,7 +198,7 @@ pub fn parallel_compute_particle_densities<I: Index, R: Real>(
198198
init_density_storage(particle_densities, particle_positions.len());
199199

200200
// Pre-compute the kernel which can be queried using squared distances
201-
let kernel = DiscreteSquaredDistanceCubicKernel::new::<f64>(1000, compact_support_radius);
201+
let kernel = CubicSplineKernel::new(compact_support_radius);
202202

203203
particle_positions
204204
.par_iter()
@@ -211,8 +211,8 @@ pub fn parallel_compute_particle_densities<I: Index, R: Real>(
211211
for particle_j_position in
212212
particle_i_neighbors.iter().map(|&j| &particle_positions[j])
213213
{
214-
let r_squared = (particle_j_position - particle_i_position).norm_squared();
215-
density += kernel.evaluate(r_squared);
214+
let r = (particle_j_position - particle_i_position).norm();
215+
density += kernel.evaluate(r);
216216
}
217217
density *= particle_rest_mass;
218218
*particle_i_density = density;
@@ -534,7 +534,7 @@ struct SparseDensityMapGenerator<I: Index, R: Real> {
534534
half_supported_cells: I,
535535
supported_points: I,
536536
kernel_evaluation_radius_sq: R,
537-
kernel: DiscreteSquaredDistanceCubicKernel<R>,
537+
kernel: CubicSplineKernel<R>,
538538
allowed_domain: Aabb3d<R>,
539539
}
540540

@@ -594,7 +594,7 @@ impl<I: Index, R: Real> SparseDensityMapGenerator<I, R> {
594594

595595
// Pre-compute the kernel which can be queried using squared distances
596596
let kernel_evaluation_radius_sq = kernel_evaluation_radius * kernel_evaluation_radius;
597-
let kernel = DiscreteSquaredDistanceCubicKernel::new::<f64>(1000, compact_support_radius);
597+
let kernel = CubicSplineKernel::new(compact_support_radius);
598598

599599
// Shrink the allowed domain for particles by the kernel evaluation radius. This ensures that all cells/points
600600
// that are affected by a particle are actually part of the domain/grid, so it does not have to be checked in the loops below.
@@ -719,7 +719,7 @@ impl<I: Index, R: Real> SparseDensityMapGenerator<I, R> {
719719
let r_squared = dxdx + dydy + dzdz;
720720
if r_squared < self.kernel_evaluation_radius_sq {
721721
let density_contribution =
722-
particle_volume * self.kernel.evaluate(r_squared);
722+
particle_volume * self.kernel.evaluate(r_squared.sqrt());
723723

724724
let flat_point_index = grid.flatten_point_indices(i, j, k);
725725
*sparse_densities

0 commit comments

Comments
 (0)