3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RAVIARTTHOMASBASIS_HH
4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RAVIARTTHOMASBASIS_HH
7 #include <dune/common/exceptions.hh>
9 #include <dune/localfunctions/raviartthomas.hh>
10 #include <dune/localfunctions/raviartthomas/raviartthomas0cube2d.hh>
11 #include <dune/localfunctions/raviartthomas/raviartthomas0cube3d.hh>
12 #include <dune/localfunctions/raviartthomas/raviartthomas02d.hh>
13 #include <dune/localfunctions/raviartthomas/raviartthomas1cube2d.hh>
14 #include <dune/localfunctions/raviartthomas/raviartthomas1cube3d.hh>
15 #include <dune/localfunctions/raviartthomas/raviartthomas12d.hh>
16 #include <dune/localfunctions/raviartthomas/raviartthomas2cube2d.hh>
18 #include <dune/typetree/leafnode.hh>
29 template<
int dim, GeometryType::BasicType basic_type,
typename D,
typename R, std::
size_t k>
30 struct RaviartThomasLocalInfo
32 static_assert((AlwaysFalse<D>::value),
"The requested type of Raviart-Thomas element is not implemented, sorry!");
35 template<
typename D,
typename R>
36 struct RaviartThomasLocalInfo<2,GeometryType::simplex,D,R,0>
38 using FiniteElement = RT02DLocalFiniteElement<D,R>;
39 static const std::size_t Variants = 8;
42 template<
typename D,
typename R>
43 struct RaviartThomasLocalInfo<2,GeometryType::simplex,D,R,1>
45 using FiniteElement = RT12DLocalFiniteElement<D,R>;
46 static const std::size_t Variants = 8;
49 template<
typename D,
typename R>
50 struct RaviartThomasLocalInfo<2,GeometryType::cube,D,R,0>
52 using FiniteElement = RT0Cube2DLocalFiniteElement<D,R>;
53 static const std::size_t Variants = 16;
56 template<
typename D,
typename R>
57 struct RaviartThomasLocalInfo<2,GeometryType::cube,D,R,1>
59 using FiniteElement = RT1Cube2DLocalFiniteElement<D,R>;
60 static const std::size_t Variants = 16;
63 template<
typename D,
typename R>
64 struct RaviartThomasLocalInfo<2,GeometryType::cube,D,R,2>
66 using FiniteElement = RT2Cube2DLocalFiniteElement<D,R>;
67 static const std::size_t Variants = 16;
70 template<
typename D,
typename R>
71 struct RaviartThomasLocalInfo<3,GeometryType::cube,D,R,0>
73 using FiniteElement = RT0Cube3DLocalFiniteElement<D,R>;
74 static const std::size_t Variants = 64;
77 template<
typename D,
typename R>
78 struct RaviartThomasLocalInfo<3,GeometryType::cube,D,R,1>
80 using FiniteElement = RT1Cube3DLocalFiniteElement<D,R>;
81 static const std::size_t Variants = 64;
84 template<
typename GV,
int dim, GeometryType::BasicType basic_type,
typename D,
typename R, std::
size_t k>
85 class RaviartThomasLocalFiniteElementMap
87 static const std::size_t Variants = RaviartThomasLocalInfo<dim, basic_type, D, R, k>::Variants;
91 using FiniteElement =
typename RaviartThomasLocalInfo<dim, basic_type, D, R, k>::FiniteElement;
93 RaviartThomasLocalFiniteElementMap(
const GV& gv)
94 : gv_(gv), is_(&(gv_.indexSet())), orient_(gv.size(0))
97 for (
size_t i = 0; i < Variants; i++)
98 variant_[i] = FiniteElement(i);
102 for(
const auto& cell : elements(gv))
104 unsigned int myId = is_->index(cell);
107 for (
const auto& intersection : intersections(gv,cell))
109 if (intersection.neighbor() && (is_->index(intersection.outside()) > myId))
110 orient_[myId] |= (1 << intersection.indexInInside());
116 template<
class EntityType>
117 const FiniteElement& find(
const EntityType& e)
const
119 return variant_[orient_[is_->index(e)]];
124 std::array<FiniteElement,Variants> variant_;
125 const typename GV::IndexSet* is_;
126 std::vector<unsigned char> orient_;
145 template<
typename GV,
int k,
typename ST,
typename TP, GeometryType::BasicType basic_type>
148 template<
typename GV,
int k,
class MI,
class TP,
class ST, GeometryType::BasicType basic_type>
151 template<
typename GV,
int k,
class MI,
class ST, GeometryType::BasicType basic_type>
154 template<
typename GV,
int k,
class MI,
class ST, GeometryType::BasicType basic_type>
157 static const int dim = GV::dimension;
158 using FiniteElementMap =
typename Impl::RaviartThomasLocalFiniteElementMap<GV, dim, basic_type, typename GV::ctype, double, k>;
162 template<
typename,
int,
class,
class,
class, GeometryType::BasicType>
177 const static int dofsPerElement = dim == 2 ? (basic_type == GeometryType::cube ? k*(k+1)*dim : k*dim) : k*(k+1)*(k+1)*dim;
238 assert(prefix.size() == 0 || prefix.size() == 1);
239 return (prefix.size() == 0) ?
size() : 0;
250 return StaticPower<(k+1),GV::dimension>::
power;
261 template<
typename GV,
int k,
typename ST,
typename TP, GeometryType::BasicType basic_type>
265 static const int dim = GV::dimension;
266 static const int maxSize = StaticPower<(k+1),GV::dimension>::
power;
274 using Element =
typename GV::template Codim<0>::Entity;
275 using FiniteElementMap =
typename Impl::RaviartThomasLocalFiniteElementMap<GV, dim, basic_type, typename GV::ctype, double, k>;
315 template<
typename GV,
int k,
class MI,
class TP,
class ST, GeometryType::BasicType basic_type>
318 enum {dim = GV::dimension};
356 return node_->finiteElement().size();
364 template<
typename It>
368 const auto& element =
node_->element();
371 if (not(basic_type==GeometryType::BasicType::cube and element.type().isCube()) and
372 not(basic_type==GeometryType::BasicType::simplex and element.type().isSimplex())) DUNE_THROW(Dune::NotImplemented,
"RaviartThomasNodalBasis only implemented for cube and simplex elements.");
374 for(std::size_t i=0, end=
size(); i<end; ++i, ++it)
376 Dune::LocalKey localKey =
node_->finiteElement().localCoefficients().localKey(i);
379 size_t subentity = localKey.subEntity();
380 size_t codim = localKey.codim();
382 if (not(codim==0 or codim==1)) DUNE_THROW(Dune::NotImplemented,
"Grid contains elements not supported for the RaviartThomasBasis");
385 preBasis_->
dofsPerCodim[codim] * gridIndexSet.subIndex(element, subentity, codim) + localKey.index() };
398 namespace BasisBuilder {
402 template<std::
size_t k, GeometryType::BasicType basic_type,
class size_type=std::
size_t>
403 class RaviartThomasPreBasisFactory
406 static const std::size_t requiredMultiIndexSize=1;
408 template<
class MultiIndex,
class Gr
idView>
409 auto makePreBasis(
const GridView& gridView)
const
426 template<std::
size_t k, GeometryType::BasicType basic_type,
class size_type=std::
size_t>
429 return Imp::RaviartThomasPreBasisFactory<k, basic_type, size_type>();
447 template<
typename GV,
int k, GeometryType::BasicType basic_type,
class ST = std::
size_t>
454 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RAVIARTTHOMASBASIS_HH