Skip to content

Commit

Permalink
WIP: Testing evaluators
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Dec 31, 2024
1 parent 57c7cf0 commit 611c8d8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ green-kernels = { git = "https://github.com/bempp/green-kernels.git", features =
# c-api-tools = { version = "0.1.0" }
kifmm = { git = "https://github.com/bempp/kifmm.git", features = ["mpi"] }
bempp-distributed-tools = { git = "https://github.com/bempp/distributed_tools.git"}

rand = "0.8"
rand_chacha = "0.3"

[dev-dependencies]
approx = "0.5"
Expand Down
60 changes: 60 additions & 0 deletions examples/test_green_evaluators.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Compare dense and FMM Green's function evaluators.

use bempp::greens_function_evaluators::kifmm_evaluator::KiFmmEvaluator;
use bempp_distributed_tools::IndexLayoutFromLocalCounts;
use green_kernels::{laplace_3d::Laplace3dKernel, types::GreenKernelEvalType};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
use rlst::{operator::interface::DistributedArrayVectorSpace, Element, LinearSpace};

fn main() {
// Number of points per process.
let npoints = 10000;
let mut rng = ChaCha8Rng::seed_from_u64(0);

// Create random sources and targets.

let sources = (0..3 * npoints)
.map(|_| rng.gen_range(-1.0..1.0))
.collect::<Vec<f64>>();

let targets = sources.clone();

// Initialise MPI

let universe = mpi::initialize().unwrap();
let world = universe.world();

// Initalise the index layout.

let index_layout = IndexLayoutFromLocalCounts::new(npoints, &world);

// Create the vector space.

let space = DistributedArrayVectorSpace::<_, f64>::new(&index_layout);

// Create a random vector of charges.

let mut charges = space.zero();

charges
.view_mut()
.local_mut()
.fill_from_equally_distributed(&mut rng);

// Create the dense evaluator.

let dense_evaluator = bempp::greens_function_evaluators::dense_evaluator::DenseEvaluator::new(
&sources,
&targets,
GreenKernelEvalType::Value,
false,
Laplace3dKernel::default(),
&space,
&space,
);

// Create the FMM evaluator.

let fmm_evaluator = KiFmmEvaluator::new(&sources, &targets, 3, 2, 10, &space, &space);
}

0 comments on commit 611c8d8

Please sign in to comment.