Skip to content

Commit

Permalink
Fix style checks
Browse files Browse the repository at this point in the history
  • Loading branch information
skailasa committed Jan 22, 2024
1 parent 800547f commit e329e8a
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 29 deletions.
18 changes: 18 additions & 0 deletions fmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,21 @@ rlst-dense = { git = "https://github.com/linalg-rs/rlst.git" }
rlst-blis = { git = "https://github.com/linalg-rs/rlst.git" }
fftw = { git = "https://github.com/skailasa/fftw.git" }
rayon = "1.7"

[[example]]
name = "single_node_fft"
path = "examples/single_node/fft.rs"

[[example]]
name = "single_node_svd"
path = "examples/single_node/svd.rs"


[[example]]
name = "single_node_svd_ia"
path = "examples/single_node/svd_ia.rs"


[[example]]
name = "single_node_svd_ia_matrix"
path = "examples/single_node/matrix_svd_ia.rs"
47 changes: 47 additions & 0 deletions fmm/examples/single_node/fft.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//! Single Node FMM using an FFT based M2L translation operator
use std::time::Instant;

use itertools::Itertools;

use rlst_dense::traits::RawAccess;

use bempp_field::types::FftFieldTranslationKiFmm;
use bempp_fmm::{
charge::build_charge_dict,
types::{FmmDataUniform, KiFmmLinear},
};
use bempp_kernel::laplace_3d::Laplace3dKernel;
use bempp_traits::{fmm::FmmLoop, tree::Tree};
use bempp_tree::implementations::helpers::points_fixture;
use bempp_tree::types::single_node::SingleNodeTree;

fn main() {
let npoints = 10000;

let points = points_fixture::<f32>(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 = 3;

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

let kernel = Laplace3dKernel::default();
let m2l_data: FftFieldTranslationKiFmm<f32, Laplace3dKernel<f32>> =
FftFieldTranslationKiFmm::new(kernel.clone(), 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);
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
//! Single Node FMM using an SVD based M2L operator with individual SVDs found
//! for each M2L operator for an FMM taking matrix input.

use std::time::Instant;

use bempp_fmm::types::FmmDataUniformMatrix;
use itertools::Itertools;

use rlst_dense::traits::RawAccess;

use bempp_field::types::{SvdFieldTranslationKiFmm, SvdFieldTranslationKiFmmIA};
use bempp_field::types::SvdFieldTranslationKiFmmIA;
use bempp_fmm::charge::build_charge_dict;
use bempp_kernel::laplace_3d::Laplace3dKernel;
use bempp_traits::{fmm::FmmLoop, tree::Tree};
use bempp_tree::implementations::helpers::points_fixture;
use bempp_tree::types::single_node::SingleNodeTree;

fn main() {
let npoints = 1000000;
let npoints = 10000;

let global_idxs = (0..npoints).collect_vec();

Expand All @@ -24,7 +27,11 @@ fn main() {
// Test matrix input
let points = points_fixture::<f32>(npoints, None, None);
let ncharge_vecs = 5;
let depth = 4;
let depth = 3;

// The fraction of the total energy of each M2L matrix as measured by the
// square sum of the singular values retained after compression.
let threshold = 0.9999;

let mut charge_mat = vec![vec![0.0; npoints]; ncharge_vecs];
charge_mat
Expand All @@ -38,18 +45,9 @@ fn main() {
// Create a tree
let tree = SingleNodeTree::new(points.data(), false, None, Some(depth), &global_idxs, true);

// Precompute the M2L data
// let m2l_data = SvdFieldTranslationKiFmm::new(
// kernel.clone(),
// Some(80),
// order,
// *tree.get_domain(),
// alpha_inner,
// );

let m2l_data = SvdFieldTranslationKiFmmIA::new(
kernel.clone(),
0.9999,
threshold,
order,
*tree.get_domain(),
alpha_inner,
Expand Down
48 changes: 48 additions & 0 deletions fmm/examples/single_node/svd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//! Single Node FMM using an SVD based M2L translation operator
use std::time::Instant;

use itertools::Itertools;

use rlst_dense::traits::RawAccess;

use bempp_field::types::SvdFieldTranslationKiFmm;
use bempp_fmm::{
charge::build_charge_dict,
types::{FmmDataUniform, KiFmmLinear},
};
use bempp_kernel::laplace_3d::Laplace3dKernel;
use bempp_traits::{fmm::FmmLoop, tree::Tree};
use bempp_tree::implementations::helpers::points_fixture;
use bempp_tree::types::single_node::SingleNodeTree;

fn main() {
let npoints = 10000;

let points = points_fixture::<f32>(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 = 3;

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

let kernel = Laplace3dKernel::default();

let m2l_data =
SvdFieldTranslationKiFmm::new(kernel.clone(), None, 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);
}
27 changes: 11 additions & 16 deletions fmm/examples/single_node.rs → fmm/examples/single_node/svd_ia.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! Single Node FMM using an SVD based M2L operator with individual SVDs found
//! for each M2L operator for an FMM taking vector input.

use std::time::Instant;

use itertools::Itertools;

use rlst_dense::traits::RawAccess;

use bempp_field::types::{
FftFieldTranslationKiFmm, SvdFieldTranslationKiFmm, SvdFieldTranslationKiFmmIA,
};
use bempp_field::types::SvdFieldTranslationKiFmmIA;
use bempp_fmm::{
charge::build_charge_dict,
types::{FmmDataUniform, KiFmmLinear},
Expand All @@ -17,7 +18,7 @@ use bempp_tree::implementations::helpers::points_fixture;
use bempp_tree::types::single_node::SingleNodeTree;

fn main() {
let npoints = 1000000;
let npoints = 10000;

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

Expand All @@ -27,25 +28,19 @@ fn main() {
let order = 6;
let alpha_inner = 1.05;
let alpha_outer = 2.95;
let depth = 4;
let depth = 3;

// The fraction of the total energy of each M2L matrix as measured by the
// square sum of the singular values retained after compression.
let threshold = 0.9999;

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

let kernel = Laplace3dKernel::default();
let m2l_data: FftFieldTranslationKiFmm<f32, Laplace3dKernel<f32>> =
FftFieldTranslationKiFmm::new(kernel.clone(), order, *tree.get_domain(), alpha_inner);

// let m2l_data = SvdFieldTranslationKiFmm::new(
// kernel.clone(),
// Some(80),
// order,
// *tree.get_domain(),
// alpha_inner,
// );

let m2l_data = SvdFieldTranslationKiFmmIA::new(
kernel.clone(),
0.9999,
threshold,
order,
*tree.get_domain(),
alpha_inner,
Expand Down

0 comments on commit e329e8a

Please sign in to comment.