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 highest_degree and highest_complete_degree #731

Merged
merged 4 commits into from
Nov 1, 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
4 changes: 2 additions & 2 deletions .github/workflows/dolfin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
if: github.event_name != 'workflow_dispatch'
run: |
python3 -m pip install git+https://github.com/FEniCS/ufl.git
python3 -m pip install git+https://github.com/FEniCS/ffcx.git
python3 -m pip install git+https://github.com/FEniCS/ffcx.git@mscroggs/embedded-degree
- name: Install FEniCS Python components
if: github.event_name == 'workflow_dispatch'
run: |
Expand All @@ -64,7 +64,7 @@ jobs:
with:
path: ./dolfinx
repository: FEniCS/dolfinx
ref: main
ref: mscroggs/embedded-degree
- name: Get DOLFINx
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ffcx-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
path: ./ffcx
repository: FEniCS/ffcx
ref: main
ref: mscroggs/embedded-degree
- name: Get FFCx source (specified branch)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
Expand Down
5 changes: 2 additions & 3 deletions cpp/basix/docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,14 @@ Create a custom finite element
map_type: The type of map to be used to map values from the reference to a cell
sobolev_space: The underlying Sobolev space for the element
discontinuous: Indicates whether or not this is the discontinuous version of the element
highest_complete_degree: The highest degree n such that a Lagrange (or vector Lagrange) element of degree n is a subspace of this element
highest_degree: The degree of a polynomial in this element's polyset
embedded_subdegree: The highest degree n such that a Lagrange (or vector Lagrange) element of degree n is a subspace of this element
embedded_superdegree: The degree of a polynomial in this element's polyset
poly_type: The type of polyset to use for this element

Returns:
A custom finite element
)";


const std::string
create_element__family_cell_degree_lvariant_dvariant_discontinuous_dof_ordering
= R"(
Expand Down
47 changes: 25 additions & 22 deletions cpp/basix/finite-element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,12 @@ FiniteElement<T> basix::create_custom_element(
const std::array<std::vector<impl::mdspan_t<const T, 2>>, 4>& x,
const std::array<std::vector<impl::mdspan_t<const T, 4>>, 4>& M,
int interpolation_nderivs, maps::type map_type,
sobolev::space sobolev_space, bool discontinuous,
int highest_complete_degree, int highest_degree, polyset::type poly_type)
sobolev::space sobolev_space, bool discontinuous, int embedded_subdegree,
int embedded_superdegree, polyset::type poly_type)
{
// Check that inputs are valid
const std::size_t psize = polyset::dim(cell_type, poly_type, highest_degree);
const std::size_t psize
= polyset::dim(cell_type, poly_type, embedded_superdegree);
const std::size_t value_size = std::reduce(
value_shape.begin(), value_shape.end(), 1, std::multiplies{});
const std::size_t deriv_count
Expand Down Expand Up @@ -501,17 +502,17 @@ FiniteElement<T> basix::create_custom_element(

auto [dualmatrix, dualshape]
= compute_dual_matrix(cell_type, poly_type, wcoeffs_ortho, x, M,
highest_degree, interpolation_nderivs);
embedded_superdegree, interpolation_nderivs);
if (math::is_singular(mdspan_t<const T, 2>(dualmatrix.data(), dualshape)))
{
throw std::runtime_error(
"Dual matrix is singular, there is an error in your inputs");
}

return basix::FiniteElement<T>(
element::family::custom, cell_type, poly_type, highest_degree,
element::family::custom, cell_type, poly_type, embedded_superdegree,
value_shape, wcoeffs_ortho, x, M, interpolation_nderivs, map_type,
sobolev_space, discontinuous, highest_complete_degree, highest_degree,
sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree,
element::lagrange_variant::unset, element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -539,9 +540,9 @@ FiniteElement<F>::FiniteElement(
const std::array<std::vector<mdspan_t<const F, 2>>, 4>& x,
const std::array<std::vector<mdspan_t<const F, 4>>, 4>& M,
int interpolation_nderivs, maps::type map_type,
sobolev::space sobolev_space, bool discontinuous,
int highest_complete_degree, int highest_degree,
element::lagrange_variant lvariant, element::dpc_variant dvariant,
sobolev::space sobolev_space, bool discontinuous, int embedded_subdegree,
int embedded_superdegree, element::lagrange_variant lvariant,
element::dpc_variant dvariant,
std::vector<std::tuple<std::vector<FiniteElement<F>>, std::vector<int>>>
tensor_factors,
std::vector<int> dof_ordering)
Expand All @@ -550,11 +551,11 @@ FiniteElement<F>::FiniteElement(
_cell_subentity_types(cell::subentity_types(cell_type)), _family(family),
_lagrange_variant(lvariant), _dpc_variant(dvariant), _degree(degree),
_interpolation_nderivs(interpolation_nderivs),
_highest_degree(highest_degree),
_highest_complete_degree(highest_complete_degree),
_value_shape(value_shape), _map_type(map_type),
_sobolev_space(sobolev_space), _discontinuous(discontinuous),
_tensor_factors(tensor_factors), _dof_ordering(dof_ordering)
_embedded_superdegree(embedded_superdegree),
_embedded_subdegree(embedded_subdegree), _value_shape(value_shape),
_map_type(map_type), _sobolev_space(sobolev_space),
_discontinuous(discontinuous), _tensor_factors(tensor_factors),
_dof_ordering(dof_ordering)
{
// Check that discontinuous elements only have DOFs on interior
if (discontinuous)
Expand All @@ -577,8 +578,9 @@ FiniteElement<F>::FiniteElement(
wcoeffs_b.begin());

_wcoeffs = {wcoeffs_b, {wcoeffs.extent(0), wcoeffs.extent(1)}};
_dual_matrix = compute_dual_matrix<F>(cell_type, poly_type, wcoeffs, x, M,
highest_degree, interpolation_nderivs);
_dual_matrix
= compute_dual_matrix<F>(cell_type, poly_type, wcoeffs, x, M,
embedded_superdegree, interpolation_nderivs);

// Copy x
for (std::size_t i = 0; i < x.size(); ++i)
Expand Down Expand Up @@ -647,7 +649,7 @@ FiniteElement<F>::FiniteElement(
_entity_transformations = doftransforms::compute_entity_transformations(
cell_type, x, M,
mdspan_t<const F, 2>(_coeffs.first.data(), _coeffs.second),
highest_degree, value_size, map_type, poly_type);
embedded_superdegree, value_size, map_type, poly_type);

const std::size_t nderivs
= polyset::nderivs(cell_type, interpolation_nderivs);
Expand Down Expand Up @@ -978,9 +980,9 @@ bool FiniteElement<F>::operator==(const FiniteElement& e) const
and map_type() == e.map_type()
and sobolev_space() == e.sobolev_space()
and value_shape() == e.value_shape()
and highest_degree() == e.highest_degree()
and highest_complete_degree() == e.highest_complete_degree()
and coeff_equal and entity_dofs() == e.entity_dofs();
and embedded_superdegree() == e.embedded_superdegree()
and embedded_subdegree() == e.embedded_subdegree() and coeff_equal
and entity_dofs() == e.entity_dofs();
}
else
{
Expand Down Expand Up @@ -1026,12 +1028,13 @@ void FiniteElement<F>::tabulate(int nd, impl::mdspan_t<const F, 2> x,
}

const std::size_t psize
= polyset::dim(_cell_type, _poly_type, _highest_degree);
= polyset::dim(_cell_type, _poly_type, _embedded_superdegree);
const std::array<std::size_t, 3> bsize
= {(std::size_t)polyset::nderivs(_cell_type, nd), psize, x.extent(0)};
std::vector<F> basis_b(bsize[0] * bsize[1] * bsize[2]);
mdspan_t<F, 3> basis(basis_b.data(), bsize);
polyset::tabulate(basis, _cell_type, _poly_type, _highest_degree, nd, x);
polyset::tabulate(basis, _cell_type, _poly_type, _embedded_superdegree, nd,
x);
const int vs = std::accumulate(_value_shape.begin(), _value_shape.end(), 1,
std::multiplies{});

Expand Down
26 changes: 13 additions & 13 deletions cpp/basix/finite-element.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ class FiniteElement
/// element
/// @param[in] discontinuous Indicates whether or not this is the
/// discontinuous version of the element
/// @param[in] highest_complete_degree The highest degree n such that
/// @param[in] embedded_subdegree The highest degree n such that
/// a Lagrange (or vector Lagrange) element of degree n is a subspace
/// of this element
/// @param[in] highest_degree The highest degree n such that at least
/// @param[in] embedded_superdegree The highest degree n such that at least
/// one polynomial of degree n is included in this element's
/// polymonial set
/// @param[in] lvariant The Lagrange variant of the element
Expand All @@ -323,9 +323,9 @@ class FiniteElement
const std::array<std::vector<mdspan_t<const F, 2>>, 4>& x,
const std::array<std::vector<mdspan_t<const F, 4>>, 4>& M,
int interpolation_nderivs, maps::type map_type,
sobolev::space sobolev_space, bool discontinuous,
int highest_complete_degree, int highest_degree,
element::lagrange_variant lvariant, element::dpc_variant dvariant,
sobolev::space sobolev_space, bool discontinuous, int embedded_subdegree,
int embedded_superdegree, element::lagrange_variant lvariant,
element::dpc_variant dvariant,
std::vector<std::tuple<std::vector<FiniteElement>, std::vector<int>>>
tensor_factors
= {},
Expand Down Expand Up @@ -498,12 +498,12 @@ class FiniteElement
/// element is contained in a Lagrange (or vector Lagrange) element of
/// degree `n`.
/// @return Polynomial degree
int highest_degree() const { return _highest_degree; }
int embedded_superdegree() const { return _embedded_superdegree; }

/// Highest degree `n` such that a Lagrange (or vector Lagrange)
/// element of degree n is a subspace of this element.
/// @return Polynomial degree
int highest_complete_degree() const { return _highest_complete_degree; }
int embedded_subdegree() const { return _embedded_subdegree; }

/// The element value tensor shape, e.g. returning {} for scalars, {3}
/// for vectors in 3D, {2, 2} for a rank-2 tensor in 2D.
Expand Down Expand Up @@ -1182,10 +1182,10 @@ class FiniteElement
int _interpolation_nderivs;

// Highest degree polynomial in element's polyset
int _highest_degree;
int _embedded_superdegree;

// Highest degree space that is a subspace of element's polyset
int _highest_complete_degree;
int _embedded_subdegree;

// Value shape
std::vector<std::size_t> _value_shape;
Expand Down Expand Up @@ -1314,10 +1314,10 @@ class FiniteElement
/// @param[in] sobolev_space The underlying Sobolev space for the element
/// @param[in] discontinuous Indicates whether or not this is the
/// discontinuous version of the element
/// @param[in] highest_complete_degree The highest degree n such that a
/// @param[in] embedded_subdegree The highest degree n such that a
/// Lagrange (or vector Lagrange) element of degree n is a subspace of this
/// element
/// @param[in] highest_degree The degree of a polynomial in this element's
/// @param[in] embedded_superdegree The degree of a polynomial in this element's
/// polyset
/// @param[in] poly_type The type of polyset to use for this element
/// @return A custom finite element
Expand All @@ -1328,8 +1328,8 @@ FiniteElement<T> create_custom_element(
const std::array<std::vector<impl::mdspan_t<const T, 2>>, 4>& x,
const std::array<std::vector<impl::mdspan_t<const T, 4>>, 4>& M,
int interpolation_nderivs, maps::type map_type,
sobolev::space sobolev_space, bool discontinuous,
int highest_complete_degree, int highest_degree, polyset::type poly_type);
sobolev::space sobolev_space, bool discontinuous, int embedded_subdegree,
int embedded_superdegree, polyset::type poly_type);

/// Create an element using a given Lagrange variant and a given DPC variant
/// @param[in] family The element family
Expand Down
28 changes: 14 additions & 14 deletions cpp/docs.template
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,24 @@ Returns:
)";

{{DOCTYPE}} create_custom_element = R"(
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > doc}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > doc}}

Args:
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > cell_type}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > value_shape}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > wcoeffs}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > x}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > M}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > interpolation_nderivs}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > map_type}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > sobolev_space}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > discontinuous}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > highest_complete_degree}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > highest_degree}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > param > poly_type}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > cell_type}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > value_shape}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > wcoeffs}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > x}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > M}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > interpolation_nderivs}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > map_type}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > sobolev_space}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > discontinuous}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > embedded_subdegree}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > embedded_superdegree}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > param > poly_type}}

Returns:
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, highest_complete_degree, highest_degree, poly_type) > return}}
{{finite-element.h > create_custom_element(cell_type, value_shape, wcoeffs, x, M, interpolation_nderivs, map_type, sobolev_space, discontinuous, embedded_subdegree, embedded_superdegree, poly_type) > return}}
)";


Expand Down
4 changes: 2 additions & 2 deletions python/basix/_basixcpp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class FiniteElement:
@property
def has_tensor_product_factorisation(self) -> bool: ...
@property
def highest_complete_degree(self) -> int: ...
def embedded_subdegree(self) -> int: ...
@property
def highest_degree(self) -> int: ...
def embedded_superdegree(self) -> int: ...
@property
def interpolation_is_identity(self) -> bool: ...
@property
Expand Down
Loading
Loading