Skip to content

Commit

Permalink
Add a simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinath Kailasa committed Jan 12, 2024
1 parent d7d52e2 commit baf6e53
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions fmm/examples/single_node.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use std::time::Instant;

use itertools::Itertools;

use rlst_dense::rlst_array_from_slice2;

Check failure on line 5 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, mpich, --features "mpi,strict")

unused import: `rlst_dense::rlst_array_from_slice2`

Check failure on line 5 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, openmpi, --features "mpi,strict")

unused import: `rlst_dense::rlst_array_from_slice2`
use rlst_dense::traits::RawAccess;

Check warning on line 6 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Rust style checks

Diff in /home/runner/work/bempp-rs/bempp-rs/fmm/examples/single_node.rs

use bempp_field::types::{FftFieldTranslationKiFmm, SvdFieldTranslationKiFmm};

Check failure on line 8 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, mpich, --features "mpi,strict")

unused import: `SvdFieldTranslationKiFmm`

Check failure on line 8 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, openmpi, --features "mpi,strict")

unused import: `SvdFieldTranslationKiFmm`
use bempp_kernel::laplace_3d::Laplace3dKernel;
use bempp_tree::implementations::helpers::{points_fixture, points_fixture_sphere};

Check failure on line 10 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, mpich, --features "mpi,strict")

unused import: `points_fixture_sphere`

Check failure on line 10 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, openmpi, --features "mpi,strict")

unused import: `points_fixture_sphere`
use bempp_tree::{constants::ROOT, types::single_node::SingleNodeTree};

Check failure on line 11 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, mpich, --features "mpi,strict")

unused import: `constants::ROOT`

Check failure on line 11 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, openmpi, --features "mpi,strict")

unused import: `constants::ROOT`
use bempp_fmm::{types::{KiFmmLinear, FmmDataUniform}, charge::build_charge_dict};
use bempp_traits::{
field::{FieldTranslation, FieldTranslationData},

Check failure on line 14 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, mpich, --features "mpi,strict")

unused imports: `FieldTranslationData`, `FieldTranslation`, `Fmm`, `Kernel`, `KiFmm as KiFmmTrait`, `ScaleInvariantKernel`, `SourceTranslation`, `TargetTranslation`, `TimeDict`, `types::EvalType`

Check failure on line 14 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Run Rust tests (stable, openmpi, --features "mpi,strict")

unused imports: `FieldTranslationData`, `FieldTranslation`, `Fmm`, `Kernel`, `KiFmm as KiFmmTrait`, `ScaleInvariantKernel`, `SourceTranslation`, `TargetTranslation`, `TimeDict`, `types::EvalType`
fmm::{Fmm, FmmLoop, KiFmm as KiFmmTrait, SourceTranslation, TargetTranslation, TimeDict},
kernel::{Kernel, ScaleInvariantKernel},
tree::Tree,

Check warning on line 17 in fmm/examples/single_node.rs

View workflow job for this annotation

GitHub Actions / Rust style checks

Diff in /home/runner/work/bempp-rs/bempp-rs/fmm/examples/single_node.rs
types::EvalType,
};


fn main () {

let npoints = 1000000;

let points = points_fixture::<f64>(npoints, None, None);

let global_idxs = (0..npoints).collect_vec();
let charges = vec![1.0; npoints];

let order = 6;
let alpha_inner = 1.05;
let alpha_outer = 2.95;
let depth = 4;

let tree = SingleNodeTree::new(points.data(), false, None, Some(depth), &global_idxs, true);

let kernel = Laplace3dKernel::default();
let m2l_data: FftFieldTranslationKiFmm<f64, Laplace3dKernel<f64>> =
FftFieldTranslationKiFmm::new(kernel.clone(), order, *tree.get_domain(), alpha_inner);
// let m2l_data = SvdFieldTranslationKiFmm::new(
// kernel.clone(),
// Some(50),
// order,
// *tree.get_domain(),
// alpha_inner,
// );

let fmm = KiFmmLinear::new(order, alpha_inner, alpha_outer, kernel, tree, m2l_data);

// Form charge dict, matching charges with their associated global indices
let charge_dict = build_charge_dict(&global_idxs, &charges);

let datatree = FmmDataUniform::new(fmm, &charge_dict).unwrap();

let s = Instant::now();
let times = datatree.run(true);
println!("runtime {:?} operators {:?}", s.elapsed(), times);

}

0 comments on commit baf6e53

Please sign in to comment.