Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename dof transformation functions #2888

Merged
merged 7 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cpp/dolfinx/fem/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Expression
std::function<void(const std::span<scalar_type>&,
const std::span<const std::uint32_t>&, std::int32_t,
int)>
dof_transform_to_transpose
post_dof_transform
= [](const std::span<scalar_type>&,
const std::span<const std::uint32_t>&, std::int32_t, int)
{
Expand All @@ -193,9 +193,10 @@ class Expression
{
mesh.topology_mutable()->create_entity_permutations();
cell_info = std::span(mesh.topology()->get_cell_permutation_info());
dof_transform_to_transpose
= element->template get_dof_transformation_to_transpose_function<
scalar_type>();
post_dof_transform
= element
->template get_post_dof_transformation_function<scalar_type>(
false, true);
}
}

Expand All @@ -219,7 +220,7 @@ class Expression
_fn(values_local.data(), coeff_cell, constant_data.data(),
coord_dofs.data(), nullptr, nullptr);

dof_transform_to_transpose(values_local, cell_info, c, size0);
post_dof_transform(values_local, cell_info, c, size0);
for (std::size_t j = 0; j < values_local.size(); ++j)
values[c * vshape[1] + j] = values_local[j];
}
Expand Down
130 changes: 63 additions & 67 deletions cpp/dolfinx/fem/FiniteElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ class FiniteElement
template <typename U>
std::function<void(const std::span<U>&, const std::span<const std::uint32_t>&,
std::int32_t, int)>
get_dof_transformation_function(bool inverse = false, bool transpose = false,
bool scalar_element = false) const
get_pre_dof_transformation_function(bool inverse = false,
bool transpose = false,
bool scalar_element = false) const
{
if (!needs_dof_transformations())
{
Expand All @@ -289,7 +290,7 @@ class FiniteElement
for (std::size_t i = 0; i < _sub_elements.size(); ++i)
{
sub_element_functions.push_back(
_sub_elements[i]->template get_dof_transformation_function<U>(
_sub_elements[i]->template get_pre_dof_transformation_function<U>(
inverse, transpose));
dims.push_back(_sub_elements[i]->space_dimension());
}
Expand All @@ -316,7 +317,7 @@ class FiniteElement
const std::span<const std::uint32_t>&,
std::int32_t, int)>
sub_function
= _sub_elements[0]->template get_dof_transformation_function<U>(
= _sub_elements[0]->template get_pre_dof_transformation_function<U>(
inverse, transpose);
const int ebs = _bs;
return
Expand All @@ -334,16 +335,17 @@ class FiniteElement
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size)
{
apply_inverse_transpose_dof_transformation(data, cell_info[cell],
block_size);
pre_apply_inverse_transpose_dof_transformation(data, cell_info[cell],
block_size);
};
}
else
{
return [this](const std::span<U>& data,
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size) {
apply_transpose_dof_transformation(data, cell_info[cell], block_size);
pre_apply_transpose_dof_transformation(data, cell_info[cell],
block_size);
};
}
}
Expand All @@ -354,15 +356,16 @@ class FiniteElement
return [this](const std::span<U>& data,
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size) {
apply_inverse_dof_transformation(data, cell_info[cell], block_size);
pre_apply_inverse_dof_transformation(data, cell_info[cell],
block_size);
};
}
else
{
return [this](const std::span<U>& data,
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size)
{ apply_dof_transformation(data, cell_info[cell], block_size); };
{ pre_apply_dof_transformation(data, cell_info[cell], block_size); };
}
}
}
Expand All @@ -388,10 +391,9 @@ class FiniteElement
template <typename U>
std::function<void(const std::span<U>&, const std::span<const std::uint32_t>&,
std::int32_t, int)>
get_dof_transformation_to_transpose_function(bool inverse = false,
bool transpose = false,
bool scalar_element
= false) const
get_post_dof_transformation_function(bool inverse = false,
bool transpose = false,
bool scalar_element = false) const
{
if (!needs_dof_transformations())
{
Expand All @@ -415,7 +417,7 @@ class FiniteElement
{
sub_element_functions.push_back(
_sub_elements[i]
->template get_dof_transformation_to_transpose_function<U>(
->template get_post_dof_transformation_function<U>(
inverse, transpose));
}

Expand All @@ -440,7 +442,7 @@ class FiniteElement
const std::span<const std::uint32_t>&,
std::int32_t, int)>
sub_function
= _sub_elements[0]->template get_dof_transformation_function<U>(
= _sub_elements[0]->template get_pre_dof_transformation_function<U>(
inverse, transpose);
return [this,
sub_function](const std::span<U>& data,
Expand All @@ -466,18 +468,17 @@ class FiniteElement
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size)
{
apply_inverse_transpose_dof_transformation_to_transpose(
data, cell_info[cell], block_size);
post_apply_inverse_transpose_dof_transformation(data, cell_info[cell],
block_size);
};
}
else
{
return [this](const std::span<U>& data,
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size)
{
apply_transpose_dof_transformation_to_transpose(data, cell_info[cell],
block_size);
std::int32_t cell, int block_size) {
post_apply_transpose_dof_transformation(data, cell_info[cell],
block_size);
};
}
}
Expand All @@ -487,20 +488,17 @@ class FiniteElement
{
return [this](const std::span<U>& data,
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size)
{
apply_inverse_dof_transformation_to_transpose(data, cell_info[cell],
block_size);
std::int32_t cell, int block_size) {
post_apply_inverse_dof_transformation(data, cell_info[cell],
block_size);
};
}
else
{
return [this](const std::span<U>& data,
const std::span<const std::uint32_t>& cell_info,
std::int32_t cell, int block_size) {
apply_dof_transformation_to_transpose(data, cell_info[cell],
block_size);
};
std::int32_t cell, int block_size)
{ post_apply_dof_transformation(data, cell_info[cell], block_size); };
}
}
}
Expand All @@ -512,12 +510,12 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void apply_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
void pre_apply_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_dof_transformation(data, block_size, cell_permutation);
_element->pre_apply_dof_transformation(data, block_size, cell_permutation);
}

/// Apply inverse transpose transformation to some data. For
Expand All @@ -530,13 +528,13 @@ class FiniteElement
/// @param[in] block_size The block_size of the input data
template <typename U>
void
apply_inverse_transpose_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
pre_apply_inverse_transpose_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_inverse_transpose_dof_transformation(data, block_size,
cell_permutation);
_element->pre_apply_inverse_transpose_dof_transformation(data, block_size,
cell_permutation);
}

/// Apply transpose transformation to some data. For VectorElements,
Expand All @@ -547,13 +545,13 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void apply_transpose_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
void pre_apply_transpose_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_transpose_dof_transformation(data, block_size,
cell_permutation);
_element->pre_apply_transpose_dof_transformation(data, block_size,
cell_permutation);
}

/// Apply inverse transformation to some data. For VectorElements,
Expand All @@ -564,13 +562,13 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void apply_inverse_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
void pre_apply_inverse_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_inverse_dof_transformation(data, block_size,
cell_permutation);
_element->pre_apply_inverse_dof_transformation(data, block_size,
cell_permutation);
}

/// Apply DOF transformation to some transposed data
Expand All @@ -580,13 +578,12 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void apply_dof_transformation_to_transpose(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
void post_apply_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_dof_transformation_to_transpose(data, block_size,
cell_permutation);
_element->post_apply_dof_transformation(data, block_size, cell_permutation);
}

/// Apply inverse of DOF transformation to some transposed data.
Expand All @@ -596,14 +593,13 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void
apply_inverse_dof_transformation_to_transpose(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
void post_apply_inverse_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_inverse_dof_transformation_to_transpose(data, block_size,
cell_permutation);
_element->post_apply_inverse_dof_transformation(data, block_size,
cell_permutation);
}

/// Apply transpose of transformation to some transposed data.
Expand All @@ -613,13 +609,13 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void apply_transpose_dof_transformation_to_transpose(
const std::span<U>& data, std::uint32_t cell_permutation,
int block_size) const
void post_apply_transpose_dof_transformation(const std::span<U>& data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_transpose_dof_transformation_to_transpose(data, block_size,
cell_permutation);
_element->post_apply_transpose_dof_transformation(data, block_size,
cell_permutation);
}

/// Apply inverse transpose transformation to some transposed data
Expand All @@ -629,13 +625,13 @@ class FiniteElement
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
template <typename U>
void apply_inverse_transpose_dof_transformation_to_transpose(
void post_apply_inverse_transpose_dof_transformation(
const std::span<U>& data, std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->apply_inverse_transpose_dof_transformation_to_transpose(
data, block_size, cell_permutation);
_element->post_apply_inverse_transpose_dof_transformation(data, block_size,
cell_permutation);
}

/// Permute the DOFs of the element
Expand Down
3 changes: 2 additions & 1 deletion cpp/dolfinx/fem/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ class Function
= element->basix_element().template map_fn<xu_t, xU_t, xJ_t, xK_t>();

auto apply_dof_transformation
= element->template get_dof_transformation_function<geometry_type>();
= element
->template get_pre_dof_transformation_function<geometry_type>();
const std::size_t num_basis_values = space_dimension * reference_value_size;

for (std::size_t p = 0; p < cells.size(); ++p)
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/fem/FunctionSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class FunctionSpace
}

auto apply_dof_transformation
= _element->template get_dof_transformation_function<T>();
= _element->template get_pre_dof_transformation_function<T>();

const std::array<std::size_t, 4> phi_shape
= cmap.tabulate_shape(0, Xshape[0]);
Expand Down
Loading
Loading