13#ifndef BOUNDARY_SPACE_HH
14#define BOUNDARY_SPACE_HH
19#include <dune/common/fvector.hh>
37 template <
class,
class>
class ContinuousLagrangeMapper;
38 template <
class,
class,
class>
class ContinuousLagrangeMapperImplementation;
39 template <
class,
class>
class DiscontinuousLagrangeMapper;
40 template <
class,
class>
class ContinuousHierarchicMapper;
41 template <
class,
class>
class DiscontinuousHierarchicMapper;
42 template <
class,
class,
class>
class ContinuousHierarchicMapperImplementation;
43 template <
class,
class>
class ContinuousHierarchicExtensionMapper;
44 template <
class,
class,
class>
class ContinuousHierarchicExtensionMapperImplementation;
46 template <
class,
int,
class>
class LagrangeSimplexShapeFunctionSet;
47 template <
class,
int,
class>
class HierarchicSimplexShapeFunctionSet;
48 template <
class,
int,
class>
class HierarchicExtensionSimplexShapeFunctionSet;
51 namespace BoundarySpace_Detail
53 using namespace ScalarSpaceDetail;
58 template <
class Scalar,
class Gr
idView>
64 struct BOUNDARY_MAPPERS_ARE_NOT_YET_IMPLEMENTED_FOR_DISCONTINUOUS_SPACES;
66 template <
class Scalar,
class Gr
idView>
69 typedef BOUNDARY_MAPPERS_ARE_NOT_YET_IMPLEMENTED_FOR_DISCONTINUOUS_SPACES
type;
72 template <
class Scalar,
class Gr
idView>
78 template <
class Scalar,
class Gr
idView>
84 template <
class Scalar,
class Gr
idView>
87 typedef BOUNDARY_MAPPERS_ARE_NOT_YET_IMPLEMENTED_FOR_DISCONTINUOUS_SPACES
type;
92 template <
class Scalar,
class Gr
idView>
95 typedef boost::compressed_pair<bool,Empty>
type;
98 template <
class Scalar,
class Gr
idView>
101 typedef boost::compressed_pair<bool,int>
type;
104 template <
class Scalar,
class Gr
idView>
107 typedef boost::compressed_pair<bool,int>
type;
113 template <
class Scalar,
class Gr
idView,
class Data>
119 template <
class Scalar,
class Gr
idView,
class Data>
125 template <
class Scalar,
class Gr
idView,
class Data>
159 template <
template <
class,
class>
class Implementation_,
class Scalar_,
class GridView_>
162 typename BoundarySpace_Detail::GetSFDataType<Implementation_<Scalar_,GridView_>>::type>
173 static int const continuity = 0;
174 static constexpr int dim = GridView::dimension;
194 Base(Implementation(gridView,order))
207 BoundaryMapper(
GridView const& gridView,
int order, std::vector<int>
const& boundaryIds_, std::vector<int>
const& usedIds_)
208 :
Base(Implementation(gridView,order,ScalarSpaceDetail::RestrictToBoundary(boundaryIds_,usedIds_)))
213 template <
class T,
class Functor>
214 BoundaryMapper(
GridView const& gridView,
int order, std::vector<T>
const& boundaryIds_, std::vector<T>
const& usedIds_, Functor boundaryIdsToInts)
215 :
Base(Implementation(gridView,order,ScalarSpaceDetail::RestrictToBoundary(boundaryIdsToInts(boundaryIds_),boundaryIdsToInts(usedIds_))))
220 bool inDomain(
typename GridView::Intersection
const& face)
const
232 forEachBoundaryFace(this->implementation.gridView(),[&](
typename GridView::Intersection
const& intersection) {
233 if(inDomain(intersection)) ++nFaces;
243 namespace ScalarSpaceDetail
246 template <
template <
class,
class,
class>
class MapperImplementation,
class Scalar_,
class GridView_,
class SFData>
247 class MapperPolicy<MapperImplementation<Scalar_,GridView_,RestrictToBoundary>,
boost::compressed_pair<bool,SFData> >
249 typedef Scalar_ Scalar;
250 typedef GridView_ GridView;
251 typedef MapperImplementation<Scalar,GridView,RestrictToBoundary> Implementation;
252 typedef typename Implementation::Grid Grid;
253 typedef typename GridView::IndexSet IndexSet;
254 typedef typename Grid::template Codim<0>::Entity
Cell;
255 typedef typename Implementation::ShapeFunctionSet ShapeFunctionSet;
256 typedef boost::compressed_pair<bool,SFData> Data;
257 typedef typename BoundarySpace_Detail::ShapeFunctionSetRestriction<Implementation>::type ShapeFunctionSet_Restricted;
260 static constexpr bool boundaryPolicy =
true;
262 explicit MapperPolicy(Implementation
const& impl) : implementation(impl),
263 insertionIndex(0), consideredCells(implementation.indexSet().size(0))
266 template <
class GlobalIndices,
class SortedIndices>
267 void initIndices(std::map<Dune::GeometryType,size_t>& startIndex, GlobalIndices& globIdx, SortedIndices& sortedIdx)
271 globIdx.resize(implementation.indexSet().size(0));
273 sortedIdx.resize(implementation.indexSet().size(0));
275 consideredCells.clear();
276 consideredCells.resize(implementation.indexSet().size(0),
false);
277 shapeFunctionSets.clear();
278 shapeFunctionSets.resize(implementation.indexSet().size(0));
281 for (
int codim=0; codim<=Grid::dimension; ++codim)
282 for(
auto const& geoType: implementation.indexSet().types(codim))
284 startIndex[geoType] = n;
285 n += implementation.indexSet().size(geoType) * implementation.dofOnEntity(geoType);
289 indexMapper.resize(n,std::make_pair(
false,0));
294 template <
class GlobalIndices,
class SortedIndices>
295 void computeIndices(
Cell const& cell, std::map<Dune::GeometryType,size_t>& startIndex, GlobalIndices& globIdx, SortedIndices& sortedIdx,
size_t cellIndex)
299 std::vector<int> idRestriction;
300 ShapeFunctionSet& sf =
static_cast<UniformScalarMapper<Implementation,Data>&
>(*this).shapefunctions_non_const(cell);
301 if(!consideredCells[cellIndex])
303 if(cell.type().isSimplex())
static_cast<ShapeFunctionSet_Restricted&
>(sf).setRestriction(idRestriction);
310 Dune::GeometryType gt;
311 int subentity, codim, indexInSubentity;
312 size_t realLocalId = 0;
313 for(
size_t i=0; i<sf.size(); ++i)
315 std::tie(nominalOrder,codim,subentity,indexInSubentity) = sf[i].location();
317 if(codim == 0)
continue;
320 assert(cell.type().isSimplex());
321 implementation.entityIndex(cell,sf[i],i,gt,subentity,codim,indexInSubentity,data);
324 std::pair<bool,size_t> contains = std::make_pair(
false,0);
328 int gt_idx =
subIndex(implementation.indexSet(),cell,codim,subentity);
330 std::map<Dune::GeometryType,size_t>::const_iterator mi = startIndex.find(gt);
331 assert(mi!=startIndex.end());
337 size_t unrestrictedIndex = mi->second+gt_idx*implementation.dofOnEntity(gt)+indexInSubentity;
339 contains = indexMapper[unrestrictedIndex];
340 if(!contains.first) indexMapper[unrestrictedIndex] = std::make_pair(
true,insertionIndex);
343 indexMapper[unrestrictedIndex] = std::make_pair(
true,insertionIndex);
347 if(!contains.first) globIdx[cellIndex].push_back( boost::compressed_pair<size_t,Data>(insertionIndex,data) );
348 else globIdx[cellIndex].push_back( boost::compressed_pair<size_t,Data>(contains.second,data) );
350 sortedIdx[cellIndex].push_back( std::make_pair(globIdx[cellIndex].back().first(),realLocalId) );
352 idRestriction.push_back(i);
354 if(!contains.first) ++insertionIndex;
359 if(cell.type().isSimplex())
static_cast<ShapeFunctionSet_Restricted&
>(sf).setRestriction(idRestriction);
362 template <
class Container,
class ShapeFunctionSet>
363 void initShapeFunctionSet(Container& sfs, ShapeFunctionSet
const& sf,
size_t cellIndex)
368 assert(cellIndex < shapeFunctionSets.size());
369 shapeFunctionSets[cellIndex] = std::make_unique<ShapeFunctionSet_Restricted>(
static_cast<ShapeFunctionSet_Restricted const&
>(sf),
nullptr);
370 sfs[cellIndex] = shapeFunctionSets[cellIndex].get();
373 Implementation implementation;
385 std::pair<bool,size_t> unrestrictedToRestrictedIndex(std::vector<std::pair<bool,size_t>>::size_type unrestrictedIndex)
const {
386 assert(unrestrictedIndex < indexMapper.size());
387 return indexMapper[unrestrictedIndex];
393 auto cend = implementation.gridView().template end<0>();
394 for(
auto cell = implementation.gridView().template begin<0>(); cell!=cend; ++cell)
396 size_t cellIndex = implementation.indexSet().index(*cell);
397 auto fend = implementation.gridView().iend(*cell);
398 for(
auto face = implementation.gridView().ibegin(*cell); face!=fend; ++face)
400 consideredCells[cellIndex] =
true;
404 size_t insertionIndex;
405 std::vector<bool> consideredCells;
407 std::vector<std::pair<bool,size_t> > indexMapper;
408 std::vector<std::unique_ptr<ShapeFunctionSet>> shapeFunctionSets;
A local to global mapper implementation for boundary spaces, with functions defined on the domain bou...
BoundarySpace_Detail::ShapeFunctionSetRestriction< Implementation >::type ShapeFunctionSetImplementation
bool inDomain(typename GridView::Intersection const &face) const
BoundaryMapper(GridView const &gridView, int order, std::vector< T > const &boundaryIds_, std::vector< T > const &usedIds_, Functor boundaryIdsToInts)
A degrees of freedom manager for globally continuous FEFunctionSpace s of piecewise polynomials.
A degrees of freedom manager for globally continuous FEFunctionSpace s of piecewise polynomials.
A degrees of freedom manager for globally continuous FEFunctionSpace s of piecewise polynomials.
A degrees of freedom manager for FEFunctionSpace s of piecewise polynomials of order Order.
A degrees of freedom manager for FEFunctionSpace s of piecewise polynomials of order Order.
A class for representing finite element functions.
Restricted shape function set. Introduces a new local ordering for the shape functions....
size_t subIndex(IndexSet const &is, Cell const &cell, int codim, int subentity)
int numFaces()
numFaces: Counts number of faces on which this boundaryMapper is defined. This costs some time so use...
BoundaryMapper(GridView const &gridView, int order, std::vector< int > const &boundaryIds_, std::vector< int > const &usedIds_)
BoundaryMapper: Create a boundary mapper over parts of the boundary.
BoundaryMapper(GridView const &gridView, int order)
BoundaryMapper: Create a boundary mapper over the entire boundary.
void forEachBoundaryFace(GridView const &gridView, Functor functor)
iterates over each boundary face and applies functor to face. Each boundary face is visited exactly o...
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
bool considerFace(Face const &face, std::vector< int > const &boundaryIds, std::vector< int > const &usedIds)
Type of the FunctionSpaceElement, associated to the FEFunctionSpace.
FunctionSpaceElement< FEFunctionSpace< BoundaryMapper >, m > type
ContinuousHierarchicExtensionMapperImplementation< Scalar, GridView, RestrictToBoundary > type
ContinuousHierarchicMapperImplementation< Scalar, GridView, RestrictToBoundary > type
ContinuousLagrangeMapperImplementation< Scalar, GridView, RestrictToBoundary > type
BOUNDARY_MAPPERS_ARE_NOT_YET_IMPLEMENTED_FOR_DISCONTINUOUS_SPACES type
BOUNDARY_MAPPERS_ARE_NOT_YET_IMPLEMENTED_FOR_DISCONTINUOUS_SPACES type
Choose implementation for mapper. Not the best design, but works...
boost::compressed_pair< bool, int > type
boost::compressed_pair< bool, int > type
boost::compressed_pair< bool, Empty > type
RestrictedShapeFunctionSet< HierarchicSimplexShapeFunctionSet< typename GridView::Grid::ctype, GridView::Grid::dimension, Scalar > > type
RestrictedShapeFunctionSet< HierarchicExtensionSimplexShapeFunctionSet< typename GridView::Grid::ctype, GridView::Grid::dimension, Scalar > > type
RestrictedShapeFunctionSet< LagrangeSimplexShapeFunctionSet< typename GridView::Grid::ctype, GridView::Grid::dimension, Scalar > > type
get restricted shape function set for simplicial grid