Skip to content

Commit

Permalink
Add new subdomain grid based dense reconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
w1th0utnam3 committed Jul 5, 2023
1 parent def7684 commit 60e7343
Show file tree
Hide file tree
Showing 14 changed files with 1,789 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions splashsurf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "splashsurf"
version = "0.9.3"
version = "0.10.0"
authors = ["Fabian Löschner <[email protected]>"]
license = "MIT"
description = "Command-line tool for surface reconstruction of SPH particle data"
Expand All @@ -13,7 +13,7 @@ homepage = "http://splashsurf.physics-simulation.org"
repository = "https://github.com/InteractiveComputerGraphics/splashsurf"

[dependencies]
splashsurf_lib = { path = "../splashsurf_lib", version = "0.9.2", features = ["vtk_extras", "profiling", "io"] }
splashsurf_lib = { path = "../splashsurf_lib", version = "0.10.0", features = ["vtk_extras", "profiling", "io"] }
clap = { version = "4.3", features = ["derive"] }
log = "0.4"
fern = "0.6"
Expand Down
20 changes: 20 additions & 0 deletions splashsurf/src/reconstruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ pub struct ReconstructSubcommandArgs {
#[arg(help_heading = ARGS_ADV, long, short = 'n')]
pub num_threads: Option<usize>,

/// Whether to enable spatial decomposition using a regular grid-based approach
#[arg(
help_heading = ARGS_OCTREE,
long,
default_value = "off",
value_name = "off|on",
ignore_case = true,
require_equals = true
)]
pub subdomain_grid: Switch,
/// Each subdomain will be a cube consisting of this number of MC cube cells along each coordinate axis
#[arg(help_heading = ARGS_OCTREE, long, default_value="64")]
pub subdomain_cubes: u32,

/// Whether to enable spatial decomposition using an octree (faster) instead of a global approach
#[arg(
help_heading = ARGS_OCTREE,
Expand Down Expand Up @@ -229,6 +243,8 @@ impl Switch {

/// Executes the `reconstruct` subcommand
pub fn reconstruct_subcommand(cmd_args: &ReconstructSubcommandArgs) -> Result<(), anyhow::Error> {
profile!("reconstruct CLI");

let paths = ReconstructionRunnerPathCollection::try_from(cmd_args)
.context("Failed parsing input file path(s) from command line")?
.collect();
Expand Down Expand Up @@ -388,6 +404,10 @@ mod arguments {
cube_size,
iso_surface_threshold: args.surface_threshold,
domain_aabb,
subdomain_num_cubes_per_dim: args
.subdomain_grid
.into_bool()
.then_some(args.subdomain_cubes),
enable_multi_threading: args.parallelize_over_particles.into_bool(),
spatial_decomposition,
};
Expand Down
2 changes: 1 addition & 1 deletion splashsurf_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "splashsurf_lib"
version = "0.9.2"
version = "0.10.0"
authors = ["Fabian Löschner <[email protected]>"]
license = "MIT"
description = "Library for surface reconstruction of SPH particle data"
Expand Down
45 changes: 41 additions & 4 deletions splashsurf_lib/benches/benches/bench_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn surface_reconstruction_canyon(c: &mut Criterion) {
let parameters = Parameters {
particle_radius,
rest_density: 1000.0,
compact_support_radius: compact_support_radius,
compact_support_radius,
cube_size,
iso_surface_threshold: 0.6,
domain_aabb: None,
Expand Down Expand Up @@ -98,11 +98,12 @@ pub fn surface_reconstruction_dam_break(c: &mut Criterion) {
let parameters = Parameters {
particle_radius,
rest_density: 1000.0,
compact_support_radius: compact_support_radius,
compact_support_radius,
cube_size,
iso_surface_threshold: 0.6,
domain_aabb: None,
enable_multi_threading: true,
subdomain_num_cubes_per_dim: None,
spatial_decomposition: None,
};

Expand Down Expand Up @@ -156,6 +157,15 @@ pub fn surface_reconstruction_dam_break(c: &mut Criterion) {
},
);

group.bench_function("surface_reconstruction_dam_break_par_grid_64", |b| {
b.iter(|| {
let mut parameters = parameters.clone();
parameters.subdomain_num_cubes_per_dim = Some(64);
reconstruction =
reconstruct_surface::<i64, _>(particle_positions.as_slice(), &parameters).unwrap()
})
});

group.finish();

/*
Expand All @@ -179,11 +189,12 @@ pub fn surface_reconstruction_double_dam_break(c: &mut Criterion) {
let parameters = Parameters {
particle_radius,
rest_density: 1000.0,
compact_support_radius: compact_support_radius,
compact_support_radius,
cube_size,
iso_surface_threshold: 0.6,
domain_aabb: None,
enable_multi_threading: true,
subdomain_num_cubes_per_dim: None,
spatial_decomposition: None,
};

Expand Down Expand Up @@ -237,6 +248,15 @@ pub fn surface_reconstruction_double_dam_break(c: &mut Criterion) {
},
);

group.bench_function("surface_reconstruction_double_dam_break_par_grid_64", |b| {
b.iter(|| {
let mut parameters = parameters.clone();
parameters.subdomain_num_cubes_per_dim = Some(64);
reconstruction =
reconstruct_surface::<i64, _>(particle_positions.as_slice(), &parameters).unwrap()
})
});

group.finish();

/*
Expand All @@ -260,11 +280,12 @@ pub fn surface_reconstruction_double_dam_break_inplace(c: &mut Criterion) {
let parameters = Parameters {
particle_radius,
rest_density: 1000.0,
compact_support_radius: compact_support_radius,
compact_support_radius,
cube_size,
iso_surface_threshold: 0.6,
domain_aabb: None,
enable_multi_threading: true,
subdomain_num_cubes_per_dim: None,
spatial_decomposition: None,
};

Expand Down Expand Up @@ -335,6 +356,22 @@ pub fn surface_reconstruction_double_dam_break_inplace(c: &mut Criterion) {
},
);

group.bench_function(
"surface_reconstruction_double_dam_break_inplace_par_grid_64",
|b| {
b.iter(|| {
let mut parameters = parameters.clone();
parameters.subdomain_num_cubes_per_dim = Some(64);
reconstruct_surface_inplace::<i64, _>(
particle_positions.as_slice(),
&parameters,
&mut reconstruction,
)
.unwrap()
})
},
);

group.finish();

write_vtk(
Expand Down
3 changes: 2 additions & 1 deletion splashsurf_lib/benches/benches/bench_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ fn reconstruct_particles<P: AsRef<Path>>(particle_file: P) -> SurfaceReconstruct
let parameters = Parameters {
particle_radius,
rest_density: 1000.0,
compact_support_radius: compact_support_radius,
compact_support_radius,
cube_size,
iso_surface_threshold: 0.6,
domain_aabb: None,
enable_multi_threading: true,
subdomain_num_cubes_per_dim: None,
spatial_decomposition: Some(SpatialDecompositionParameters {
subdivision_criterion: SubdivisionCriterion::MaxParticleCountAuto,
ghost_particle_safety_factor: None,
Expand Down
Loading

0 comments on commit 60e7343

Please sign in to comment.