Skip to content

Commit 827ffeb

Browse files
committed
Test transform optimisation
1 parent 4c25ace commit 827ffeb

3 files changed

Lines changed: 17 additions & 24 deletions

File tree

cpp/dolfinx/fem/FiniteElement.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,7 @@ class FiniteElement
435435
dof_transformation_fn(doftransform ttype, bool scalar_element = false) const
436436
{
437437
if (!needs_dof_transformations())
438-
{
439-
// If no permutation needed, return function that does nothing
440-
return [](std::span<U>, std::span<const std::uint32_t>, std::int32_t, int)
441-
{
442-
// Do nothing
443-
};
444-
}
438+
return nullptr;
445439

446440
if (!_sub_elements.empty())
447441
{
@@ -541,13 +535,7 @@ class FiniteElement
541535
bool scalar_element = false) const
542536
{
543537
if (!needs_dof_transformations())
544-
{
545-
// If no permutation needed, return function that does nothing
546-
return [](std::span<U>, std::span<const std::uint32_t>, std::int32_t, int)
547-
{
548-
// Do nothing
549-
};
550-
}
538+
return nullptr;
551539
else if (!_sub_elements.empty())
552540
{
553541
if (!_reference_value_shape) // Mixed element

cpp/dolfinx/fem/assemble_matrix_impl.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ void assemble_cells_matrix(
153153
nullptr, nullptr);
154154

155155
// Compute A = P_0 \tilde{A} P_1^T (dof transformation)
156-
P0(Ae, cell_info0, cell0, ndim1); // B = P0 \tilde{A}
157-
P1T(Ae, cell_info1, cell1, ndim0); // A = B P1_T
156+
if (P0)
157+
P0(Ae, cell_info0, cell0, ndim1); // B = P0 \tilde{A}
158+
if (P1T)
159+
P1T(Ae, cell_info1, cell1, ndim0); // A = B P1_T
158160

159161
// In lifting mode only BC dofs are assembled, while in standard mode these
160162
// row/column dofs are zeroed.
@@ -333,8 +335,10 @@ void assemble_entities(
333335
std::ranges::fill(Ae, 0);
334336
kernel(Ae.data(), &coeffs(f, 0), constants.data(), cdofs_b.data(),
335337
&local_entity, &perm, nullptr);
336-
P0(Ae, cell_info0, cell0, ndim1);
337-
P1T(Ae, cell_info1, cell1, ndim0);
338+
if (P0)
339+
P0(Ae, cell_info0, cell0, ndim1);
340+
if (P1T)
341+
P1T(Ae, cell_info1, cell1, ndim0);
338342

339343
// Don't clear rows/cols in LiftingMode
340344
if constexpr (!LiftingMode)
@@ -586,16 +590,15 @@ void assemble_interior_facets(
586590
// where each block is element tensor of size (dmap0, dmap1).
587591

588592
// Only apply transformation when cells exist
589-
if (cells0[0] >= 0)
593+
if (P0 and cells0[0] >= 0)
590594
P0(Ae, cell_info0, cells0[0], num_cols);
591-
if (cells0[1] >= 0)
595+
if (P1T and cells0[1] >= 0)
592596
{
593597
std::span sub_Ae0(Ae.data() + bs0 * dmap0_size * num_cols,
594598
bs0 * dmap0_size * num_cols);
595-
596599
P0(sub_Ae0, cell_info0, cells0[1], num_cols);
597600
}
598-
if (cells1[0] >= 0)
601+
if (P1T and cells1[0] >= 0)
599602
P1T(Ae, cell_info1, cells1[0], num_rows);
600603

601604
if (cells1[1] >= 0)

cpp/dolfinx/fem/assemble_vector_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ void assemble_cells(
105105
std::ranges::fill(be, 0);
106106
kernel(be.data(), &coeffs(index, 0), constants.data(), cdofs_b.data(),
107107
nullptr, nullptr, nullptr);
108-
P0(be, cell_info0, c0, 1);
108+
if (P0)
109+
P0(be, cell_info0, c0, 1);
109110

110111
// Scatter cell vector to 'global' vector array
111112
auto dofs = md::submdspan(dmap, c0, md::full_extent);
@@ -200,7 +201,8 @@ void assemble_entities(
200201
std::ranges::fill(be, 0);
201202
kernel(be.data(), &coeffs(f, 0), constants.data(), cdofs_b.data(),
202203
&local_entity, &perm, nullptr);
203-
P0(be, cell_info0, cell0, 1);
204+
if (P0)
205+
P0(be, cell_info0, cell0, 1);
204206

205207
// Add to global vector
206208
auto dofs = md::submdspan(dmap, cell0, md::full_extent);

0 commit comments

Comments
 (0)