Skip to content

Commit

Permalink
Merge branch 'main' into mscroggs/cell_dofs_unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs authored Aug 30, 2024
2 parents 43b8b65 + 44043aa commit 389ea11
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 234 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ mpi = { version = "0.8.*", optional = true }
num = "0.4"
lazy_static = "1.4"
ndelement = "0.1.0"
# ndgrid = "0.1.0"
ndgrid = { git = "https://github.com/bempp/ndgrid.git" }
rayon = "1.9"
rlst = "0.2"
Expand Down
131 changes: 65 additions & 66 deletions src/assembly/boundary/cell_pair_assemblers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,22 @@ impl<
for (test_i, entry) in col.iter_mut().enumerate() {
*entry = T::zero();
for (index, wt) in self.weights.iter().enumerate() {
*entry += unsafe {
self.integrand.evaluate_singular(
self.test_table,
self.trial_table,
index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*wt * *self.test_jdet.get_unchecked(index)
* *self.trial_jdet.get_unchecked(index),
)
.unwrap()
};
*entry += self.integrand.evaluate_singular(
self.test_table,
self.trial_table,
index,
test_i,
trial_i,
&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();
}
}
}
Expand Down Expand Up @@ -299,22 +299,21 @@ impl<
.unwrap()
};
for (trial_index, trial_wt) in self.trial_weights.iter().enumerate() {
*entry += unsafe {
self.integrand.evaluate_nonsingular(
self.test_table,
self.trial_table,
test_index,
trial_index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*trial_wt * *self.trial_jdet.get_unchecked(trial_index),
)
.unwrap()
} * test_integrand;
*entry += self.integrand.evaluate_nonsingular(
self.test_table,
self.trial_table,
test_index,
trial_index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*trial_wt * unsafe { *self.trial_jdet.get_unchecked(trial_index) },
)
.unwrap()
* test_integrand;
}
}
}
Expand Down Expand Up @@ -486,26 +485,27 @@ impl<
.unwrap()
};
for (trial_index, trial_wt) in self.trial_weights.iter().enumerate() {
*entry += unsafe {
self.integrand.evaluate_nonsingular(
self.test_table,
self.trial_table,
test_index,
trial_index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*trial_wt
* *self
*entry += self.integrand.evaluate_nonsingular(
self.test_table,
self.trial_table,
test_index,
trial_index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*trial_wt
* unsafe {
*self
.trial_jdet
.get_unchecked(self.trial_cell)
.get_unchecked(trial_index),
)
.unwrap()
} * test_integrand;
.get_unchecked(trial_index)
},
)
.unwrap()
* test_integrand;
}
}
}
Expand Down Expand Up @@ -679,22 +679,21 @@ impl<
}
.unwrap();
for (trial_index, trial_wt) in self.trial_weights.iter().enumerate() {
*entry += unsafe {
self.integrand.evaluate_nonsingular(
self.test_table,
self.trial_table,
test_index,
trial_index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*trial_wt * *self.trial_jdet.get_unchecked(trial_index),
)
.unwrap()
} * test_integrand;
*entry += self.integrand.evaluate_nonsingular(
self.test_table,
self.trial_table,
test_index,
trial_index,
test_i,
trial_i,
&self.k,
&test_geometry,
&trial_geometry,
) * num::cast::<T::Real, T>(
*trial_wt * unsafe { *self.trial_jdet.get_unchecked(trial_index) },
)
.unwrap()
* test_integrand;
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/assembly/boundary/integrands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ impl<T: RlstScalar, I0: BoundaryIntegrand<T = T>, I1: BoundaryIntegrand<T = T>>
}
}

impl<T: RlstScalar, I0: BoundaryIntegrand<T = T>, I1: BoundaryIntegrand<T = T>> BoundaryIntegrand
for BoundaryIntegrandSum<T, I0, I1>
unsafe impl<T: RlstScalar, I0: BoundaryIntegrand<T = T>, I1: BoundaryIntegrand<T = T>>
BoundaryIntegrand for BoundaryIntegrandSum<T, I0, I1>
{
type T = T;

unsafe fn evaluate_nonsingular(
fn evaluate_nonsingular(
&self,
test_table: &RlstArray<T, 4>,
trial_table: &RlstArray<T, 4>,
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<T: RlstScalar, I0: BoundaryIntegrand<T = T>, I1: BoundaryIntegrand<T = T>>
)
}

unsafe fn evaluate_singular(
fn evaluate_singular(
&self,
test_table: &RlstArray<T, 4>,
trial_table: &RlstArray<T, 4>,
Expand Down Expand Up @@ -121,12 +121,12 @@ impl<T: RlstScalar, I: BoundaryIntegrand<T = T>> BoundaryIntegrandScalarProduct<
}
}

impl<T: RlstScalar, I: BoundaryIntegrand<T = T>> BoundaryIntegrand
unsafe impl<T: RlstScalar, I: BoundaryIntegrand<T = T>> BoundaryIntegrand
for BoundaryIntegrandScalarProduct<T, I>
{
type T = T;

unsafe fn evaluate_nonsingular(
fn evaluate_nonsingular(
&self,
test_table: &RlstArray<T, 4>,
trial_table: &RlstArray<T, 4>,
Expand All @@ -152,7 +152,7 @@ impl<T: RlstScalar, I: BoundaryIntegrand<T = T>> BoundaryIntegrand
)
}

unsafe fn evaluate_singular(
fn evaluate_singular(
&self,
test_table: &RlstArray<T, 4>,
trial_table: &RlstArray<T, 4>,
Expand Down
60 changes: 34 additions & 26 deletions src/assembly/boundary/integrands/adjoint_double_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ impl<T: RlstScalar> AdjointDoubleLayerBoundaryIntegrand<T> {
}
}

impl<T: RlstScalar> BoundaryIntegrand for AdjointDoubleLayerBoundaryIntegrand<T> {
unsafe impl<T: RlstScalar> BoundaryIntegrand for AdjointDoubleLayerBoundaryIntegrand<T> {
type T = T;

unsafe fn evaluate_nonsingular(
fn evaluate_nonsingular(
&self,
test_table: &RlstArray<T, 4>,
trial_table: &RlstArray<T, 4>,
Expand All @@ -30,26 +30,28 @@ impl<T: RlstScalar> BoundaryIntegrand for AdjointDoubleLayerBoundaryIntegrand<T>
test_geometry: &impl CellGeometry<T = T::Real>,
_trial_geometry: &impl CellGeometry<T = T::Real>,
) -> T {
-(*k.get_unchecked([1, test_point_index, trial_point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([0, test_point_index]),
)
.unwrap()
+ *k.get_unchecked([2, test_point_index, trial_point_index])
unsafe {
-(*k.get_unchecked([1, test_point_index, trial_point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([1, test_point_index]),
*test_geometry.normals().get_unchecked([0, test_point_index]),
)
.unwrap()
+ *k.get_unchecked([3, test_point_index, trial_point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([2, test_point_index]),
)
.unwrap())
* *test_table.get_unchecked([0, test_point_index, test_basis_index, 0])
* *trial_table.get_unchecked([0, trial_point_index, trial_basis_index, 0])
+ *k.get_unchecked([2, test_point_index, trial_point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([1, test_point_index]),
)
.unwrap()
+ *k.get_unchecked([3, test_point_index, trial_point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([2, test_point_index]),
)
.unwrap())
* *test_table.get_unchecked([0, test_point_index, test_basis_index, 0])
* *trial_table.get_unchecked([0, trial_point_index, trial_basis_index, 0])
}
}

unsafe fn evaluate_singular(
fn evaluate_singular(
&self,
test_table: &RlstArray<T, 4>,
trial_table: &RlstArray<T, 4>,
Expand All @@ -60,17 +62,23 @@ impl<T: RlstScalar> BoundaryIntegrand for AdjointDoubleLayerBoundaryIntegrand<T>
test_geometry: &impl CellGeometry<T = T::Real>,
_trial_geometry: &impl CellGeometry<T = T::Real>,
) -> T {
-(*k.get_unchecked([1, point_index])
* num::cast::<T::Real, T>(*test_geometry.normals().get_unchecked([0, point_index]))
.unwrap()
+ *k.get_unchecked([2, point_index])
* num::cast::<T::Real, T>(*test_geometry.normals().get_unchecked([1, point_index]))
unsafe {
-(*k.get_unchecked([1, point_index])
* num::cast::<T::Real, T>(*test_geometry.normals().get_unchecked([0, point_index]))
.unwrap()
+ *k.get_unchecked([3, point_index])
* num::cast::<T::Real, T>(*test_geometry.normals().get_unchecked([2, point_index]))
+ *k.get_unchecked([2, point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([1, point_index]),
)
.unwrap()
+ *k.get_unchecked([3, point_index])
* num::cast::<T::Real, T>(
*test_geometry.normals().get_unchecked([2, point_index]),
)
.unwrap())
* *test_table.get_unchecked([0, point_index, test_basis_index, 0])
* *trial_table.get_unchecked([0, point_index, trial_basis_index, 0])
* *test_table.get_unchecked([0, point_index, test_basis_index, 0])
* *trial_table.get_unchecked([0, point_index, trial_basis_index, 0])
}
}
}

Expand Down
Loading

0 comments on commit 389ea11

Please sign in to comment.