Skip to content

Commit

Permalink
WIP: Options refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Nov 5, 2024
1 parent 530ba5a commit c37a204
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
18 changes: 9 additions & 9 deletions benches/assembly_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ 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 options = BoundaryAssemblerOptions::default();
options.set_regular_quadrature_degree(ReferenceCellType::Triangle, 16);
options.set_singular_quadrature_degree(
(ReferenceCellType::Triangle, ReferenceCellType::Triangle),
4,
);
options.set_batch_size(128);

let mut assembler = BoundaryAssembler::<f64, _, _>::new(
let assembler = BoundaryAssembler::<f64, _, _>::new(
SingleLayerBoundaryIntegrand::new(),
KernelEvaluator::new(Laplace3dKernel::new(), GreenKernelEvalType::Value),
BoundaryAssemblerOptions::default(),
options.clone(),
1,
0,
);

assembler.set_quadrature_degree(ReferenceCellType::Triangle, 16);
assembler.set_singular_quadrature_degree(
(ReferenceCellType::Triangle, ReferenceCellType::Triangle),
4,
);
assembler.set_batch_size(128);

group.bench_function(
format!(
"Assembly of singular terms of {}x{} matrix",
Expand Down
86 changes: 43 additions & 43 deletions src/assembly/boundary/assemblers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,49 +423,49 @@ impl<T: RlstScalar + MatrixInverse, Integrand: BoundaryIntegrand<T = T>, K: Kern
}
}

/// Set (non-singular) quadrature degree for a cell type
pub fn set_quadrature_degree(&mut self, cell: ReferenceCellType, degree: usize) {
*self.options.quadrature_degrees.get_mut(&cell).unwrap() = degree;
}

/// Get (non-singular) quadrature degree for a cell type
pub fn quadrature_degree(&self, cell: ReferenceCellType) -> Option<usize> {
self.options.quadrature_degrees.get(&cell).copied()
}

/// Set singular quadrature degree for a pair of cell types
pub fn set_singular_quadrature_degree(
&mut self,
cells: (ReferenceCellType, ReferenceCellType),
degree: usize,
) {
*self
.options
.singular_quadrature_degrees
.get_mut(&cells)
.unwrap() = degree;
}

/// Get singular quadrature degree for a pair of cell types
pub fn singular_quadrature_degree(
&self,
cells: (ReferenceCellType, ReferenceCellType),
) -> Option<usize> {
self.options
.singular_quadrature_degrees
.get(&cells)
.copied()
}

/// Set the maximum size of a batch of cells to send to an assembly function
pub fn set_batch_size(&mut self, size: usize) {
self.options.batch_size = size;
}

/// Get the maximum size of a batch of cells to send to an assembly function
pub fn batch_size(&self) -> usize {
self.options.batch_size
}
// /// Set (non-singular) quadrature degree for a cell type
// pub fn set_quadrature_degree(&mut self, cell: ReferenceCellType, degree: usize) {
// *self.options.quadrature_degrees.get_mut(&cell).unwrap() = degree;
// }

// /// Get (non-singular) quadrature degree for a cell type
// pub fn quadrature_degree(&self, cell: ReferenceCellType) -> Option<usize> {
// self.options.quadrature_degrees.get(&cell).copied()
// }

// /// Set singular quadrature degree for a pair of cell types
// pub fn set_singular_quadrature_degree(
// &mut self,
// cells: (ReferenceCellType, ReferenceCellType),
// degree: usize,
// ) {
// *self
// .options
// .singular_quadrature_degrees
// .get_mut(&cells)
// .unwrap() = degree;
// }

// /// Get singular quadrature degree for a pair of cell types
// pub fn singular_quadrature_degree(
// &self,
// cells: (ReferenceCellType, ReferenceCellType),
// ) -> Option<usize> {
// self.options
// .singular_quadrature_degrees
// .get(&cells)
// .copied()
// }

// /// Set the maximum size of a batch of cells to send to an assembly function
// pub fn set_batch_size(&mut self, size: usize) {
// self.options.batch_size = size;
// }

// /// Get the maximum size of a batch of cells to send to an assembly function
// pub fn batch_size(&self) -> usize {
// self.options.batch_size
// }

/// Assemble the singular contributions
pub(crate) fn assemble_singular<Space: FunctionSpace<T = T> + Sync>(
Expand Down

0 comments on commit c37a204

Please sign in to comment.