Skip to content

Commit

Permalink
Convert BoundaryAssembler to struct (#280)
Browse files Browse the repository at this point in the history
* working on refactor

* remove some no-longer-needed functions

* nonsingular cell pair assembler

* singular correction

* Restructuring traits

* simplify parameters

* working on hypersingular

* hypersingular

* fix some typos

* fix bench

* remove old file

* clippy

* trying something

* simplify

* fix mpi

* unused import
  • Loading branch information
mscroggs authored Aug 22, 2024
1 parent 50008c1 commit 50ae817
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 412 deletions.
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::{boundary, boundary::BoundaryAssembler};
use bempp::assembly::boundary::BoundaryAssembler;
use bempp::function::SerialFunctionSpace;
use bempp::traits::{BoundaryAssembly, 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 = boundary::SingleLayerAssembler::<f64, _>::new_laplace();
let mut a = BoundaryAssembler::<f64, _, _>::new_laplace_single_layer();
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::{boundary, boundary::BoundaryAssembler};
use bempp::assembly::boundary::BoundaryAssembler;
use bempp::function::SerialFunctionSpace;
use bempp::traits::{BoundaryAssembly, 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 = boundary::SingleLayerAssembler::<f64, _>::new_laplace();
let mut a = BoundaryAssembler::<f64, _, _>::new_laplace_single_layer();

// Adjust the quadrature degree for non-singular integrals on a triangle.
// This makes the integrals use a quadrature rule with 16 points
Expand Down
4 changes: 2 additions & 2 deletions examples/test_parallel_assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use approx::assert_relative_eq;
#[cfg(feature = "mpi")]
use bempp::{
assembly::boundary,
assembly::boundary::BoundaryAssembler,
function::{ParallelFunctionSpace, SerialFunctionSpace},
traits::{BoundaryAssembly, FunctionSpace, ParallelBoundaryAssembly},
};
Expand Down Expand Up @@ -91,7 +91,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 = boundary::SingleLayerAssembler::<f64, _>::new_laplace();
let a = BoundaryAssembler::<f64, _, _>::new_laplace_single_layer();

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

Expand Down
146 changes: 73 additions & 73 deletions src/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ mod test {
};
(Laplace, $operator:ident, $dtype:ident) => {
paste! {
boundary::[<$operator Assembler>]::<[<$dtype>], _>::new_laplace()
boundary::BoundaryAssembler::<[<$dtype>], _, _>::[<new_laplace_ $operator>]()
}
};
(Helmholtz, $operator:ident, $dtype:ident) => {
paste! {
boundary::[<$operator Assembler>]::<[<$dtype>], _>::new_helmholtz(3.0)
boundary::BoundaryAssembler::<[<$dtype>], _, _>::[<new_helmholtz_ $operator>](3.0)
}
};
}
Expand Down Expand Up @@ -169,76 +169,76 @@ mod test {
}

test_assembly!(
(f64, Laplace, SingleLayer, Triangle),
(f32, Laplace, SingleLayer, Triangle),
//(c64, Laplace, SingleLayer, Triangle),
//(c32, Laplace, SingleLayer, Triangle),
(f64, Laplace, DoubleLayer, Triangle),
(f32, Laplace, DoubleLayer, Triangle),
//(c64, Laplace, DoubleLayer, Triangle),
//(c32, Laplace, DoubleLayer, Triangle),
(f64, Laplace, AdjointDoubleLayer, Triangle),
(f32, Laplace, AdjointDoubleLayer, Triangle),
//(c64, Laplace, AdjointDoubleLayer, Triangle),
//(c32, Laplace, AdjointDoubleLayer, Triangle),
(f64, Laplace, Hypersingular, Triangle),
(f32, Laplace, Hypersingular, Triangle),
//(c64, Laplace, Hypersingular, Triangle),
//(c32, Laplace, Hypersingular, Triangle),
(c64, Helmholtz, SingleLayer, Triangle),
(c32, Helmholtz, SingleLayer, Triangle),
(c64, Helmholtz, DoubleLayer, Triangle),
(c32, Helmholtz, DoubleLayer, Triangle),
(c64, Helmholtz, AdjointDoubleLayer, Triangle),
(c32, Helmholtz, AdjointDoubleLayer, Triangle),
(c64, Helmholtz, Hypersingular, Triangle),
(c32, Helmholtz, Hypersingular, Triangle),
(f64, Laplace, SingleLayer, Quadrilateral),
(f32, Laplace, SingleLayer, Quadrilateral),
//(c64, Laplace, SingleLayer, Quadrilateral),
//(c32, Laplace, SingleLayer, Quadrilateral),
(f64, Laplace, DoubleLayer, Quadrilateral),
(f32, Laplace, DoubleLayer, Quadrilateral),
//(c64, Laplace, DoubleLayer, Quadrilateral),
//(c32, Laplace, DoubleLayer, Quadrilateral),
(f64, Laplace, AdjointDoubleLayer, Quadrilateral),
(f32, Laplace, AdjointDoubleLayer, Quadrilateral),
//(c64, Laplace, AdjointDoubleLayer, Quadrilateral),
//(c32, Laplace, AdjointDoubleLayer, Quadrilateral),
(f64, Laplace, Hypersingular, Quadrilateral),
(f32, Laplace, Hypersingular, Quadrilateral),
//(c64, Laplace, Hypersingular, Quadrilateral),
//(c32, Laplace, Hypersingular, Quadrilateral),
(c64, Helmholtz, SingleLayer, Quadrilateral),
(c32, Helmholtz, SingleLayer, Quadrilateral),
(c64, Helmholtz, DoubleLayer, Quadrilateral),
(c32, Helmholtz, DoubleLayer, Quadrilateral),
(c64, Helmholtz, AdjointDoubleLayer, Quadrilateral),
(c32, Helmholtz, AdjointDoubleLayer, Quadrilateral),
(c64, Helmholtz, Hypersingular, Quadrilateral),
(c32, Helmholtz, Hypersingular, Quadrilateral) //(f64, Laplace, SingleLayer, Mixed),
//(f32, Laplace, SingleLayer, Mixed),
//(c64, Laplace, SingleLayer, Mixed),
//(c32, Laplace, SingleLayer, Mixed),
//(f64, Laplace, DoubleLayer, Mixed),
//(f32, Laplace, DoubleLayer, Mixed),
//(c64, Laplace, DoubleLayer, Mixed),
//(c32, Laplace, DoubleLayer, Mixed),
//(f64, Laplace, AdjointDoubleLayer, Mixed),
//(f32, Laplace, AdjointDoubleLayer, Mixed),
//(c64, Laplace, AdjointDoubleLayer, Mixed),
//(c32, Laplace, AdjointDoubleLayer, Mixed),
//(f64, Laplace, Hypersingular, Mixed),
//(f32, Laplace, Hypersingular, Mixed),
//(c64, Laplace, Hypersingular, Mixed),
//(c32, Laplace, Hypersingular, Mixed),
//(c64, Helmholtz, SingleLayer, Mixed),
//(c32, Helmholtz, SingleLayer, Mixed),
//(c64, Helmholtz, DoubleLayer, Mixed),
//(c32, Helmholtz, DoubleLayer, Mixed),
//(c64, Helmholtz, AdjointDoubleLayer, Mixed),
//(c32, Helmholtz, AdjointDoubleLayer, Mixed),
//(c64, Helmholtz, Hypersingular, Mixed),
//(c32, Helmholtz, Hypersingular, Mixed)
(f64, Laplace, single_layer, Triangle),
(f32, Laplace, single_layer, Triangle),
//(c64, Laplace, single_layer, Triangle),
//(c32, Laplace, single_layer, Triangle),
(f64, Laplace, double_layer, Triangle),
(f32, Laplace, double_layer, Triangle),
//(c64, Laplace, double_layer, Triangle),
//(c32, Laplace, double_layer, Triangle),
(f64, Laplace, adjoint_double_layer, Triangle),
(f32, Laplace, adjoint_double_layer, Triangle),
//(c64, Laplace, adjoint_double_layer, Triangle),
//(c32, Laplace, adjoint_double_layer, Triangle),
(f64, Laplace, hypersingular, Triangle),
(f32, Laplace, hypersingular, Triangle),
//(c64, Laplace, hypersingular, Triangle),
//(c32, Laplace, hypersingular, Triangle),
(c64, Helmholtz, single_layer, Triangle),
(c32, Helmholtz, single_layer, Triangle),
(c64, Helmholtz, double_layer, Triangle),
(c32, Helmholtz, double_layer, Triangle),
(c64, Helmholtz, adjoint_double_layer, Triangle),
(c32, Helmholtz, adjoint_double_layer, Triangle),
(c64, Helmholtz, hypersingular, Triangle),
(c32, Helmholtz, hypersingular, Triangle),
(f64, Laplace, single_layer, Quadrilateral),
(f32, Laplace, single_layer, Quadrilateral),
//(c64, Laplace, single_layer, Quadrilateral),
//(c32, Laplace, single_layer, Quadrilateral),
(f64, Laplace, double_layer, Quadrilateral),
(f32, Laplace, double_layer, Quadrilateral),
//(c64, Laplace, double_layer, Quadrilateral),
//(c32, Laplace, double_layer, Quadrilateral),
(f64, Laplace, adjoint_double_layer, Quadrilateral),
(f32, Laplace, adjoint_double_layer, Quadrilateral),
//(c64, Laplace, adjoint_double_layer, Quadrilateral),
//(c32, Laplace, adjoint_double_layer, Quadrilateral),
(f64, Laplace, hypersingular, Quadrilateral),
(f32, Laplace, hypersingular, Quadrilateral),
//(c64, Laplace, hypersingular, Quadrilateral),
//(c32, Laplace, hypersingular, Quadrilateral),
(c64, Helmholtz, single_layer, Quadrilateral),
(c32, Helmholtz, single_layer, Quadrilateral),
(c64, Helmholtz, double_layer, Quadrilateral),
(c32, Helmholtz, double_layer, Quadrilateral),
(c64, Helmholtz, adjoint_double_layer, Quadrilateral),
(c32, Helmholtz, adjoint_double_layer, Quadrilateral),
(c64, Helmholtz, hypersingular, Quadrilateral),
(c32, Helmholtz, hypersingular, Quadrilateral) //(f64, Laplace, single_layer, Mixed),
//(f32, Laplace, single_layer, Mixed),
//(c64, Laplace, single_layer, Mixed),
//(c32, Laplace, single_layer, Mixed),
//(f64, Laplace, double_layer, Mixed),
//(f32, Laplace, double_layer, Mixed),
//(c64, Laplace, double_layer, Mixed),
//(c32, Laplace, double_layer, Mixed),
//(f64, Laplace, adjoint_double_layer, Mixed),
//(f32, Laplace, adjoint_double_layer, Mixed),
//(c64, Laplace, adjoint_double_layer, Mixed),
//(c32, Laplace, adjoint_double_layer, Mixed),
//(f64, Laplace, hypersingular, Mixed),
//(f32, Laplace, hypersingular, Mixed),
//(c64, Laplace, hypersingular, Mixed),
//(c32, Laplace, hypersingular, Mixed),
//(c64, Helmholtz, single_layer, Mixed),
//(c32, Helmholtz, single_layer, Mixed),
//(c64, Helmholtz, double_layer, Mixed),
//(c32, Helmholtz, double_layer, Mixed),
//(c64, Helmholtz, adjoint_double_layer, Mixed),
//(c32, Helmholtz, adjoint_double_layer, Mixed),
//(c64, Helmholtz, hypersingular, Mixed),
//(c32, Helmholtz, hypersingular, Mixed)
);
}
9 changes: 3 additions & 6 deletions src/assembly/boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ pub(crate) mod cell_pair_assemblers;
mod integrands;

pub use assemblers::BoundaryAssembler;
pub use assemblers::{
AdjointDoubleLayerAssembler, DoubleLayerAssembler, HypersingularAssembler, SingleLayerAssembler,
};

#[cfg(test)]
mod test {
Expand All @@ -29,7 +26,7 @@ mod test {
let ndofs = space.global_size();

let mut matrix = rlst_dynamic_array2!(f64, [ndofs, ndofs]);
let assembler = SingleLayerAssembler::<f64, _>::new_laplace();
let assembler = BoundaryAssembler::<f64, _, _>::new_laplace_single_layer();
assembler.assemble_singular_into_dense(&mut matrix, &space, &space);
let csr = assembler.assemble_singular_into_csr(&space, &space);

Expand All @@ -55,7 +52,7 @@ mod test {
let ndofs = space.global_size();

let mut matrix = rlst_dynamic_array2!(f64, [ndofs, ndofs]);
let assembler = SingleLayerAssembler::<f64, _>::new_laplace();
let assembler = BoundaryAssembler::<f64, _, _>::new_laplace_single_layer();
assembler.assemble_singular_into_dense(&mut matrix, &space, &space);
let csr = assembler.assemble_singular_into_csr(&space, &space);

Expand Down Expand Up @@ -84,7 +81,7 @@ mod test {
let ndofs1 = space1.global_size();

let mut matrix = rlst_dynamic_array2!(f64, [ndofs1, ndofs0]);
let assembler = SingleLayerAssembler::<f64, _>::new_laplace();
let assembler = BoundaryAssembler::<f64, _, _>::new_laplace_single_layer();
assembler.assemble_singular_into_dense(&mut matrix, &space0, &space1);
let csr = assembler.assemble_singular_into_csr(&space0, &space1);
let indptr = csr.indptr();
Expand Down
Loading

0 comments on commit 50ae817

Please sign in to comment.