21#include <boost/compressed_pair.hpp>
22#include <boost/iterator/transform_iterator.hpp>
32 template <
class,
class>
class ContinuousLagrangeBoundaryMapper;
34 namespace ScalarSpaceDetail
46 typename Pair::first_const_reference
operator()(Pair
const& pair)
const
56 bool operator()(boost::compressed_pair<size_t,Data>
const& a, boost::compressed_pair<size_t,Data>
const& b)
58 return a.first() < b.first();
73 if(codim==0)
return false;
74 if(codim==1)
return id==localFaceId;
78 if(localFaceId==0)
return (
id==0 ||
id==1);
79 if(localFaceId==1)
return (
id==0 ||
id==2);
80 if(localFaceId==2)
return (
id==2 ||
id==1);
87 if(localFaceId==0)
return (
id>=0 &&
id<3);
88 if(localFaceId==1)
return (
id==0 ||
id==3 ||
id==4);
89 if(localFaceId==2)
return (
id==1 ||
id==3 ||
id==5);
90 if(localFaceId==3)
return (
id==2 ||
id==4 ||
id==5);
95 if(localFaceId==0)
return (
id>=0 &&
id<3);
96 if(localFaceId==1)
return (
id==0 ||
id==1 ||
id==3);
97 if(localFaceId==2)
return (
id==0 ||
id==2 ||
id==3);
98 if(localFaceId==3)
return (
id==1 ||
id==2 ||
id==3);
106 static constexpr int defaultIndex = -94279;
108 template <
class Face>
111 size_t boundarySegmentIndex = face.boundarySegmentIndex();
112 if(boundarySegmentIndex < boundaryIds.size())
return boundaryIds[boundarySegmentIndex];
116 inline bool usedId(
int id, std::vector<int>
const& usedIds)
118 if (
id==defaultIndex)
return false;
119 return std::find(usedIds.begin(), usedIds.end(),
id) != usedIds.end();
122 template <
class Face>
123 inline bool considerFace(
Face const& face, std::vector<int>
const& boundaryIds, std::vector<int>
const& usedIds)
125 if(boundaryIds.empty())
return face.boundary();
136 template <
class Data,
class Gr
idView,
class Cell>
137 void treatBoundary(Data& data, GridView
const& gridView,
Cell const& cell,
int codim,
int subentity)
const
140 assert(cell.type().isSimplex());
142 for(
auto const& face: intersections(gridView,cell))
145 &&
onSimplexFace(GridView::dimension,codim,subentity,face.indexInInside()))
153 template <
class Policy>
156 return std::is_same<Policy,RestrictToBoundary>::value;
162 template <
class Data,
class Gr
idView,
class Cell>
void treatBoundary(Data&, GridView
const&,
Cell const&,
int,
int)
const {}
174 template <
class SFData>
203 template <
class Implementation,
class SFData = ScalarSpaceDetail::Empty>
207 typedef typename Implementation::Grid
Grid;
211 typedef typename Implementation::Combiner
Combiner;
212 typedef typename Implementation::Scalar
Scalar;
213 typedef typename Implementation::GridView
GridView;
218 typedef boost::compressed_pair<size_t,SFData> Data;
222 typedef boost::transform_iterator<First,typename std::vector<Data>::const_iterator> GlobalIndexIterator;
223 typedef std::vector<IndexPair>::const_iterator SortedIndexIterator;
225 static constexpr int dim = Grid::dimension;
264 GlobalIndexIterator(globIdx[0].begin(),
First()));
288 GlobalIndexIterator(globIdx[n].end(),
First()));
296 static std::vector<IndexPair> dummy;
323 size_t size()
const {
return n; }
381 return std::make_pair(
true, unrestrictedIndex);
403 for (
int codim=0; codim<=Grid::dimension; ++codim)
406 startIndex[geoType] = ndofs;
410 ndofs += numOfEntity * dofOnEntity;
416 sfs.resize(indexSet.size(0));
426 for(
auto const& cell : elements(
gridView))
428 size_t const cellIndex = indexSet.index(cell);
434 sfs[cellIndex] = &sf;
440 globIdx[cellIndex].clear();
441 sortedIdx[cellIndex].clear();
448 size_t localNumberOfShapeFunctions = sf.size();
449 globIdx[cellIndex].resize(localNumberOfShapeFunctions);
450 sortedIdx[cellIndex].resize(localNumberOfShapeFunctions);
454 for(
size_t i=0; i<localNumberOfShapeFunctions; ++i)
456 Dune::GeometryType gt;
457 int subentity, codim, indexInSubentity;
459 implementation.entityIndex(cell,sf[i],i,gt,subentity,codim,indexInSubentity,sfData);
464 auto mi = startIndex.find(gt);
465 assert(mi!=startIndex.end());
467 int globalIndex = mi->second+gt_idx*
implementation.dofOnEntity(gt) + indexInSubentity;
469 globIdx[cellIndex][i] = Data(globalIndex,sfData);
470 sortedIdx[cellIndex][i] = std::make_pair(globIdx[cellIndex][i].first(),i);
475 std::sort(sortedIdx[cellIndex].begin(),sortedIdx[cellIndex].end(),
FirstLess());
482 std::vector<size_t> idx(globIdx[cellIndex].
size());
483 for (
int j=0; j<idx.size(); ++j)
484 idx[j] = globIdx[cellIndex][j].first();
485 std::sort(idx.begin(),idx.end());
486 for (
int j=1; j<idx.size(); ++j)
487 assert(idx[j]>idx[j-1] || idx[j]<0);
510 std::map<Dune::GeometryType,size_t> startIndex;
513 std::vector<std::vector<Data>> globIdx;
518 std::vector<std::vector<IndexPair>> sortedIdx;
521 std::vector<ShapeFunctionSet const*> sfs;
DEPRECATED. Use boost::iterator_range instead.
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
typename GridView::Intersection Face
The type of faces in the grid view.
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
int getBoundaryId(Face const &face, std::vector< int > const &boundaryIds)
bool onSimplexFace(int dim, int codim, int id, int localFaceId)
check if a given subentity E is part of a certain simplex face F
bool considerFace(Face const &face, std::vector< int > const &boundaryIds, std::vector< int > const &usedIds)
bool usedId(int id, std::vector< int > const &usedIds)
constexpr bool isRestriction()
RangeView< It > rangeView(It first, It last)
Convenience function for constructing range views on the fly.
A comparator functor that supports sorting std::pair by their first component.
void treatBoundary(Data &, GridView const &, Cell const &, int, int) const
A functor for extracting the first component of a boost compressed pair.
Pair::first_const_reference result_type
Pair::first_const_reference operator()(Pair const &pair) const
bool operator()(boost::compressed_pair< size_t, Data > const &a, boost::compressed_pair< size_t, Data > const &b)
std::vector< int > const usedIds
RestrictToBoundary(std::vector< int > const &boundaryIds_, std::vector< int > const &usedIds_)
void treatBoundary(Data &data, GridView const &gridView, Cell const &cell, int codim, int subentity) const
std::vector< int > const boundaryIds
RestrictToBoundary(RestrictToBoundary const &other)