3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_BREZZIDOUGLASMARINIBASIS_HH
4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_BREZZIDOUGLASMARINIBASIS_HH
7 #include <dune/common/exceptions.hh>
8 #include <dune/geometry/referenceelements.hh>
10 #include <dune/localfunctions/common/virtualinterface.hh>
11 #include <dune/localfunctions/common/virtualwrappers.hh>
13 #include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini1cube2d.hh>
14 #include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini1cube3d.hh>
15 #include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini1simplex2d.hh>
16 #include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini2cube2d.hh>
17 #include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini2simplex2d.hh>
19 #include <dune/typetree/leafnode.hh>
30 template<
int dim,
typename D,
typename R, std::
size_t k>
31 struct BDMSimplexLocalInfo
33 static_assert((AlwaysFalse<D>::value),
"The requested type of BDM element is not implemented, sorry!");
36 template<
typename D,
typename R>
37 struct BDMSimplexLocalInfo<2,D,R,1>
39 using FiniteElement = BDM1Simplex2DLocalFiniteElement<D,R>;
40 static const std::size_t Variants = 8;
43 template<
typename D,
typename R>
44 struct BDMSimplexLocalInfo<2,D,R,2>
46 using FiniteElement = BDM2Simplex2DLocalFiniteElement<D,R>;
47 static const std::size_t Variants = 8;
50 template<
int dim,
typename D,
typename R, std::
size_t k>
51 struct BDMCubeLocalInfo
53 static_assert((AlwaysFalse<D>::value),
"The requested type of BDM element is not implemented, sorry!");
56 template<
typename D,
typename R>
57 struct BDMCubeLocalInfo<2,D,R,1>
59 using FiniteElement = BDM1Cube2DLocalFiniteElement<D,R>;
60 static const std::size_t Variants = 16;
63 template<
typename D,
typename R>
64 struct BDMCubeLocalInfo<2,D,R,2>
66 using FiniteElement = BDM2Cube2DLocalFiniteElement<D,R>;
67 static const std::size_t Variants = 16;
70 template<
typename D,
typename R>
71 struct BDMCubeLocalInfo<3,D,R,1>
73 using FiniteElement = BDM1Cube3DLocalFiniteElement<D,R>;
74 static const std::size_t Variants = 64;
77 template<
typename GV,
int dim,
typename R, std::
size_t k>
78 class BDMLocalFiniteElementMap
80 using D =
typename GV::ctype;
81 using CubeFiniteElement =
typename BDMCubeLocalInfo<dim, D, R, k>::FiniteElement;
82 using SimplexFiniteElement =
typename BDMSimplexLocalInfo<dim, D, R, k>::FiniteElement;
86 using T = LocalBasisTraits<D, dim, FieldVector<D,dim>, R, dim, FieldVector<R,dim>, FieldMatrix<D,dim,dim> >;
87 using FiniteElement = LocalFiniteElementVirtualInterface<T>;
89 BDMLocalFiniteElementMap(
const GV& gv)
90 : is_(&(gv.indexSet())), orient_(gv.size(0))
92 cubeVariant_.resize(BDMCubeLocalInfo<dim, D, R, k>::Variants);
93 simplexVariant_.resize(BDMSimplexLocalInfo<dim, D, R, k>::Variants);
96 for (
size_t i = 0; i < cubeVariant_.size(); i++)
97 cubeVariant_[i] = std::make_unique<LocalFiniteElementVirtualImp<CubeFiniteElement> >(CubeFiniteElement(i));
99 for (
size_t i = 0; i < simplexVariant_.size(); i++)
100 simplexVariant_[i] = std::make_unique<LocalFiniteElementVirtualImp<SimplexFiniteElement> >(SimplexFiniteElement(i));
104 for(
const auto& cell : elements(gv))
106 unsigned int myId = is_->index(cell);
109 for (
const auto& intersection : intersections(gv,cell))
111 if (intersection.neighbor() && (is_->index(intersection.outside()) > myId))
112 orient_[myId] |= (1 << intersection.indexInInside());
118 template<
class EntityType>
119 const FiniteElement& find(
const EntityType& e)
const
121 if (e.type().isCube())
122 return *cubeVariant_[orient_[is_->index(e)]];
124 return *simplexVariant_[orient_[is_->index(e)]];
128 std::vector<std::unique_ptr<LocalFiniteElementVirtualImp<CubeFiniteElement> > > cubeVariant_;
129 std::vector<std::unique_ptr<LocalFiniteElementVirtualImp<SimplexFiniteElement> > > simplexVariant_;
130 const typename GV::IndexSet* is_;
131 std::vector<unsigned char> orient_;
150 template<
typename GV,
int k>
153 template<
typename GV,
int k,
class MI>
156 template<
typename GV,
int k,
class MI>
159 static const int dim = GV::dimension;
160 using FiniteElementMap =
typename Impl::BDMLocalFiniteElementMap<GV, dim, double, k>;
162 template<
typename,
int,
class>
187 if (gv.indexSet().types(0).size() > 1)
188 DUNE_THROW(Dune::NotImplemented,
"Brezzi-Douglas-Marini basis is only implemented for grids with a single element type");
238 assert(prefix.size() == 0 || prefix.size() == 1);
239 return (prefix.size() == 0) ?
size() : 0;
252 GeometryType elementType = *(
gridView_.indexSet().types(0).begin());
253 size_t numFaces = ReferenceElements<double,dim>::general(elementType).size(1);
267 template<
typename GV,
int k>
268 class BrezziDouglasMariniNode :
271 static const int dim = GV::dimension;
276 using Element =
typename GV::template Codim<0>::Entity;
318 template<
typename GV,
int k,
class MI>
321 enum {dim = GV::dimension};
367 template<
typename It>
374 if (not(element.type().isCube()) and not(element.type().isSimplex()))
375 DUNE_THROW(Dune::NotImplemented,
"BrezziDouglasMariniBasis only implemented for cube and simplex elements.");
377 for(std::size_t i=0, end=
size(); i<end; ++i, ++it)
382 size_t subentity = localKey.subEntity();
383 size_t codim = localKey.codim();
399 namespace BasisFactory {
403 template<std::
size_t k>
404 class BrezziDouglasMariniPreBasisFactory
407 static const std::size_t requiredMultiIndexSize=1;
409 template<
class MultiIndex,
class Gr
idView>
410 auto makePreBasis(
const GridView& gridView)
const
426 template<std::
size_t k>
429 return Imp::BrezziDouglasMariniPreBasisFactory<k>();
447 template<
typename GV,
int k>
454 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_BREZZIDOUGLASMARINIBASIS_HH