Skip to content

Commit

Permalink
Merge branch 'main' into jhale/release-instructions-tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Apr 19, 2024
2 parents df3fb4a + c8ca7b6 commit 23edb27
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 108 deletions.
13 changes: 6 additions & 7 deletions cpp/dolfinx/fem/CoordinateElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ CoordinateElement<T>::CoordinateElement(
template <std::floating_point T>
CoordinateElement<T>::CoordinateElement(mesh::CellType celltype, int degree,
basix::element::lagrange_variant type)
: CoordinateElement(std::make_shared<basix::FiniteElement<T>>(
basix::create_element<T>(basix::element::family::P,
mesh::cell_type_to_basix_type(celltype),
degree, type,
basix::element::dpc_variant::unset, false)))
: CoordinateElement(
std::make_shared<basix::FiniteElement<T>>(basix::create_element<T>(
basix::element::family::P, mesh::cell_type_to_basix_type(celltype),
degree, type, basix::element::dpc_variant::unset, false)))
{
// Do nothing
}
Expand Down Expand Up @@ -164,15 +163,15 @@ void CoordinateElement<T>::permute_dofs(std::span<std::int32_t> dofs,
std::uint32_t cell_perm) const
{
assert(_element);
_element->permute_dofs(dofs, cell_perm);
_element->permute(dofs, cell_perm);
}
//-----------------------------------------------------------------------------
template <std::floating_point T>
void CoordinateElement<T>::unpermute_dofs(std::span<std::int32_t> dofs,
std::uint32_t cell_perm) const
{
assert(_element);
_element->unpermute_dofs(dofs, cell_perm);
_element->permute_inv(dofs, cell_perm);
}
//-----------------------------------------------------------------------------
template <std::floating_point T>
Expand Down
4 changes: 2 additions & 2 deletions cpp/dolfinx/fem/FiniteElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ template <std::floating_point T>
void FiniteElement<T>::permute_dofs(std::span<std::int32_t> doflist,
std::uint32_t cell_permutation) const
{
_element->permute_dofs(doflist, cell_permutation);
_element->permute(doflist, cell_permutation);
}
//-----------------------------------------------------------------------------
template <std::floating_point T>
void FiniteElement<T>::unpermute_dofs(std::span<std::int32_t> doflist,
std::uint32_t cell_permutation) const
{
_element->unpermute_dofs(doflist, cell_permutation);
_element->permute_inv(doflist, cell_permutation);
}
//-----------------------------------------------------------------------------
/// @cond
Expand Down
163 changes: 84 additions & 79 deletions cpp/dolfinx/fem/FiniteElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ class FiniteElement
/// @return True if DOF transformations are required
bool needs_dof_permutations() const noexcept;

/// Return a function that applies DOF transformation to some data.
/// @brief Return a function that applies DOF transformation operator
/// `T to some data.
///
/// The returned function will take four inputs:
/// The signature of the returned function has four arguments:
/// - [in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// - [in] cell_info Permutation data for the cell. The size of this
Expand All @@ -265,9 +266,8 @@ class FiniteElement
template <typename U>
std::function<void(std::span<U>, std::span<const std::uint32_t>, std::int32_t,
int)>
get_pre_dof_transformation_function(doftransform ttype
= doftransform::standard,
bool scalar_element = false) const
dof_transformation_function(doftransform ttype = doftransform::standard,
bool scalar_element = false) const
{
if (!needs_dof_transformations())
{
Expand All @@ -290,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_pre_dof_transformation_function<U>(
_sub_elements[i]->template dof_transformation_function<U>(
ttype));
dims.push_back(_sub_elements[i]->space_dimension());
}
Expand All @@ -315,7 +315,7 @@ class FiniteElement
const std::function<void(std::span<U>, std::span<const std::uint32_t>,
std::int32_t, int)>
sub_function
= _sub_elements[0]->template get_pre_dof_transformation_function<U>(
= _sub_elements[0]->template dof_transformation_function<U>(
ttype);
const int ebs = _bs;
return [ebs, sub_function](std::span<U> data,
Expand Down Expand Up @@ -352,10 +352,11 @@ class FiniteElement
throw std::runtime_error("Unknown transformation type");
}
}
/// Return a function that applies DOF transformation to some
/// transposed data

/// @brief Return a function that applies DOF transformation to some
/// transposed data.
///
/// The returned function will take three inputs:
/// The signature of the returned function has four arguments:
/// - [in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// - [in] cell_info Permutation data for the cell. The size of this
Expand Down Expand Up @@ -416,7 +417,7 @@ class FiniteElement
const std::function<void(std::span<U>, std::span<const std::uint32_t>,
std::int32_t, int)>
sub_function
= _sub_elements[0]->template get_pre_dof_transformation_function<U>(
= _sub_elements[0]->template dof_transformation_function<U>(
ttype);
return [this, sub_function](std::span<U> data,
std::span<const std::uint32_t> cell_info,
Expand Down Expand Up @@ -463,7 +464,7 @@ class FiniteElement
}
}

/// Apply DOF transformation to some data
/// @brief Apply DOF transformation to some data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
Expand All @@ -475,147 +476,151 @@ class FiniteElement
int block_size) const
{
assert(_element);
_element->pre_apply_dof_transformation(data, block_size, cell_permutation);
_element->T_apply(data, block_size, cell_permutation);
}

/// Apply inverse transpose transformation to some data. For
/// VectorElements, this applies the transformations for the scalar
/// subelement.
/// @brief Apply inverse transpose transformation to some data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// For VectorElements, this applies the transformations for the
/// scalar subelement.
///
/// @param[in,out] data The data to be transformed. This data is
/// flattened with row-major layout, `shape=(num_dofs, block_size)`.
/// @param[in] cell_permutation Permutation data for the cell.
/// @param[in] n Block_size of the input data.
template <typename U>
void pre_apply_inverse_transpose_dof_transformation(
std::span<U> data, std::uint32_t cell_permutation, int block_size) const
std::span<U> data, std::uint32_t cell_permutation, int n) const
{
assert(_element);
_element->pre_apply_inverse_transpose_dof_transformation(data, block_size,
cell_permutation);
_element->Tt_inv_apply(data, n, cell_permutation);
}

/// Apply transpose transformation to some data. For VectorElements,
/// this applies the transformations for the scalar subelement.
/// @brief Apply transpose transformation to some data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// For VectorElements, this applies the transformations for the
/// scalar subelement.
///
/// @param[in,out] data The data to be transformed. This data is
/// flattened with row-major layout, `shape=(num_dofs, block_size)`.
/// @param[in] cell_permutation Permutation data for the cell.
/// @param[in] block_size The block size of the input data.
template <typename U>
void pre_apply_transpose_dof_transformation(std::span<U> data,
std::uint32_t cell_permutation,
int block_size) const
{
assert(_element);
_element->pre_apply_transpose_dof_transformation(data, block_size,
cell_permutation);
_element->Tt_apply(data, block_size, cell_permutation);
}

/// Apply inverse transformation to some data. For VectorElements,
/// this applies the transformations for the scalar subelement.
/// @brief Apply inverse transformation to some data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// For VectorElements, this applies the transformations for the
/// scalar subelement.
///
/// @param[in,out] data The data to be transformed. This data is
/// flattened with row-major layout, `shape=(num_dofs, block_size)`.
/// @param[in] cell_permutation Permutation data for the cell.
/// @param[in] n Block size of the input data.
template <typename U>
void pre_apply_inverse_dof_transformation(std::span<U> data,
std::uint32_t cell_permutation,
int block_size) const
int n) const
{
assert(_element);
_element->pre_apply_inverse_dof_transformation(data, block_size,
cell_permutation);
_element->Tinv_apply(data, n, cell_permutation);
}

/// Apply DOF transformation to some transposed data
/// @brief Apply DOF transformation to some transposed data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in,out] data The data to be transformed. This data is
/// flattened with row-major layout, `shape=(num_dofs, block_size)`.
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// @param[in] n Block size of the input data
template <typename U>
void post_apply_dof_transformation(std::span<U> data,
std::uint32_t cell_permutation,
int block_size) const
int n) const
{
assert(_element);
_element->post_apply_dof_transformation(data, block_size, cell_permutation);
_element->T_post_apply(data, n, cell_permutation);
}

/// Apply inverse of DOF transformation to some transposed data.
/// @brief Apply inverse of DOF transformation to some transposed
/// data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in,out] data Data to be transformed. This data is flattened
/// with row-major layout, `shape=(num_dofs, block_size)`/
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// @param[in] n Block size of the input data
template <typename U>
void post_apply_inverse_dof_transformation(std::span<U> data,
std::uint32_t cell_permutation,
int block_size) const
int n) const
{
assert(_element);
_element->post_apply_inverse_dof_transformation(data, block_size,
cell_permutation);
_element->Tinv_post_apply(data, n, cell_permutation);
}

/// Apply transpose of transformation to some transposed data.
/// @brief Apply transpose of transformation to some transposed data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in,out] data Data to be transformed. This data is flattened
/// with row-major layout, `shape=(num_dofs, block_size)`.
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// @param[in] n Block size of the input data.
template <typename U>
void post_apply_transpose_dof_transformation(std::span<U> data,
std::uint32_t cell_permutation,
int block_size) const
int n) const
{
assert(_element);
_element->post_apply_transpose_dof_transformation(data, block_size,
cell_permutation);
_element->Tt_post_apply(data, n, cell_permutation);
}

/// Apply inverse transpose transformation to some transposed data
/// @brief Apply inverse transpose transformation to some transposed
/// data.
///
/// @param[in,out] data The data to be transformed. This data is flattened
/// with row-major layout, shape=(num_dofs, block_size)
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in] block_size The block_size of the input data
/// @param[in,out] data Data to be transformed. This data is flattened
/// with row-major layout, `shape=(num_dofs, block_size)`.
/// @param[in] cell_permutation Permutation data for the cell.
/// @param[in] n Block size of the input data.
template <typename U>
void post_apply_inverse_transpose_dof_transformation(
std::span<U> data, std::uint32_t cell_permutation, int block_size) const
std::span<U> data, std::uint32_t cell_permutation, int n) const
{
assert(_element);
_element->post_apply_inverse_transpose_dof_transformation(data, block_size,
cell_permutation);
_element->Tt_inv_post_apply(data, n, cell_permutation);
}

/// Permute the DOFs of the element
/// @brief Permute the DOFs of the element.
///
/// @param[in,out] doflist The numbers of the DOFs, a span of length num_dofs
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in,out] doflist The numbers of the DOFs, a span of length
/// `num_dofs`.
/// @param[in] cell_permutation Permutation data for the cell.
void permute_dofs(std::span<std::int32_t> doflist,
std::uint32_t cell_permutation) const;

/// Unpermute the DOFs of the element
/// @brief Unpermute the DOFs of the element.
///
/// @param[in,out] doflist The numbers of the DOFs, a span of length num_dofs
/// @param[in] cell_permutation Permutation data for the cell
/// @param[in,out] doflist Numbers of the DOFs, a span of length
/// `num_dofs`.
/// @param[in] cell_permutation Permutation data for the cell.
void unpermute_dofs(std::span<std::int32_t> doflist,
std::uint32_t cell_permutation) const;

/// Return a function that applies DOF permutation to some data
/// @brief Return a function that applies DOF permutation to some
/// data.
///
/// The returned function will take three inputs:
/// The signature of the returned function has three arguments:
/// - [in,out] doflist The numbers of the DOFs, a span of length num_dofs
/// - [in] cell_permutation Permutation data for the cell
/// - [in] block_size The block_size of the input data
///
/// @param[in] inverse Indicates whether the inverse transformations
/// should be returned
/// @param[in] scalar_element Indicated whether the scalar
/// transformations should be returned for a vector element
/// should be returned.
/// @param[in] scalar_element Indicates whether the scalar
/// transformations should be returned for a vector element.
std::function<void(std::span<std::int32_t>, std::uint32_t)>
get_dof_permutation_function(bool inverse = false,
bool scalar_element = false) const;
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/fem/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ class Function

auto apply_dof_transformation
= element
->template get_pre_dof_transformation_function<geometry_type>();
->template 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 @@ -261,7 +261,7 @@ class FunctionSpace

auto apply_dof_transformation
= _element
->template get_pre_dof_transformation_function<geometry_type>();
->template dof_transformation_function<geometry_type>();

const std::array<std::size_t, 4> phi_shape
= cmap.tabulate_shape(0, Xshape[0]);
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/fem/assemble_matrix_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void assemble_matrix(
auto element1 = a.function_spaces().at(1)->element();
assert(element1);
fem::DofTransformKernel<T> auto P0
= element0->template get_pre_dof_transformation_function<T>();
= element0->template dof_transformation_function<T>();
fem::DofTransformKernel<T> auto P1T
= element1->template get_post_dof_transformation_function<T>(
FiniteElement<U>::doftransform::transpose);
Expand Down
4 changes: 2 additions & 2 deletions cpp/dolfinx/fem/assemble_vector_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ void lift_bc(std::span<T> b, const Form<T, U>& a, mdspan2_t x_dofmap,
}

fem::DofTransformKernel<T> auto P0
= element0->template get_pre_dof_transformation_function<T>();
= element0->template dof_transformation_function<T>();
fem::DofTransformKernel<T> auto P1T
= element1->template get_post_dof_transformation_function<T>(
FiniteElement<U>::doftransform::transpose);
Expand Down Expand Up @@ -1144,7 +1144,7 @@ void assemble_vector(
const int bs = dofmap->bs();

fem::DofTransformKernel<T> auto P0
= element->template get_pre_dof_transformation_function<T>();
= element->template dof_transformation_function<T>();

std::span<const std::uint32_t> cell_info0;
if (element->needs_dof_transformations() or L.needs_facet_permutations())
Expand Down
Loading

0 comments on commit 23edb27

Please sign in to comment.