Skip to content

Commit

Permalink
Green kernel (#105)
Browse files Browse the repository at this point in the history
* WIP: Laplace kernels

* WIP: Clean-Up and unit tests

* Unit tests for Laplace 3d working.

* Updated documentation.

* Updated cargo path for rlst

* Updated Rayon version

* Fixed num_cpus version

---------

Co-authored-by: Matthew Scroggs <[email protected]>
  • Loading branch information
tbetcke and mscroggs authored Jun 29, 2023
1 parent 472fde0 commit 88a4bd8
Show file tree
Hide file tree
Showing 13 changed files with 489 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
rustflags = ["-C", "target-cpu=native"]

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"quadrature",
"tools",
"tree",
"kernel",
"traits",
]

Expand All @@ -21,5 +22,6 @@ default-members = [
"quadrature",
"tools",
"tree",
"kernel",
"traits",
]
4 changes: 2 additions & 2 deletions fmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ blas-src = { version = "*", features = ["openblas"] }
openblas-src = { version = "*", features = ["cblas", "system"] }
ndarray-linalg = { version = "*", features = ["openblas-system"] }
float-cmp = "0.9.0"
rayon = "1.5.1"
num_cpus = "1.0"
rayon = "1.7"
num_cpus = "1"
ndrustfft = "0.4.0"
num = "0.4"
ndarray-ndimage = "0.3.0"
Expand Down
33 changes: 33 additions & 0 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[features]
# Treat warnings as a build error.
strict = []

[package]
name = "bempp-kernel"
version = "0.1.0"
edition = "2021"
authors = ["Timo Betcke <[email protected]>"]
description = "Evaluation of Green's function kernels."
license = "BSD-3-Clause"
homepage = "https://github.com/bempp/bempp-rs"
repository = "https://github.com/bempp/bempp-rs"
readme = "README.md"
keywords = ["numerics"]
categories = ["mathematics", "science"]

[lib]
name = "bempp_kernel"
crate-type = ["lib", "cdylib"]

[dependencies]
bempp-tools = { path = "../tools"}
bempp-traits = { path = "../traits" }
paste = "1.*"
libc = "0.2"
approx = "0.5"
rayon = "1.7"
num = "0.4"
num_cpus = "1"

[dev-dependencies]
rlst = {git = "https://github.com/linalg-rs/rlst.git" }
45 changes: 45 additions & 0 deletions kernel/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use crate::traits::Kernel;
use crate::types::EvalType;
use bempp_traits::types::Scalar;

pub(crate) fn check_dimensions_evaluate<K: Kernel, T: Scalar>(
kernel: &K,
eval_type: EvalType,
sources: &[T::Real],
targets: &[T::Real],
charges: &[T],
result: &[T],
) {
assert!(
sources.len() % kernel.space_dimension() == 0,
"Length of sources {} is not a multiple of space dimension {}.",
sources.len(),
kernel.space_dimension()
);

assert!(
targets.len() % kernel.space_dimension() == 0,
"Length of targets {} is not a multiple of space dimension {}.",
sources.len(),
kernel.space_dimension()
);

let nsources = sources.len() / kernel.space_dimension();
let ntargets = targets.len() / kernel.space_dimension();

assert_eq!(
charges.len(),
nsources,
"Wrong dimension for `charges`. {} != {} ",
charges.len(),
nsources,
);

assert_eq!(
result.len(),
kernel.range_component_count(eval_type) * ntargets,
"Wrong dimension for `result`. {} != {} ",
result.len(),
ntargets * kernel.range_component_count(eval_type),
);
}
Loading

0 comments on commit 88a4bd8

Please sign in to comment.