Skip to content

Simplify tabulation through dolfinx::FiniteElement - #1565

Merged
garth-wells merged 9 commits into
mainfrom
dokken/finite-element-tabulate
Jun 23, 2021
Merged

Simplify tabulation through dolfinx::FiniteElement#1565
garth-wells merged 9 commits into
mainfrom
dokken/finite-element-tabulate

Conversation

@jorgensd

Copy link
Copy Markdown
Member

As DOLFINx uses xtensor there is no point of distinguishing between tabulation of 0th order and nth order derivatives of the basis function.

Also makes it possible to tabulate the derivative of basis function in DOLFINx (useful for custom kernels).

@garth-wells
garth-wells force-pushed the dokken/finite-element-tabulate branch from 4786ca4 to 1bdf269 Compare June 22, 2021 06:43
Comment thread cpp/dolfinx/fem/Function.h Outdated
/// dimension] containing the points at the reference element
/// @param[in] order The number of derivatives (up to and including this
/// order) to tabulate for.
void tabulate(xt::xtensor<double, 4>& values, const xt::xtensor<double, 2>& X,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also change the order of parameters in CoordinateElement::tabulate for consistency?

Comment on lines +305 to +306
auto basis_reference_values = xt::view(basis_derivatives_reference_values,
0, xt::all(), xt::all(), xt::all());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little issue is that this will be copied further down in each loop iteration when passed to element->transform_reference_basis since transform_reference_basis expects a xt::xarray.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not correct?
Transform reference basis takes an xtensor:

void FiniteElement::transform_reference_basis(
xt::xtensor<double, 3>& values,
const xt::xtensor<double, 3>& reference_values,
const xt::xtensor<double, 3>& J, const xtl::span<const double>& detJ,
const xt::xtensor<double, 3>& K) const
{
assert(_element);
_element->map_push_forward_m(reference_values, J, detJ, K, values);
}

and
map_push_forward_m takes an xtensor: https://github.com/FEniCS/basix/blob/266c9b486d6a8e6d00c118cb05f499690cd98679/cpp/basix/finite-element.h#L317

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it takes a xt::xtensor<double, 3>, but xt::view isn't a xt::xtensor<double, 3> hence a copy will be made.

@garth-wells
garth-wells merged commit 4186d68 into main Jun 23, 2021
@garth-wells
garth-wells deleted the dokken/finite-element-tabulate branch June 23, 2021 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants