Skip to content

Commit

Permalink
Refactor assembly (#278)
Browse files Browse the repository at this point in the history
* update version numbers

* restructure files

* fmt

* reduce code duplication

* clippy
  • Loading branch information
mscroggs authored Aug 20, 2024
1 parent fead46f commit 1d36bec
Show file tree
Hide file tree
Showing 22 changed files with 686 additions and 820 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ itertools = "0.13.*"
mpi = { version = "0.8.*", optional = true }
num = "0.4"
lazy_static = "1.4"
ndelement = { git = "https://github.com/bempp/ndelement.git" }
ndgrid = { git = "https://github.com/bempp/ndgrid.git" }
ndelement = "0.1.0"
ndgrid = "0.1.0"
rayon = "1.9"
rlst = { version = "0.2" }
green-kernels = { git = "https://github.com/bempp/green-kernels.git" }
rlst = "0.2"
green-kernels = "0.2.0"

[dev-dependencies]
approx = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions benches/assembly_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bempp::assembly::{batched, batched::BatchedAssembler};
use bempp::assembly::{boundary, boundary::BoundaryAssembler};
use bempp::function::SerialFunctionSpace;
use bempp::traits::FunctionSpace;
use criterion::{criterion_group, criterion_main, Criterion};
Expand All @@ -19,7 +19,7 @@ pub fn assembly_parts_benchmark(c: &mut Criterion) {
let mut matrix = rlst_dynamic_array2!(f64, [space.global_size(), space.global_size()]);

let colouring = space.cell_colouring();
let mut a = batched::LaplaceSingleLayerAssembler::<f64>::default();
let mut a = boundary::SingleLayerAssembler::<f64, _>::new_laplace();
a.quadrature_degree(ReferenceCellType::Triangle, 16);
a.singular_quadrature_degree(
(ReferenceCellType::Triangle, ReferenceCellType::Triangle),
Expand Down
4 changes: 2 additions & 2 deletions examples/assembly.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bempp::assembly::{batched, batched::BatchedAssembler};
use bempp::assembly::{boundary, boundary::BoundaryAssembler};
use bempp::function::SerialFunctionSpace;
use bempp::traits::FunctionSpace;
use ndelement::ciarlet::LagrangeElementFamily;
Expand All @@ -17,7 +17,7 @@ fn main() {
let mut matrix = rlst_dynamic_array2!(f64, [ndofs, ndofs]);

// Create an assembler for the Laplace single layer operator
let mut a = batched::LaplaceSingleLayerAssembler::<f64>::default();
let mut a = boundary::SingleLayerAssembler::<f64, _>::new_laplace();

// Adjust the quadrature degree for non-singular integrals on a triangle.
// This makes the integrals use a quadrature rule with 16 points
Expand Down
6 changes: 3 additions & 3 deletions examples/test_parallel_assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use approx::assert_relative_eq;
#[cfg(feature = "mpi")]
use bempp::{
assembly::batched,
assembly::batched::BatchedAssembler,
assembly::boundary,
assembly::boundary::BoundaryAssembler,
function::{ParallelFunctionSpace, SerialFunctionSpace},
traits::FunctionSpace,
};
Expand Down Expand Up @@ -92,7 +92,7 @@ fn test_parallel_assembly_single_element_grid<C: Communicator>(
let element = LagrangeElementFamily::<f64>::new(degree, cont);
let space = ParallelFunctionSpace::new(&grid, &element);

let a = batched::LaplaceSingleLayerAssembler::<f64>::default();
let a = boundary::SingleLayerAssembler::<f64, _>::new_laplace();

let matrix = a.parallel_assemble_singular_into_csr(&space, &space);

Expand Down
9 changes: 5 additions & 4 deletions src/assembly.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! Boundary operator assembly
pub mod batched;
pub mod boundary;
pub(crate) mod common;
pub mod fmm_tools;
pub mod potential;

#[cfg(test)]
mod test {
use super::batched::BatchedAssembler;
use super::boundary::BoundaryAssembler;
use super::*;
use crate::function::SerialFunctionSpace;
use crate::traits::FunctionSpace;
Expand Down Expand Up @@ -122,12 +123,12 @@ mod test {
macro_rules! create_assembler {
(Laplace, $operator:ident, $dtype:ident) => {
paste! {
batched::[<Laplace $operator Assembler>]::<[<$dtype>]>::default()
boundary::[<$operator Assembler>]::<[<$dtype>], _>::new_laplace()
}
};
(Helmholtz, $operator:ident, $dtype:ident) => {
paste! {
batched::[<Helmholtz $operator Assembler>]::<[<$dtype>]>::new(3.0)
boundary::[<$operator Assembler>]::<[<$dtype>], _>::new_helmholtz(3.0)
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/assembly/batched.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Batched dense assembly
use crate::assembly::common::SparseMatrixData;
use green_kernels::types::GreenKernelEvalType;
use green_kernels::types::EvalType as GreenKernelEvalType;
use rlst::{Array, BaseArray, VectorContainer};

mod boundary;
Expand Down
144 changes: 0 additions & 144 deletions src/assembly/batched/boundary/adjoint_double_layer.rs

This file was deleted.

144 changes: 0 additions & 144 deletions src/assembly/batched/boundary/double_layer.rs

This file was deleted.

Loading

0 comments on commit 1d36bec

Please sign in to comment.