Skip to content
Snippets Groups Projects
Commit baf1f9fd authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Implement GlobalP2Mapper for 1d grids

Otherwise the Cosserat rod code will not compile without dune-parmg.
parent 7d22b79b
No related branches found
No related tags found
1 merge request!67Modernize rod code
Pipeline #5484 passed
...@@ -26,54 +26,96 @@ namespace Dune { ...@@ -26,54 +26,96 @@ namespace Dune {
p2Mapper_(gridView) p2Mapper_(gridView)
{ {
#if !HAVE_DUNE_PARMG #if !HAVE_DUNE_PARMG
static_assert(GridView::dimension==2, "Only implemented for two-dimensional grids"); static_assert(GridView::dimension<=2, "Only implemented for one- and two-dimensional grids");
if (gridView.size(GeometryTypes::triangle)>1) if (gridView.size(GeometryTypes::triangle)>1)
DUNE_THROW(NotImplemented, "GlobalP2Mapper only works for quad grids!"); DUNE_THROW(NotImplemented, "GlobalP2Mapper only works for quad grids!");
GlobalIndexSet<GridView> globalVertexIndex(gridView,2); GlobalIndexSet<GridView> globalVertexIndex(gridView,GridView::dimension);
GlobalIndexSet<GridView> globalEdgeIndex(gridView,1);
GlobalIndexSet<GridView> globalElementIndex(gridView,0); GlobalIndexSet<GridView> globalElementIndex(gridView,0);
// total number of degrees of freedom
this->size_ = globalVertexIndex.size(2) + globalEdgeIndex.size(1) + globalElementIndex.size(0);
auto localView = p2Mapper_.localView(); auto localView = p2Mapper_.localView();
// Determine if (GridView::dimension==1)
for (const auto& element : elements(gridView))
{ {
localView.bind(element); // total number of degrees of freedom
this->size_ = globalVertexIndex.size(GridView::dimension) + globalElementIndex.size(0);
// Loop over all local degrees of freedom // Determine
for (size_t i=0; i<localView.size(); i++) for (const auto& element : elements(gridView))
{ {
int codim = localView.tree().finiteElement().localCoefficients().localKey(i).codim(); localView.bind(element);
int entity = localView.tree().finiteElement().localCoefficients().localKey(i).subEntity();
auto localIndex = localView.index(i); // Loop over all local degrees of freedom
int globalIndex; for (size_t i=0; i<localView.size(); i++)
switch (codim)
{ {
case 2: // vertex dofs int codim = localView.tree().finiteElement().localCoefficients().localKey(i).codim();
globalIndex = globalVertexIndex.index(element.template subEntity<2>(entity)); int entity = localView.tree().finiteElement().localCoefficients().localKey(i).subEntity();
break;
auto localIndex = localView.index(i);
case 1: // edge dofs int globalIndex;
globalIndex = globalEdgeIndex.index(element.template subEntity<1>(entity)) + globalVertexIndex.size(2); switch (codim)
break; {
case 1: // vertex dofs
case 0: // element dofs globalIndex = globalVertexIndex.index(element.template subEntity<1>(entity));
globalIndex = globalElementIndex.index(element.template subEntity<0>(entity)) break;
+ globalEdgeIndex.size(1)
+ globalVertexIndex.size(2); case 0: // element dofs
break; globalIndex = globalElementIndex.index(element.template subEntity<0>(entity))
+ globalVertexIndex.size(2);
default: break;
DUNE_THROW(Dune::Exception, "Impossible codimension!");
default:
DUNE_THROW(Dune::Exception, "Impossible codimension!");
}
localGlobalMap_[localIndex] = globalIndex;
} }
}
}
else
{
GlobalIndexSet<GridView> globalEdgeIndex(gridView,1);
localGlobalMap_[localIndex] = globalIndex; // total number of degrees of freedom
this->size_ = globalVertexIndex.size(2) + globalEdgeIndex.size(1) + globalElementIndex.size(0);
// Determine
for (const auto& element : elements(gridView))
{
localView.bind(element);
// Loop over all local degrees of freedom
for (size_t i=0; i<localView.size(); i++)
{
int codim = localView.tree().finiteElement().localCoefficients().localKey(i).codim();
int entity = localView.tree().finiteElement().localCoefficients().localKey(i).subEntity();
auto localIndex = localView.index(i);
int globalIndex;
switch (codim)
{
case 2: // vertex dofs
globalIndex = globalVertexIndex.index(element.template subEntity<GridView::dimension>(entity));
break;
case 1: // edge dofs
globalIndex = globalEdgeIndex.index(element.template subEntity<1>(entity)) + globalVertexIndex.size(2);
break;
case 0: // element dofs
globalIndex = globalElementIndex.index(element.template subEntity<0>(entity))
+ globalEdgeIndex.size(1)
+ globalVertexIndex.size(2);
break;
default:
DUNE_THROW(Dune::Exception, "Impossible codimension!");
}
localGlobalMap_[localIndex] = globalIndex;
}
} }
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment