Hello,<div><br></div><div>I am trying to write some simple Poisson solver with P2 elements in Dune. I thought, this could be easily done using a LeafMultipleCodimMultipleGeomTypeMapper. I wrote some small helper class to map from local element indices to global indices in my linear system.</div>
<div><br></div><div>The problem is: the mapping of the DOF's is all messed up. I think the codim 2 entities (nodes) are not mapped correctly. I am pretty sure, that the bug hides somewhere in my get(Face)DOFMapping routines.</div>
<div><br></div><div>I have no idea what I could have done wrong here. I am trying to fix this for about 3 days now and did not make significant progress. Does anyone here see the problem? Any help is greatly appreciated! I am using <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Dune 1.2.1 and a ALUSimplex2D mesh.</span></div>
<div><br></div><div>Kind regards,</div><div><br></div><div>J. Gerno</div><div><br></div><div><br></div><div><br></div><div><br></div><div>==== CODE SNIPPET THAT PRODUCES THE WRONG MAPPING ====================================================================</div>
<div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>template<typename G></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>class P22DSpace</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>typedef G GridType;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>typedef typename GridType::ctype RealType;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>typedef typename GridType::LeafGridView::template Codim<0>::Iterator::Entity EntityType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>typedef Dune::P22DLocalFiniteElement<RealType, RealType> FiniteElementType;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>typedef Dune::P21DLocalFiniteElement<RealType, RealType> FaceFiniteElementType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Dune::ReferenceSimplex<double, 2> ref;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>template<int D></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>struct Layout</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>bool contains(Dune::GeometryType gt)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return gt.dim() == D-1 || gt.dim() == D-2;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>};</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>GridType const& grid;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>unsigned dofoff;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>FiniteElementType localfe;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>FaceFiniteElementType facefe;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Dune::LeafMultipleCodimMultipleGeomTypeMapper<GridType, Layout> mapper;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>public:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>P22DSpace(GridType const& grid, unsigned dofoff = 0) :</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>grid(grid), dofoff(dofoff), mapper(grid)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>FiniteElementType const& localFiniteElement() const</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return localfe;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>FaceFiniteElementType const& localFaceFiniteElement() const</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return facefe;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>size_t getDOFMapping(EntityType const& e, IndexVector& dofno) const</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno.resize(6);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>for(int i=0; i<3; i++)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno[i] = dofoff + mapper.template map<2>(e, ref.subEntity(0,0,i,2));</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>for(int i=0; i<3; i++)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno[i+3] = dofoff + mapper.template map<1>(e, ref.subEntity(0,0,i,1));</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return dofno.size();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>size_t getFaceDOFMapping(EntityType const& e, unsigned index, IndexVector& dofno) const</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno.resize(3);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno[0] = dofoff + mapper.template map<2>(e, ref.subEntity(index,1,0,2)); // node 1</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno[1] = dofoff + mapper.template map<2>(e, ref.subEntity(index,1,1,2)); // node 2</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>dofno[2] = dofoff + mapper.template map<1>(e, ref.subEntity(0,0,index,1)); // edge dof</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return dofno.size();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>unsigned size() const</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return mapper.size();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>static unsigned const order()</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>return 2;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>static unsigned const dim()</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>return 1;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>};</div>
<div><br></div></div>