Skip to content

Commit 42402da

Browse files
authored
Implement iso element on quads (#683)
1 parent c6d880e commit 42402da

10 files changed

+331
-26
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ The following elements are supported on a quadrilateral:
111111
- [Bubble](https://defelement.com/elements/bubble.html)
112112
- [DPC](https://defelement.com/elements/dpc.html)
113113
- [Serendipity](https://defelement.com/elements/serendipity.html)
114+
- [iso](https://defelement.com/elements/p1-iso-p2.html)
114115

115116

116117
### Tetrahedron

cpp/basix/dof-transformations.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ std::pair<std::vector<T>, std::array<std::size_t, 2>> compute_transformation(
317317
mdspan_t<const T, 2> coeffs, const mdarray_t<T, 2>& J, T detJ,
318318
const mdarray_t<T, 2>& K,
319319
const std::function<std::array<T, 3>(std::span<const T>)> map_point,
320-
int degree, int tdim, int entity, std::size_t vs, const maps::type map_type)
320+
int degree, int tdim, int entity, std::size_t vs, const maps::type map_type,
321+
const polyset::type ptype)
321322
{
322323
if (x[tdim].size() == 0 or x[tdim][entity].extent(0) == 0)
323324
return {{}, {0, 0}};
@@ -327,7 +328,7 @@ std::pair<std::vector<T>, std::array<std::size_t, 2>> compute_transformation(
327328

328329
const std::size_t ndofs = imat.extent(0);
329330
const std::size_t npts = pts.extent(0);
330-
const int psize = polyset::dim(cell_type, polyset::type::standard, degree);
331+
const int psize = polyset::dim(cell_type, ptype, degree);
331332

332333
std::size_t dofstart = 0;
333334
for (int d = 0; d < tdim; ++d)
@@ -352,7 +353,7 @@ std::pair<std::vector<T>, std::array<std::size_t, 2>> compute_transformation(
352353
}
353354

354355
auto [polyset_vals_b, polyset_shape] = polyset::tabulate(
355-
cell_type, polyset::type::standard, degree, 0,
356+
cell_type, ptype, degree, 0,
356357
mdspan_t<const T, 2>(mapped_pts.data(), mapped_pts.extents()));
357358
assert(polyset_shape[0] == 1);
358359
mdspan_t<const T, 2> polyset_vals(polyset_vals_b.data(), polyset_shape[1],
@@ -424,7 +425,7 @@ doftransforms::compute_entity_transformations(
424425
std::experimental::mdspan<const T,
425426
std::experimental::dextents<std::size_t, 2>>
426427
coeffs,
427-
int degree, std::size_t vs, maps::type map_type)
428+
int degree, std::size_t vs, maps::type map_type, polyset::type ptype)
428429
{
429430
std::map<cell::type, std::pair<std::vector<T>, std::array<std::size_t, 3>>>
430431
out;
@@ -441,7 +442,7 @@ doftransforms::compute_entity_transformations(
441442
{
442443
auto [t2b, _]
443444
= compute_transformation(cell_type, x, M, coeffs, J, detJ, K, mapfn,
444-
degree, tdim, entity, vs, map_type);
445+
degree, tdim, entity, vs, map_type, ptype);
445446
transform.insert(transform.end(), t2b.begin(), t2b.end());
446447
}
447448

@@ -468,7 +469,7 @@ doftransforms::compute_entity_transformations(
468469
4>&,
469470
std::experimental::mdspan<const float,
470471
std::experimental::dextents<std::size_t, 2>>,
471-
int, std::size_t, maps::type);
472+
int, std::size_t, maps::type, polyset::type);
472473

473474
template std::map<cell::type,
474475
std::pair<std::vector<double>, std::array<std::size_t, 3>>>
@@ -484,6 +485,6 @@ doftransforms::compute_entity_transformations(
484485
4>&,
485486
std::experimental::mdspan<const double,
486487
std::experimental::dextents<std::size_t, 2>>,
487-
int, std::size_t, maps::type);
488+
int, std::size_t, maps::type, polyset::type);
488489
/// @endcond
489490
//-----------------------------------------------------------------------------

cpp/basix/dof-transformations.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "cell.h"
88
#include "maps.h"
99
#include "mdspan.hpp"
10+
#include "polyset.h"
1011
#include <array>
1112
#include <concepts>
1213
#include <map>
@@ -33,6 +34,7 @@ namespace basix::doftransforms
3334
/// @param[in] degree The degree of the element
3435
/// @param[in] vs The value size of the element
3536
/// @param[in] map_type The map type used by the element
37+
/// @param[in] ptype The polyset type used by the element
3638
/// @return Entity transformations. For each cell, the shape is
3739
/// (ntransformation, ndofs, ndofs)
3840
template <std::floating_point T>
@@ -48,6 +50,6 @@ compute_entity_transformations(
4850
std::experimental::mdspan<const T,
4951
std::experimental::dextents<std::size_t, 2>>
5052
coeffs,
51-
int degree, std::size_t vs, maps::type map_type);
53+
int degree, std::size_t vs, maps::type map_type, polyset::type ptype);
5254

5355
} // namespace basix::doftransforms

cpp/basix/e-lagrange.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1434,10 +1434,10 @@ FiniteElement<T> basix::element::create_iso(cell::type celltype, int degree,
14341434
lagrange_variant variant,
14351435
bool discontinuous)
14361436
{
1437-
if (celltype != cell::type::interval)
1437+
if (celltype != cell::type::interval && celltype != cell::type::quadrilateral)
14381438
{
1439-
throw std::runtime_error(
1440-
"Can currently only create iso elements on an interval");
1439+
throw std::runtime_error("Can currently only create iso elements on "
1440+
"intervals and quadrilaterals");
14411441
}
14421442

14431443
if (variant == lagrange_variant::unset)

cpp/basix/finite-element.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ FiniteElement<F>::FiniteElement(
658658
_entity_transformations = doftransforms::compute_entity_transformations(
659659
cell_type, x, M,
660660
mdspan_t<const F, 2>(_coeffs.first.data(), _coeffs.second),
661-
highest_degree, value_size, map_type);
661+
highest_degree, value_size, map_type, poly_type);
662662

663663
const std::size_t nderivs
664664
= polyset::nderivs(cell_type, interpolation_nderivs);

0 commit comments

Comments
 (0)