Skip to content
Snippets Groups Projects
Commit 00825730 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Do not use an iterator over the entities we want a global numbering for

Iterators over entities are only mandatory for vertices and elements.
But here the user may also request indices for other entities.
Hence one cannot use a straight iterator.

[[Imported from SVN: r9759]]
parent 8ea612fd
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@ private:
typedef typename GridView::Grid::GlobalIdSet GlobalIdSet;
typedef typename GridView::Grid::GlobalIdSet::IdType IdType;
typedef typename GridView::Traits::template Codim<CODIM>::Iterator Iterator;
typedef typename GridView::Traits::template Codim<0>::Iterator Iterator;
typedef typename GridView::Traits::template Codim<CODIM>::Entity Entity;
......@@ -196,9 +196,7 @@ public:
nLocalEntity_=0;
nGlobalEntity_=0;
for(Iterator iter = gridview_.template begin<CODIM>();iter!=gridview_.template end<CODIM>(); ++iter)
if(uniqueEntityPartition_.owner((*iter)) == true)
++nLocalEntity_;
nLocalEntity_ = uniqueEntityPartition_.numOwners();
/** compute the global, non-redundant number of entities, i.e. the number of entities in the set
......@@ -255,27 +253,41 @@ public:
int globalcontrib=0; /** initialize contribution for the global index */
for(Iterator iter = gridview_.template begin<CODIM>();iter!=gridview_.template end<CODIM>(); ++iter)
std::vector<bool> firstTime(gridview_.size(CODIM));
std::fill(firstTime.begin(), firstTime.end(), true);
for(Iterator iter = gridview_.template begin<0>();iter!=gridview_.template end<0>(); ++iter)
{
for (size_t i=0; i<iter->template count<CODIM>(); i++)
{
IdType id=globalIdSet.id(*iter); /** retrieve the entity's id */
if(uniqueEntityPartition_.owner(*iter) == true) /** if the entity is owned by the process, go ahead with computing the global index */
{
const int gindex = myoffset + globalcontrib; /** compute global index */
globalIndex.insert(std::make_pair(id,gindex)); /** insert pair (key, dataum) into the map */
const int lindex = indexSet.index(*iter);
localGlobalMap_[lindex] = gindex;
globalLocalMap_[gindex] = lindex;
globalcontrib++; /** increment contribution to global index */
}
else /** if entity is not owned, insert -1 to signal not yet calculated global index */
{
globalIndex.insert(std::make_pair(id,-1));
}
IdType id=globalIdSet.subId(*iter,i,CODIM); /** retrieve the entity's id */
int idx = gridview_.indexSet().subIndex(*iter,i,CODIM);
if (! firstTime[idx] )
continue;
firstTime[idx] = false;
if(uniqueEntityPartition_.owner(idx) == true) /** if the entity is owned by the process, go ahead with computing the global index */
{
const int gindex = myoffset + globalcontrib; /** compute global index */
globalIndex.insert(std::make_pair(id,gindex)); /** insert pair (key, value) into the map */
const int lindex = idx;
localGlobalMap_[lindex] = gindex;
globalLocalMap_[gindex] = lindex;
globalcontrib++; /** increment contribution to global index */
}
else /** if entity is not owned, insert -1 to signal not yet calculated global index */
{
globalIndex.insert(std::make_pair(id,-1));
}
}
}
/** 2nd stage of global index calculation: communicate global index for non-owned entities */
// Create the data handle and communicate.
......
......@@ -148,6 +148,17 @@ public:
}
}
/** answer question if entity belongs to me, to this process */
bool owner(size_t i)
{
return assignment_[i];
}
size_t numOwners() const
{
return std::accumulate(assignment_.begin(), assignment_.end(), 0);
}
/** answer question if entity belongs to me, to this process */
bool owner(const Entity& entity)
{
......
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