diff --git a/benches/assembly_benchmark.rs b/benches/assembly_benchmark.rs index 32b2bc3d..8a020f4f 100644 --- a/benches/assembly_benchmark.rs +++ b/benches/assembly_benchmark.rs @@ -1,6 +1,6 @@ use bempp::boundary_assemblers::BoundaryAssemblerOptions; -use bempp::function::DefaultFunctionSpace; use bempp::function::FunctionSpace; +use bempp::function::FunctionSpaceTrait; use bempp::laplace::assembler::single_layer; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use mpi; @@ -18,7 +18,7 @@ pub fn assembly_parts_benchmark(c: &mut Criterion) { let grid = bempp::shapes::regular_sphere(i, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let mut options = BoundaryAssemblerOptions::default(); options.set_regular_quadrature_degree(ReferenceCellType::Triangle, 16); options.set_singular_quadrature_degree( diff --git a/examples/assembly.rs b/examples/assembly.rs index e9cc6f48..bfc46d40 100644 --- a/examples/assembly.rs +++ b/examples/assembly.rs @@ -1,5 +1,5 @@ use bempp::boundary_assemblers::BoundaryAssemblerOptions; -use bempp::function::DefaultFunctionSpace; +use bempp::function::FunctionSpace; use bempp::laplace::assembler::single_layer; use ndelement::ciarlet::LagrangeElementFamily; use ndelement::types::{Continuity, ReferenceCellType}; @@ -11,7 +11,7 @@ fn main() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(1, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); // Adjust the quadrature degree for non-singular integrals on a triangle. // This makes the integrals use a quadrature rule with 16 points diff --git a/src/boundary_assemblers.rs b/src/boundary_assemblers.rs index eed9cad8..854088ca 100644 --- a/src/boundary_assemblers.rs +++ b/src/boundary_assemblers.rs @@ -8,7 +8,7 @@ use crate::boundary_assemblers::cell_pair_assemblers::{ }; use crate::boundary_assemblers::helpers::KernelEvaluator; use crate::boundary_assemblers::helpers::{equal_grids, RawData2D, RlstArray, SparseMatrixData}; -use crate::function::FunctionSpace; +use crate::function::FunctionSpaceTrait; use bempp_quadrature::duffy::{ quadrilateral_duffy, quadrilateral_triangle_duffy, triangle_duffy, triangle_quadrilateral_duffy, }; @@ -119,7 +119,7 @@ impl<'o, T: RlstScalar + MatrixInverse, Integrand: BoundaryIntegrand, K: BoundaryAssembler<'o, T, Integrand, K> { /// Assemble the singular part into a CSR matrix. - pub fn assemble_singular + Sync>( + pub fn assemble_singular + Sync>( &self, trial_space: &Space, test_space: &Space, @@ -155,7 +155,7 @@ impl<'o, T: RlstScalar + MatrixInverse, Integrand: BoundaryIntegrand, K: } /// Assemble into a dense matrix. - pub fn assemble + Sync>( + pub fn assemble + Sync>( &self, trial_space: &Space, test_space: &Space, @@ -173,7 +173,7 @@ impl<'o, T: RlstScalar + MatrixInverse, Integrand: BoundaryIntegrand, K: } /// Assemble into a dense matrix. - pub fn assemble_into_memory + Sync>( + pub fn assemble_into_memory + Sync>( &self, trial_space: &Space, test_space: &Space, @@ -231,7 +231,7 @@ impl<'o, T: RlstScalar + MatrixInverse, Integrand: BoundaryIntegrand, K: } /// Assemble the singular contributions - fn assemble_singular_part + Sync>( + fn assemble_singular_part + Sync>( &self, shape: [usize; 2], trial_space: &Space, @@ -393,7 +393,7 @@ impl<'o, T: RlstScalar + MatrixInverse, Integrand: BoundaryIntegrand, K: } /// Assemble the non-singular contributions into a dense matrix - fn assemble_nonsingular_part + Sync>( + fn assemble_nonsingular_part + Sync>( &self, output: &RawData2D, trial_space: &Space, @@ -609,7 +609,7 @@ where #[allow(clippy::too_many_arguments)] fn assemble_batch_singular< T: RlstScalar + MatrixInverse, - Space: FunctionSpace, + Space: FunctionSpaceTrait, Integrand: BoundaryIntegrand, K: Kernel, >( @@ -688,7 +688,7 @@ fn assemble_batch_singular< #[allow(clippy::too_many_arguments)] fn assemble_batch_nonadjacent< T: RlstScalar + MatrixInverse, - Space: FunctionSpace, + Space: FunctionSpaceTrait, Integrand: BoundaryIntegrand, K: Kernel, >( diff --git a/src/function.rs b/src/function.rs index a4480caa..c725505a 100644 --- a/src/function.rs +++ b/src/function.rs @@ -18,7 +18,7 @@ type DofList = Vec>; type OwnerData = Vec<(usize, usize, usize, usize)>; /// A function space -pub trait FunctionSpace { +pub trait FunctionSpaceTrait { /// Communicator type C: Communicator; /// Scalar type @@ -70,7 +70,7 @@ pub trait FunctionSpace { } /// Implementation of a general function space. -pub struct DefaultFunctionSpace< +pub struct FunctionSpace< 'a, C: Communicator, T: RlstScalar + MatrixInverse, @@ -88,11 +88,10 @@ pub struct DefaultFunctionSpace< } unsafe impl< - 'a, C: Communicator, T: RlstScalar + MatrixInverse, GridImpl: ParallelGrid + Grid, - > Sync for DefaultFunctionSpace<'a, C, T, GridImpl> + > Sync for FunctionSpace<'_, C, T, GridImpl> { } @@ -101,7 +100,7 @@ impl< C: Communicator, T: RlstScalar + MatrixInverse, GridImpl: ParallelGrid + Grid, - > DefaultFunctionSpace<'a, C, T, GridImpl> + > FunctionSpace<'a, C, T, GridImpl> { /// Create new function space pub fn new( @@ -239,11 +238,10 @@ impl< } impl< - 'a, C: Communicator, T: RlstScalar + MatrixInverse, GridImpl: ParallelGrid + Grid, - > FunctionSpace for DefaultFunctionSpace<'a, C, T, GridImpl> + > FunctionSpaceTrait for FunctionSpace<'_, C, T, GridImpl> { type T = T; type Grid = GridImpl; diff --git a/tests/compare_to_bempp_cl.rs b/tests/compare_to_bempp_cl.rs index ab17626f..a1ceb527 100644 --- a/tests/compare_to_bempp_cl.rs +++ b/tests/compare_to_bempp_cl.rs @@ -2,7 +2,7 @@ use std::sync::LazyLock; use approx::*; use bempp::boundary_assemblers::BoundaryAssemblerOptions; -use bempp::function::DefaultFunctionSpace; +use bempp::function::FunctionSpace; use bempp::{helmholtz, laplace}; use cauchy::c64; use mpi::environment::Universe; @@ -23,7 +23,7 @@ fn test_laplace_single_layer_dp0_dp0() { let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = laplace::assembler::single_layer(&options).assemble(&space, &space); @@ -45,7 +45,7 @@ fn test_laplace_double_layer_dp0_dp0() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = laplace::assembler::double_layer(&options).assemble(&space, &space); @@ -67,7 +67,7 @@ fn test_laplace_adjoint_double_layer_dp0_dp0() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = laplace::assembler::adjoint_double_layer(&options).assemble(&space, &space); @@ -90,7 +90,7 @@ fn test_laplace_hypersingular_p1_p1() { let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(1, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = laplace::assembler::hypersingular(&options).assemble(&space, &space); @@ -118,7 +118,7 @@ fn test_helmholtz_single_layer_dp0_dp0() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = helmholtz::assembler::single_layer(3.0, &options).assemble(&space, &space); @@ -140,7 +140,7 @@ fn test_helmholtz_double_layer_dp0_dp0() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = helmholtz::assembler::double_layer(3.0, &options).assemble(&space, &space); @@ -161,7 +161,7 @@ fn test_helmholtz_adjoint_double_layer_dp0_dp0() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = helmholtz::assembler::adjoint_double_layer(3.0, &options).assemble(&space, &space); @@ -183,7 +183,7 @@ fn test_helmholtz_hypersingular_p1_p1() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = bempp::shapes::regular_sphere(0, 1, &comm); let element = LagrangeElementFamily::::new(1, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let options = BoundaryAssemblerOptions::default(); let matrix = helmholtz::assembler::hypersingular(3.0, &options).assemble(&space, &space); diff --git a/tests/test_space.rs b/tests/test_space.rs index 531b0970..6d1d9e78 100644 --- a/tests/test_space.rs +++ b/tests/test_space.rs @@ -1,6 +1,5 @@ -use bempp::function::{assign_dofs, DefaultFunctionSpace, FunctionSpace}; +use bempp::function::{assign_dofs, FunctionSpace, FunctionSpaceTrait}; use bempp::shapes::{regular_sphere, screen_triangles}; -use mpi::topology::SimpleCommunicator; use ndelement::ciarlet::{LagrangeElementFamily, RaviartThomasElementFamily}; use ndelement::types::{Continuity, ReferenceCellType}; use ndgrid::traits::{Entity, Grid, Topology}; @@ -14,13 +13,6 @@ static MPI_UNIVERSE: LazyLock = std::sync::LazyLock::new(|| { .0 }); -fn get_comm() -> SimpleCommunicator { - use mpi; - - let _ = mpi::initialize(); - mpi::topology::SimpleCommunicator::self_comm() -} - fn run_test( grid: &(impl Grid + Sync), degree: usize, @@ -149,7 +141,7 @@ fn test_dofmap_lagrange0() { let grid = regular_sphere::(2, 1, &comm); //let grid = regular_sphere::(2, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); assert_eq!(space.local_size(), space.global_size()); assert_eq!( space.local_size(), @@ -163,7 +155,7 @@ fn test_dofmap_lagrange1() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = regular_sphere::(2, 1, &comm); let element = LagrangeElementFamily::::new(1, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); assert_eq!(space.local_size(), space.global_size()); assert_eq!( space.local_size(), @@ -177,7 +169,7 @@ fn test_dofmap_lagrange2() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = regular_sphere::(2, 1, &comm); let element = LagrangeElementFamily::::new(2, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); assert_eq!(space.local_size(), space.global_size()); assert_eq!( space.local_size(), @@ -192,7 +184,7 @@ fn test_colouring_p1() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = regular_sphere::(2, 1, &comm); let element = LagrangeElementFamily::::new(1, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let colouring = &space.cell_colouring()[&ReferenceCellType::Triangle]; let cells = grid.entity_iter(2).collect::>(); let mut n = 0; @@ -232,7 +224,7 @@ fn test_colouring_dp0() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = regular_sphere::(2, 1, &comm); let element = LagrangeElementFamily::::new(0, Continuity::Discontinuous); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let colouring = &space.cell_colouring()[&ReferenceCellType::Triangle]; let mut n = 0; for i in colouring { @@ -259,7 +251,7 @@ fn test_colouring_rt1() { let comm = mpi::topology::SimpleCommunicator::self_comm(); let grid = regular_sphere::(2, 1, &comm); let element = LagrangeElementFamily::::new(1, Continuity::Standard); - let space = DefaultFunctionSpace::new(&grid, &element); + let space = FunctionSpace::new(&grid, &element); let colouring = &space.cell_colouring()[&ReferenceCellType::Triangle]; let mut n = 0; for i in colouring {