Skip to content

Commit

Permalink
WIP: Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Oct 31, 2024
1 parent ad736e1 commit 135a39e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
53 changes: 21 additions & 32 deletions src/assembly/boundary/assemblers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use bempp_quadrature::duffy::{
};
use bempp_quadrature::simplex_rules::simplex_rule;
use bempp_quadrature::types::{CellToCellConnectivity, TestTrialNumericalQuadratureDefinition};
use itertools::izip;
use itertools::{izip, Itertools};
#[cfg(feature = "mpi")]
use mpi::traits::Communicator;
use ndelement::reference_cell;
Expand Down Expand Up @@ -853,47 +853,36 @@ impl<

for test_cell_type in test_space.grid().entity_types(2) {
let npts_test = self.options.quadrature_degrees[test_cell_type];
let qrule_test = simplex_rule(*test_cell_type, npts_test).unwrap();
let mut qpoints_test = rlst_dynamic_array2!(<T as RlstScalar>::Real, [2, npts_test]);
for (target, source) in izip!(qpoints_test.data_mut(), qrule_test.points.iter()) {
*target = num::cast::<f64, <T as RlstScalar>::Real>(*source).unwrap();
}
let qweights_test = qrule_test
.weights
.iter()
.map(|w| num::cast::<f64, <T as RlstScalar>::Real>(*w).unwrap())
.collect_vec();
let test_element = test_space.element(*test_cell_type);
let mut test_table = rlst_dynamic_array4!(
T,
test_element.tabulate_array_shape(self.table_derivs, npts_test)
);
test_element.tabulate(&qpoints_test, self.table_derivs, &mut test_table);

for trial_cell_type in trial_space.grid().entity_types(2) {
let npts_trial = self.options.quadrature_degrees[trial_cell_type];
let qrule_test = simplex_rule(*test_cell_type, npts_test).unwrap();
let mut qpoints_test =
rlst_dynamic_array2!(<T as RlstScalar>::Real, [2, npts_test]);
for i in 0..npts_test {
for j in 0..2 {
*qpoints_test.get_mut([j, i]).unwrap() =
num::cast::<f64, <T as RlstScalar>::Real>(qrule_test.points[2 * i + j])
.unwrap();
}
}
let qweights_test = qrule_test
.weights
.iter()
.map(|w| num::cast::<f64, <T as RlstScalar>::Real>(*w).unwrap())
.collect::<Vec<_>>();
let qrule_trial = simplex_rule(*trial_cell_type, npts_trial).unwrap();
let mut qpoints_trial =
rlst_dynamic_array2!(<T as RlstScalar>::Real, [2, npts_trial]);
for i in 0..npts_trial {
for j in 0..2 {
*qpoints_trial.get_mut([j, i]).unwrap() =
num::cast::<f64, <T as RlstScalar>::Real>(
qrule_trial.points[2 * i + j],
)
.unwrap();
}
for (target, source) in izip!(qpoints_trial.data_mut(), qrule_trial.points.iter()) {
*target = num::cast::<f64, <T as RlstScalar>::Real>(*source).unwrap();
}
let qweights_trial = qrule_trial
.weights
.iter()
.map(|w| num::cast::<f64, <T as RlstScalar>::Real>(*w).unwrap())
.collect::<Vec<_>>();

let test_element = test_space.element(*test_cell_type);
let mut test_table = rlst_dynamic_array4!(
T,
test_element.tabulate_array_shape(self.table_derivs, npts_test)
);
test_element.tabulate(&qpoints_test, self.table_derivs, &mut test_table);
.collect_vec();

let trial_element = trial_space.element(*trial_cell_type);
let mut trial_table = rlst_dynamic_array4!(
Expand Down
16 changes: 8 additions & 8 deletions src/assembly/boundary/cell_pair_assemblers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ impl<
for (trial_i, mut col) in local_mat.col_iter_mut().enumerate() {
for (test_i, entry) in col.iter_mut().enumerate() {
*entry = T::zero();
for (index, wt) in self.weights.iter().enumerate() {
for (index, (&wt, &test_det, &trial_det)) in izip!(
self.weights.iter(),
self.test_jdet.iter(),
self.trial_jdet.iter()
)
.enumerate()
{
*entry += self.integrand.evaluate_singular(
self.test_table,
self.trial_table,
Expand All @@ -146,13 +152,7 @@ impl<
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*wt * unsafe {
*self.test_jdet.get_unchecked(index)
* *self.trial_jdet.get_unchecked(index)
},
)
.unwrap();
) * num::cast::<T::Real, T>(wt * test_det * trial_det).unwrap();
}
}
}
Expand Down

0 comments on commit 135a39e

Please sign in to comment.