Skip to content
Snippets Groups Projects
Commit 5acf6cc2 authored by Peter Bastian's avatar Peter Bastian
Browse files

Changed implementation of IDs.

- UG's id was overwritten in vertices because it was used by leaf index
- IDs are now unique over all codims and levels by ORing codim
- Parallel case not tested
- Still: IDs are only implemented for codims 0 and dim. Edges and faces can be done
fairly easily but are not required for P1 elements :-)

[[Imported from SVN: r2986]]
parent 87f6f986
No related branches found
No related tags found
No related merge requests found
......@@ -323,33 +323,26 @@ namespace Dune {
//! Gets the leaf index of a UG node
static int& leafIndex(TargetType<2,2>::T* theNode) {
return theNode->myvertex->iv.id;
return theNode->myvertex->iv.leafIndex;
}
//! Gets the leaf index of a UG node
static const int& leafIndex(const TargetType<2,2>::T* theNode) {
return theNode->myvertex->iv.id;
return theNode->myvertex->iv.leafIndex;
}
// /////////////////////////////////////////////
// IDs
// /////////////////////////////////////////////
//! Gets the index of a UG element
static int& id(TargetType<0,2>::T* theElement) {
return theElement->ge.id;
}
//! Gets the index of a UG element
static const int& id(const TargetType<0,2>::T* theElement) {
static unsigned int id(const TargetType<0,2>::T* theElement) {
return theElement->ge.id;
}
//! Gets the index of a UG node
static int& id(TargetType<2,2>::T* theNode) {
return theNode->id;
}
//! Gets the index of a UG node
static const int& id(const TargetType<2,2>::T* theNode) {
return theNode->id;
static unsigned int id(const TargetType<2,2>::T* theNode) {
return theNode->myvertex->iv.id | 0x80000000;
}
//! \todo Please doc me!
......
......@@ -324,33 +324,26 @@ namespace Dune {
//! Gets the leaf index of a UG node
static int& leafIndex(TargetType<3,3>::T* theNode) {
return theNode->myvertex->iv.id;
return theNode->myvertex->iv.leafIndex;
}
//! Gets the leaf index of a UG node
static const int& leafIndex(const TargetType<3,3>::T* theNode) {
return theNode->myvertex->iv.id;
return theNode->myvertex->iv.leafIndex;
}
// /////////////////////////////////////////////
// IDs
// /////////////////////////////////////////////
//! Gets the index of a UG element
static int& id(TargetType<0,3>::T* theElement) {
return theElement->ge.id;
}
//! Gets the index of a UG element
static const int& id(const TargetType<0,3>::T* theElement) {
static unsigned int id(const TargetType<0,3>::T* theElement) {
return theElement->ge.id;
}
//! Gets the index of a UG node
static int& id(TargetType<3,3>::T* theNode) {
return theNode->id;
}
//! Gets the index of a UG node
static const int& id(const TargetType<3,3>::T* theNode) {
return theNode->id;
static unsigned int id(const TargetType<3,3>::T* theNode) {
return theNode->myvertex->iv.id | 0xC0000000;
}
//! \todo Please doc me!
......
......@@ -213,23 +213,34 @@ inline int UGGridEntity<0, dim, GridImp>::subLeafIndex(int i) const
template <int dim, class GridImp>
template <int cc>
inline int UGGridEntity<0, dim, GridImp>::subGlobalId(int i) const
inline unsigned int UGGridEntity<0, dim, GridImp>::subGlobalId(int i) const
{
assert(i>=0 && i<count<cc>());
if (cc!=dim)
DUNE_THROW(GridError, "UGGrid::subGlobalId isn't implemented for cc != dim");
if (cc==0)
{
#ifdef ModelP
return UG_NS<dim>::Corner(target_,renumberVertex(i))->ddd.gid;
return target_->ddd.gid;
#else
return UG_NS<dim>::id(UG_NS<dim>::Corner(target_,renumberVertex(i)));
return UG_NS<dim>::id(target_);
#endif
}
if (cc==dim)
{
#ifdef ModelP
return UG_NS<dim>::Corner(target_,renumberVertex(i))->ddd.gid;
#else
return UG_NS<dim>::id(UG_NS<dim>::Corner(target_,renumberVertex(i)));
#endif
}
DUNE_THROW(GridError, "UGGrid<" << dim << "," << dim << ">::subGlobalId isn't implemented for cc==" << cc );
return 0;
}
template <int dim, class GridImp>
template <int cc>
inline int UGGridEntity<0, dim, GridImp>::subLocalId(int i) const
inline unsigned int UGGridEntity<0, dim, GridImp>::subLocalId(int i) const
{
assert(i>=0 && i<count<cc>());
......
......@@ -103,19 +103,17 @@ namespace Dune {
int leafIndex() const {
return UG_NS<dim>::leafIndex(target_);
// return target_->myvertex->iv.id;
}
unsigned int localId() const {
return UG_NS<dim>::id(target_);
// return target_->id;
}
unsigned int globalId() const {
#ifdef ModelP
return target_->ddd.gid;
#else
return target_->id;
return UG_NS<dim>::id(target_);
#endif
}
......@@ -286,12 +284,12 @@ namespace Dune {
/** \brief Return global id of sub entity with codim = cc and local number i
*/
template<int cc>
int subGlobalId (int i) const;
unsigned int subGlobalId (int i) const;
/** \brief Return local id of sub entity with codim = cc and local number i
*/
template<int cc>
int subLocalId (int i) const;
unsigned int subLocalId (int i) const;
/** \brief Provide access to sub entity i of given codimension. Entities
......
......@@ -746,7 +746,7 @@ namespace Dune {
public:
//! define the type used for persistent local ids
typedef uint LocalIdType;
typedef unsigned int LocalIdType;
//! get id of an entity
template<int cd>
......
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