Skip to content

Commit

Permalink
Fixes #640. (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells authored Mar 1, 2023
1 parent 6c47355 commit caad923
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 67 deletions.
9 changes: 5 additions & 4 deletions cpp/basix/e-brezzi-douglas-marini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ FiniteElement element::create_bdm(cell::type celltype, int degree,

// The number of order (degree) scalar polynomials
const std::size_t ndofs = tdim * polyset::dim(celltype, degree);

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HDiv;
return FiniteElement(family::BDM, celltype, degree, {tdim},
impl::mdspan2_t(math::eye(ndofs).data(), ndofs, ndofs),
xview, Mview, 0, maps::type::contravariantPiola,
sobolev::space::HDiv, discontinuous, degree, degree,
lvariant, element::dpc_variant::unset);
xview, Mview, 0, maps::type::contravariantPiola, space,
discontinuous, degree, degree, lvariant,
element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
11 changes: 6 additions & 5 deletions cpp/basix/e-bubble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ FiniteElement basix::element::create_bubble(cell::type celltype, int degree,
_M(i, 0, i, 0) = 1.0;

impl::mdspan2_t wview(wcoeffs.data(), wcoeffs.extents());
return FiniteElement(element::family::bubble, celltype, degree, {}, wview,
impl::to_mdspan(x), impl::to_mdspan(M), 0,
maps::type::identity, sobolev::space::H1, discontinuous,
-1, degree, element::lagrange_variant::unset,
element::dpc_variant::unset);
sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::H1;
return FiniteElement(
element::family::bubble, celltype, degree, {}, wview, impl::to_mdspan(x),
impl::to_mdspan(M), 0, maps::type::identity, space, discontinuous, -1,
degree, element::lagrange_variant::unset, element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
4 changes: 3 additions & 1 deletion cpp/basix/e-hermite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ FiniteElement basix::element::create_hermite(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::H2;
return FiniteElement(
element::family::Hermite, celltype, degree, {},
impl::mdspan2_t(math::eye(ndofs).data(), ndofs, ndofs), xview, Mview, 1,
maps::type::identity, sobolev::space::H2, discontinuous, -1, degree,
maps::type::identity, space, discontinuous, -1, degree,
element::lagrange_variant::unset, element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
13 changes: 7 additions & 6 deletions cpp/basix/e-hhj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ FiniteElement basix::element::create_hhj(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

return FiniteElement(element::family::HHJ, celltype, degree, {tdim, tdim},
impl::mdspan2_t(wcoeffs.data(), wcoeffs.extents()),
xview, Mview, 0, maps::type::doubleContravariantPiola,
sobolev::space::HDivDiv, discontinuous, -1, degree,
element::lagrange_variant::unset,
element::dpc_variant::unset);
sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HDivDiv;
return FiniteElement(
element::family::HHJ, celltype, degree, {tdim, tdim},
impl::mdspan2_t(wcoeffs.data(), wcoeffs.extents()), xview, Mview, 0,
maps::type::doubleContravariantPiola, space, discontinuous, -1, degree,
element::lagrange_variant::unset, element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
16 changes: 10 additions & 6 deletions cpp/basix/e-nce-rtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ FiniteElement basix::element::create_rtc(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HCurl;
return FiniteElement(element::family::RT, celltype, degree, {tdim},
impl::mdspan2_t(wcoeffs.data(), wcoeffs.extents()),
xview, Mview, 0, maps::type::contravariantPiola,
sobolev::space::HDiv, discontinuous, degree - 1, degree,
lvariant, element::dpc_variant::unset);
xview, Mview, 0, maps::type::contravariantPiola, space,
discontinuous, degree - 1, degree, lvariant,
element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
FiniteElement basix::element::create_nce(cell::type celltype, int degree,
Expand Down Expand Up @@ -393,10 +395,12 @@ FiniteElement basix::element::create_nce(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HCurl;
return FiniteElement(element::family::N1E, celltype, degree, {tdim},
impl::mdspan2_t(wcoeffs.data(), wcoeffs.extents()),
xview, Mview, 0, maps::type::covariantPiola,
sobolev::space::HCurl, discontinuous, degree - 1, degree,
lvariant, element::dpc_variant::unset);
xview, Mview, 0, maps::type::covariantPiola, space,
discontinuous, degree - 1, degree, lvariant,
element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
6 changes: 4 additions & 2 deletions cpp/basix/e-nedelec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,12 @@ FiniteElement element::create_nedelec(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HCurl;
return FiniteElement(element::family::N1E, celltype, degree, {tdim},
impl::mdspan2_t(wcoeffs.data(), wshape), xview, Mview, 0,
maps::type::covariantPiola, sobolev::space::HCurl,
discontinuous, degree - 1, degree, lvariant,
maps::type::covariantPiola, space, discontinuous,
degree - 1, degree, lvariant,
element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions cpp/basix/e-raviart-thomas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ FiniteElement basix::element::create_rt(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HDiv;
return FiniteElement(element::family::RT, celltype, degree, {tdim},
impl::mdspan2_t(B.data(), B.extents()), xview, Mview, 0,
maps::type::contravariantPiola, sobolev::space::HDiv,
discontinuous, degree - 1, degree, lvariant,
maps::type::contravariantPiola, space, discontinuous,
degree - 1, degree, lvariant,
element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
9 changes: 4 additions & 5 deletions cpp/basix/e-regge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,12 @@ FiniteElement element::create_regge(cell::type celltype, int degree,
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

// if (discontinuous)
// std::tie(x, M) = element::make_discontinuous(x, M, tdim, tdim * tdim);

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HEin;
return FiniteElement(
element::family::Regge, celltype, degree, {tdim, tdim},
impl::mdspan2_t(wcoeffs.data(), wcoeffs.extents()), xview, Mview, 0,
maps::type::doubleCovariantPiola, sobolev::space::HEin, discontinuous, -1,
degree, element::lagrange_variant::unset, element::dpc_variant::unset);
maps::type::doubleCovariantPiola, space, discontinuous, -1, degree,
element::lagrange_variant::unset, element::dpc_variant::unset);
}
//-----------------------------------------------------------------------------
19 changes: 10 additions & 9 deletions cpp/basix/e-serendipity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,10 +1094,11 @@ FiniteElement basix::element::create_serendipity(
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::H1;
return FiniteElement(element::family::serendipity, celltype, degree, {},
impl::cmdspan2_t(wbuffer.data(), wshape), xview, Mview,
0, maps::type::identity, sobolev::space::H1,
discontinuous,
0, maps::type::identity, space, discontinuous,
degree < static_cast<int>(tdim) ? 1 : degree / tdim,
degree, lvariant, dvariant);
}
Expand Down Expand Up @@ -1268,9 +1269,7 @@ FiniteElement basix::element::create_serendipity_div(
wshape = {w.extent(0), w.extent(1)};
}
else
{
throw std::runtime_error("Unsupported tdim");
}

std::array<std::vector<cmdspan2_t>, 4> xview = impl::to_mdspan(x);
std::array<std::vector<cmdspan4_t>, 4> Mview = impl::to_mdspan(M);
Expand All @@ -1286,11 +1285,12 @@ FiniteElement basix::element::create_serendipity_div(
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HDiv;
return FiniteElement(element::family::BDM, celltype, degree, {tdim},
impl::cmdspan2_t(wbuffer.data(), wshape), xview, Mview,
0, maps::type::contravariantPiola, sobolev::space::HDiv,
discontinuous, degree / tdim, degree + 1, lvariant,
dvariant);
0, maps::type::contravariantPiola, space, discontinuous,
degree / tdim, degree + 1, lvariant, dvariant);
}
//-----------------------------------------------------------------------------
FiniteElement basix::element::create_serendipity_curl(
Expand Down Expand Up @@ -1412,10 +1412,11 @@ FiniteElement basix::element::create_serendipity_curl(
Mview = impl::to_mdspan(Mbuffer, Mshape);
}

sobolev::space space
= discontinuous ? sobolev::space::L2 : sobolev::space::HCurl;
return FiniteElement(element::family::N2E, celltype, degree, {tdim},
impl::cmdspan2_t(wbuffer.data(), wshape), xview, Mview,
0, maps::type::covariantPiola, sobolev::space::HCurl,
discontinuous,
0, maps::type::covariantPiola, space, discontinuous,
(degree == 2 && tdim == 3) ? 1 : degree / tdim,
degree + 1, lvariant, dvariant);
}
Expand Down
35 changes: 14 additions & 21 deletions cpp/basix/sobolev-spaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,36 @@

#include "sobolev-spaces.h"

basix::sobolev::space
basix::sobolev::space_intersection(basix::sobolev::space space1,
basix::sobolev::space space2)
basix::sobolev::space basix::sobolev::space_intersection(space space1,
space space2)
{
if (space1 == space2)
return space1;
if (space1 == basix::sobolev::space::H1)

if (space1 == space::H1)
{
if (space2 == basix::sobolev::space::H2
|| space2 == basix::sobolev::space::H3
|| space2 == basix::sobolev::space::HInf)
if (space2 == space::H2 or space2 == space::H3 or space2 == space::HInf)
return space1;
}
else if (space1 == basix::sobolev::space::H2)
else if (space1 == space::H2)
{
if (space2 == basix::sobolev::space::H1)
if (space2 == space::H1)
return space2;
else if (space2 == basix::sobolev::space::H3
|| space2 == basix::sobolev::space::HInf)
else if (space2 == space::H3 or space2 == space::HInf)
return space1;
}
else if (space1 == basix::sobolev::space::H3)
else if (space1 == space::H3)
{
if (space2 == basix::sobolev::space::H1
|| space2 == basix::sobolev::space::H2)
if (space2 == space::H1 or space2 == space::H2)
return space2;
else if (space2 == basix::sobolev::space::H3
|| space2 == basix::sobolev::space::HInf)
else if (space2 == space::H3 or space2 == space::HInf)
return space1;
}
else if (space1 == basix::sobolev::space::HInf)
else if (space1 == space::HInf)
{
if (space2 == basix::sobolev::space::H1
|| space2 == basix::sobolev::space::H2
|| space2 == basix::sobolev::space::H3)
if (space2 == space::H1 or space2 == space::H2 or space2 == space::H3)
return space2;
}

return basix::sobolev::space::L2;
return space::L2;
}
11 changes: 5 additions & 6 deletions cpp/basix/sobolev-spaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ enum class space
HDivDiv = 13,
};

/// Get the intersection of two Sobolev spaces
/// @param[in] space1 The first space
/// @param[in] space2 The second space
/// @return The intersection
basix::sobolev::space space_intersection(basix::sobolev::space space1,
basix::sobolev::space space2);
/// Get the intersection of two Sobolev spaces.
/// @param[in] space1 First space
/// @param[in] space2 Second space
/// @return Intersection of the spaces
space space_intersection(space space1, space space2);

} // namespace basix::sobolev

0 comments on commit caad923

Please sign in to comment.