Commit 397b001a authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Preparation for redistribute

parent 129ccedd
......@@ -116,6 +116,16 @@ namespace INMOST
(void) size;
element->Integer(tag) = std::min(element->Integer(tag),*((const INMOST_DATA_INTEGER_TYPE *)data));
}
void ReduceUnion(const Tag & tag, const Element & element, const INMOST_DATA_BULK_TYPE * data, INMOST_DATA_ENUM_TYPE size)
{
(void) size;
const INMOST_DATA_INTEGER_TYPE * idata = (const INMOST_DATA_INTEGER_TYPE *)data;
Storage::integer_array odata = element->IntegerArray(tag);
std::vector<int> tmp(size+odata.size());
tmp.resize(std::set_union(odata.begin(),odata.end(),idata,idata+size,tmp.begin())-tmp.begin());
odata.replace(odata.begin(),odata.end(),tmp.begin(),tmp.end());
}
/*
void AdaptiveMesh::PrintSetLocal(std::string offset, ElementSet it, std::stringstream& ss)
......@@ -867,6 +877,7 @@ namespace INMOST
EXIT_BLOCK();
//return number of refined cells
call_counter++;
ret = m->Integrate(ret);
EXIT_FUNC();
return ret != 0;
}
......@@ -1539,7 +1550,111 @@ namespace INMOST
EXIT_BLOCK();
call_counter++;
ret = m->Integrate(ret);
EXIT_FUNC();
return ret != 0;
}
#if defined(USE_PARTITIONER)
void AdaptiveMesh::SetNewOwner(ElementSet set, TagInteger owner)
{
if( set.HaveChild() )
{
if( set.Empty() ) owner[set] = INT_MAX;
for(ElementSet chld = set.GetChild(); chld.isValid(); chld = chld.GetSibling())
{
SetNewOwner(chld,owner);
owner[set] = std::min(owner[set],owner[chld]);
}
}
//for(ElementSet::iterator it = set.Begin(); it != set.End(); ++it)
// owner[set] = std::min(owner[set],owner[*it]);
}
void AdaptiveMesh::SetNewProcs(ElementSet set, TagIntegerArray procs)
{
std::vector<int> tmp;
for(ElementSet chld = set.GetChild(); chld.isValid(); chld = chld.GetSibling())
{
SetNewProcs(chld,procs);
Storage::integer_array pm = procs[set];
Storage::integer_array pc = procs[chld];
tmp.resize(pm.size()+pc.size());
tmp.resize(std::set_union(pm.begin(),pm.end(),pc.begin(),pc.end(),tmp.begin())-tmp.begin());
pm.replace(pm.begin(),pm.end(),tmp.begin(),tmp.end());
}
}
void AdaptiveMesh::RestoreParent(ElementSet set)
{
for(ElementSet chld = set.GetChild(); chld.isValid(); chld = chld.GetSibling())
RestoreParent(chld);
for(ElementSet::iterator it = set.Begin(); it != set.End(); ++it)
parent_set[*it] = set.GetHandle();
}
void AdaptiveMesh::Repartition()
{
if( !root.isValid() ) return;
TagInteger redist = m->RedistributeTag();
TagInteger new_owner = m->CreateTag("TEMPORARY_NEW_OWNER",DATA_INTEGER,ESET, NONE,1); //workaround for sets
TagIntegerArray new_procs = m->CreateTag("TEMPORARY_NEW_PROCESSORS",DATA_INTEGER,ESET, NONE);
for(Storage::integer it = 0; it < m->EsetLastLocalID(); ++it) if( m->isValidElementSet(it) )
{
ElementSet set = m->EsetByLocalID(it);
new_owner[set] = INT_MAX;
new_procs[set].clear();
}
std::cout << __FUNCTION__ << ":" << __FILE__ << ":" << __LINE__ << std::endl;
for(Storage::integer it = 0; it < m->CellLastLocalID(); ++it) if( m->isValidCell(it) )
{
Cell c = m->CellByLocalID(it);
ElementSet parent(m,parent_set[c]);
std::cout << "cell:" << it << " gid " << c.GlobalID() << " has parent " << parent.LocalID() << " " << parent.GetName() << " redist " << redist[c] << std::endl;
new_owner[parent] = std::min(new_owner[parent],redist[c]);
Storage::integer_array procs = new_procs[parent];
Storage::integer_array::iterator insp = std::lower_bound(procs.begin(),procs.end(),redist[c]);
if( insp == procs.end() || *insp != redist[c] ) procs.insert(insp,redist[c]);
}
SetNewOwner(root,new_owner);
SetNewProcs(root,new_procs);
m->ReduceData(new_owner,ESET,0,ReduceMin);
m->ExchangeData(new_owner,ESET,0);
m->ReduceData(new_procs,ESET,0,ReduceUnion);
m->ExchangeData(new_procs,ESET,0);
for(Storage::integer it = 0; it < m->EsetLastLocalID(); ++it) if( m->isValidElementSet(it) )
{
ElementSet set = m->EsetByLocalID(it);
Storage::integer_array old_p = set->IntegerArray(m->ProcessorsTag());
Storage::integer_array new_p = new_procs[set];
Storage::integer_array sendto = set->IntegerArray(m->SendtoTag());
sendto.resize(std::max(old_p.size(),new_p.size()));
sendto.resize(std::set_difference(new_p.begin(),new_p.end(),old_p.begin(),old_p.end(),sendto.begin())-sendto.begin());
}
std::cout << __FUNCTION__ << ":" << __FILE__ << ":" << __LINE__ << std::endl;
for(Storage::integer it = 0; it < m->EsetLastLocalID(); ++it) if( m->isValidElementSet(it) )
{
ElementSet set = m->EsetByLocalID(it);
if( new_owner[set] == INT_MAX ) std::cout << "no new owner for set " << it << " " << set.GetName() << std::endl;
}
for(Storage::integer it = 0; it < m->CellLastLocalID(); ++it) if( m->isValidCell(it) )
{
Cell c = m->CellByLocalID(it);
if( parent_set[c] == InvalidHandle() ) std::cout << "No parent set for cell:" << it << " gid " << c.GlobalID() << std::endl;
}
m->BeginModification();
m->Redistribute();
m->ExchangeData(hanging_nodes,CELL|FACE,0); //maybe will work
m->ApplyModification(); //this will correctly remove links
m->EndModification();
m->ReorderEmpty(CELL|FACE|EDGE|NODE);
RestoreParent(root);
std::cout << __FUNCTION__ << ":" << __FILE__ << ":" << __LINE__ << std::endl;
for(Storage::integer it = 0; it < m->CellLastLocalID(); ++it) if( m->isValidCell(it) )
{
Cell c = m->CellByLocalID(it);
if( parent_set[c] == InvalidHandle() ) std::cout << "No parent set for cell:" << it << " gid " << c.GlobalID() << std::endl;
}
}
#endif
}
......@@ -20,6 +20,9 @@ namespace INMOST
void PrepareSet();
//void PrintSetLocal(std::string offset, ElementSet it, std::stringstream& ss);
void SynchronizeIndicated(TagInteger& indicator);
void SetNewOwner(ElementSet set, TagInteger owner);
void SetNewProcs(ElementSet set, TagIntegerArray procs);
void RestoreParent(ElementSet set);
public:
TagReference parent_set; //<Link to the set that contains an element.
TagReferenceArray hanging_nodes; //< Link to current hanging nodes of the cell.
......@@ -37,6 +40,7 @@ namespace INMOST
void ClearData();
void PrintSet(std::ostream & fout, ElementSet set);
void SetModel(Model * mm) {model = mm;}
void Repartition();
//void Test();
//void PrintMesh(std::ostream& os, int cell = 0, int face = 0, int edge = 0, int node = 0);
//void PrintSet();
......
......@@ -28,7 +28,7 @@ int main(int argc, char ** argv)
//std::cout << "after on " << m.GetProcessorRank() << " " << m.NumberOfCells() << std::endl;
}
#endif
m.ExchangeGhost(2,NODE);
m.ExchangeGhost(2,FACE);
AdaptiveMesh am(m);
//m.SetTopologyCheck(NEED_TEST_CLOSURE);
//m.SetTopologyCheck(PROHIBIT_MULTILINE);
......@@ -93,16 +93,14 @@ int main(int argc, char ** argv)
}
else indicator[*it] = 0;
}
numref = m.Integrate(numref);
if( numref )
if( m.Integrate(numref) )
{
int ncells = m.TotalNumberOf(CELL);
if( m.GetProcessorRank() == 0 )
std::cout << "k " << k << " refcnt " << refcnt << " " << r*k << " < r < " << r*(k+1) << " numref " << numref << " cells " << ncells << std::endl;
std::cout << "k " << k << " refcnt " << refcnt << " " << r*k << " < r < " << r*(k+1) << " cells " << ncells << std::endl;
int res = am.Refine(indicator);
res = m.Integrate(res);
if (!res) break;
if (!am.Refine(indicator)) break;
if( false )
{
......@@ -139,24 +137,13 @@ int main(int argc, char ** argv)
}
else indicator[*it] = 0;
}
numref = m.Integrate(numref);
if( numref )
if( m.Integrate(numref) )
{
int ncells = m.TotalNumberOf(CELL);
if( m.GetProcessorRank() == 0 )
std::cout << ": k " << k << " crscnt " << refcnt << " " << r*k << " < r < " << r*(k+1) << " numcrs " << numref << " cells " << ncells << std::endl;
//if( k == 5 && refcnt == 1 ) exit(-1);
if( false )
{
std::stringstream file;
file << "crsind_" << k << "_" << refcnt << ".pvtk";
m.Save(file.str());
if( m.GetProcessorRank() == 0 )
std::cout << "Save " << file.str() << std::endl;
}
int res = am.Coarse(indicator);
res = m.Integrate(res);
if( !res ) break;
std::cout << ": k " << k << " crscnt " << refcnt << " " << r*k << " < r < " << r*(k+1) << " cells " << ncells << std::endl;
if( !am.Coarse(indicator) ) break;
if( false )
{
......@@ -173,22 +160,19 @@ int main(int argc, char ** argv)
}
while(numref);
/*
#if defined(USE_PARTITIONER)
if( true )
if( false )
{
//std::cout << "before on " << m.GetProcessorRank() << " " << m.NumberOfCells() << std::endl;
p.Evaluate();
m.Redistribute();
m.ReorderEmpty(CELL|FACE|EDGE|NODE);
//std::cout << "after on " << m.GetProcessorRank() << " " << m.NumberOfCells() << std::endl;
am.Repartition();
}
#endif
*/
if( false )
if( true )
{
TagInteger tag_owner = m.CreateTag("OWN",DATA_INTEGER,CELL,NONE,1);
TagInteger tag_owner0 = m.GetTag("OWNER_PROCESSOR");
......
......@@ -3961,12 +3961,11 @@ namespace INMOST
std::vector<INMOST_DATA_ENUM_TYPE> low_conn_nums; // array composed elements : ElementType and position in array
std::vector<Storage::integer> high_conn_nums(selems[4].size() * 3); // array of indexes of children, sibling, parent. -1 if has't
std::vector<char> names_buff;
INMOST_DATA_ENUM_TYPE num_high = 0;
position = static_cast<int>(buffer.size());
new_size = 0;
num = 0; k = 0;
int marked_for_data = 0, marked_shared = 0;
int names_buff_size = 0;
//int names_buff_size = 0;
// Pack sequence:
// 1) all names of sets
......@@ -3974,9 +3973,9 @@ namespace INMOST
// 3) high conn for sets (3 arr_pos: child, sibling, parent. -1 if has't)
// Compute names_buff_size
for(element_set::iterator it = selems[4].begin(); it != selems[4].end(); it++) names_buff_size += ElementSet(this,*it).GetName().size() + 1;
names_buff.resize(names_buff_size);
int names_buff_pos = 0;
//for(element_set::iterator it = selems[4].begin(); it != selems[4].end(); it++) names_buff_size += ElementSet(this,*it).GetName().size() + 1;
//names_buff.resize(names_buff_size);
//int names_buff_pos = 0;
//MarkerType pack_set = CreateMarker();
//if( selems[4].size() ) SetMarkerArray(&selems[4][0],selems[4].size(),pack_set);
for(element_set::iterator it = selems[4].begin(); it != selems[4].end(); it++)
......@@ -3985,8 +3984,9 @@ namespace INMOST
Storage::integer & owner = Integer(*it,tag_owner);
// if( GetStatus(*it) == Element::Owned || GetStatus(*it) == Element::Any )
// owner = mpirank;
//if( GetStatus(*it) == Element::Owned || GetStatus(*it) == Element::Any )
// owner = mpirank;
//REPORT_STR("set name \"" << set.GetName() << "\" owner " << owner);
if( owner == mpirank )
{
......@@ -4010,30 +4010,33 @@ namespace INMOST
}
// Add set name to names_buffer
strcpy(&names_buff[names_buff_pos],set.GetName().c_str());
names_buff[names_buff_pos+set.GetName().length()] = '\0';
names_buff_pos += set.GetName().length() + 1;
std::string set_name = set.GetName();
names_buff.insert(names_buff.end(),set_name.begin(),set_name.end());
names_buff.push_back('\0');
//strcpy(&names_buff[names_buff_pos],set.GetName().c_str());
//names_buff[names_buff_pos+set.GetName().length()] = '\0';
//names_buff_pos += set.GetName().length() + 1;
// Add all low conns to low_conn_nums
low_conn_size[k] = 0;
//ElementSet::ExchangeType exch = set.Bulk(SetExchangeTag());
//if( exch != ElementSet::SYNC_ELEMENTS_NONE )
assert(!Hidden(*it));
Element::adj_type const & lc = LowConn(*it);
for(Element::adj_type::const_iterator jt = lc.begin(); jt != lc.end(); jt++)
{
Element::adj_type const & lc = LowConn(*it);
for(Element::adj_type::const_iterator jt = lc.begin(); jt != lc.end(); jt++) if( *jt != InvalidHandle() && !Hidden(*jt) )
if( *jt != InvalidHandle() && !Hidden(*jt) && GetMarker(*jt,busy) )
{
if( GetMarker(*jt,busy) )
{
INMOST_DATA_INTEGER_TYPE el_num = GetHandleElementNum(*jt);
assert( GetMarker(*jt,busy) );
assert(*jt == selems[el_num][Integer(*jt,arr_position)]);
assert(Integer(*jt,arr_position) == Integer(selems[el_num][Integer(*jt,arr_position)],arr_position));
low_conn_nums.push_back(ComposeHandle(GetHandleElementType(*jt), Integer(*jt,arr_position)));
low_conn_size[k]++;
num++;
}
INMOST_DATA_INTEGER_TYPE el_num = GetHandleElementNum(*jt);
assert( GetMarker(*jt,busy) );
assert(*jt == selems[el_num][Integer(*jt,arr_position)]);
assert(Integer(*jt,arr_position) == Integer(selems[el_num][Integer(*jt,arr_position)],arr_position));
low_conn_nums.push_back(ComposeHandle(GetHandleElementType(*jt), Integer(*jt,arr_position)));
low_conn_size[k]++;
num++;
}
}
if( set.HaveChild() )
assert(k*3 + 2 < high_conn_nums.size());
if( set.HaveChild() )
{
assert(set.GetChild().GetMarker(busy));
assert(set.GetChild().GetHandle() == selems[4][Integer(set.GetChild().GetHandle(),arr_position)]);
......@@ -4067,15 +4070,16 @@ namespace INMOST
//ReleaseMarker(pack_set);
MPI_Pack_size(1 ,INMOST_MPI_DATA_ENUM_TYPE ,comm,&temp); new_size += temp; // count of sets
MPI_Pack_size(1 ,INMOST_MPI_DATA_ENUM_TYPE ,comm,&temp); new_size += temp; // names_buff_size
MPI_Pack_size(static_cast<INMOST_MPI_SIZE>(names_buff_size) ,INMOST_MPI_DATA_BULK_TYPE ,comm,&temp); new_size += temp; // names_buff
MPI_Pack_size(static_cast<INMOST_MPI_SIZE>(names_buff.size()) ,MPI_CHAR ,comm,&temp); new_size += temp; // names_buff
MPI_Pack_size(static_cast<INMOST_MPI_SIZE>(selems[4].size()) ,INMOST_MPI_DATA_ENUM_TYPE ,comm,&temp); new_size += temp; // low_conn_sizes array
MPI_Pack_size(static_cast<INMOST_MPI_SIZE>(num) ,INMOST_MPI_DATA_ENUM_TYPE ,comm,&temp); new_size += temp; // low_conn_nums array
MPI_Pack_size(static_cast<INMOST_MPI_SIZE>(selems[4].size()*3),INMOST_MPI_DATA_INTEGER_TYPE,comm,&temp); new_size += temp; // high_conn_nums array
buffer.resize(position+new_size);
temp = static_cast<INMOST_DATA_ENUM_TYPE>(selems[4].size());
MPI_Pack(&temp ,1 ,INMOST_MPI_DATA_ENUM_TYPE ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
MPI_Pack(&names_buff_size ,1 ,INMOST_MPI_DATA_ENUM_TYPE ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
if( names_buff_size > 0 ) MPI_Pack(&names_buff[0] ,static_cast<INMOST_MPI_SIZE>(names_buff_size) ,MPI_CHAR ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
MPI_Pack(&temp ,1 ,INMOST_MPI_DATA_ENUM_TYPE ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
temp = static_cast<INMOST_DATA_ENUM_TYPE>(names_buff.size());
MPI_Pack(&temp ,1 ,INMOST_MPI_DATA_ENUM_TYPE ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
if( !names_buff.empty() ) MPI_Pack(&names_buff[0] ,static_cast<INMOST_MPI_SIZE>(names_buff.size()) ,MPI_CHAR ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
if( !low_conn_size.empty() ) MPI_Pack(&low_conn_size[0] ,static_cast<INMOST_MPI_SIZE>(selems[4].size()) ,INMOST_MPI_DATA_ENUM_TYPE ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
if( !low_conn_nums.empty() ) MPI_Pack(&low_conn_nums[0] ,static_cast<INMOST_MPI_SIZE>(num) ,INMOST_MPI_DATA_ENUM_TYPE ,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
if( selems[4].size() > 0 ) MPI_Pack(&high_conn_nums[0],static_cast<INMOST_MPI_SIZE>(selems[4].size()*3),INMOST_MPI_DATA_INTEGER_TYPE,&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,comm);
......@@ -4627,27 +4631,40 @@ namespace INMOST
//unpack esets
ENTER_BLOCK();
{
ElementArray<Face> c_faces(this);
ElementArray<Node> c_nodes(this);
std::vector<char> names_buff;
std::vector<INMOST_DATA_ENUM_TYPE> low_conn_size;
std::vector<INMOST_DATA_ENUM_TYPE> low_conn_nums;
std::vector<Storage::integer> high_conn_nums;
INMOST_DATA_ENUM_TYPE shift_high = 0;
INMOST_DATA_ENUM_TYPE names_buff_size = 0;
shift = 0;
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&num,1,INMOST_MPI_DATA_ENUM_TYPE,comm);
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&names_buff_size,1,INMOST_MPI_DATA_ENUM_TYPE,comm);
names_buff.resize(names_buff_size);
if( names_buff_size != 0 ) MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&names_buff[0],static_cast<INMOST_MPI_SIZE>(names_buff_size),MPI_CHAR,comm);
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&temp,1,INMOST_MPI_DATA_ENUM_TYPE,comm);
REPORT_VAL("number of sets ",num);
REPORT_VAL("length of buffer ",temp);
names_buff.resize(temp);
if( temp ) MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&names_buff[0],static_cast<INMOST_MPI_SIZE>(temp),MPI_CHAR,comm);
// Gather sets names to array
int pos = 0;
high_conn_nums.resize(num*3);
low_conn_size.resize(num);
if( num ) // Unpack low_conn_size array
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&low_conn_size[0],static_cast<INMOST_MPI_SIZE>(num),INMOST_MPI_DATA_ENUM_TYPE,comm);
temp = 0;
for(INMOST_DATA_ENUM_TYPE i = 0; i < num; i++) temp += low_conn_size[i];
low_conn_nums.resize(temp);
if( temp ) // Unpack low_conn_nums array
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&low_conn_nums[0],static_cast<INMOST_MPI_SIZE>(temp),INMOST_MPI_DATA_ENUM_TYPE,comm);
if( num ) // Unpack high_conn_nums array
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&high_conn_nums[0],static_cast<INMOST_MPI_SIZE>(num*3),INMOST_MPI_DATA_INTEGER_TYPE,comm);
REPORT_VAL("buffer position",position);
std::vector<std::string> names;
while (pos < names_buff_size)
int pos = 0;
while (pos < names_buff.size())
{
names.push_back(std::string(&names_buff[pos]));
pos += names[names.size() - 1].length() + 1;
pos += names.back().length() + 1;
}
assert(names.size() == num);
// Looking to all names and create the sets if it's needed
int found = 0, marked_for_data = 0, marked_ghost = 0;
for (int i = 0; i < names.size(); i++)
......@@ -4672,6 +4689,8 @@ namespace INMOST
}
else
{
//REPORT_VAL("found old ",set->GetHandle());
//REPORT_VAL("owner ",IntegerDF(set.GetHandle(),tag_owner));
if( IntegerDF(set.GetHandle(),tag_owner) != mpirank )
{
//TODO 46 old
......@@ -4689,20 +4708,8 @@ namespace INMOST
selems[4].push_back(set.GetHandle());
}
high_conn_nums.resize(num*3);
low_conn_size.resize(num);
if( num )
{
// Unpack low_conn_size array
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&low_conn_size[0],static_cast<INMOST_MPI_SIZE>(num),INMOST_MPI_DATA_ENUM_TYPE,comm);
temp = 0;
for(INMOST_DATA_ENUM_TYPE i = 0; i < num; i++) temp += low_conn_size[i];
low_conn_nums.resize(temp);
// Unpack low_conn_num array
if( temp )
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&low_conn_nums[0],static_cast<INMOST_MPI_SIZE>(temp),INMOST_MPI_DATA_ENUM_TYPE,comm);
MPI_Unpack(&buffer[0],static_cast<INMOST_MPI_SIZE>(buffer.size()),&position,&high_conn_nums[0],static_cast<INMOST_MPI_SIZE>(num*3),INMOST_MPI_DATA_INTEGER_TYPE,comm);
// Add low conns for sets
int ind = 0;
for (INMOST_DATA_ENUM_TYPE i = 0; i < num; i++)
......@@ -5259,10 +5266,12 @@ namespace INMOST
if( !it->second.empty() )
{
//Have packed all entities, now delete those entities that i should not own
for(int k = 0; k < 5; ++k)
for(element_set::iterator kt = it->second[k].begin(); kt != it->second[k].end(); kt++)
if( !GetMarker(*kt,delete_marker) )
for(ElementType etype = NODE; etype <= ESET; etype = NextElementType(etype)) if( tag_new_processors.isDefined(etype) )
{
int k = ElementNum(etype);
for(element_set::iterator kt = it->second[k].begin(); kt != it->second[k].end(); kt++) if( !GetMarker(*kt,delete_marker) )
{
if( IntegerArray(*kt,tag_new_processors).empty() ) continue; //don't delete elements without processors
Storage::integer_array procs = IntegerArray(*kt,tag_new_processors);
if( !std::binary_search(procs.begin(),procs.end(),mpirank) )
{
......@@ -5270,6 +5279,7 @@ namespace INMOST
SetMarker(*kt,delete_marker);
}
}
}
}
}
//Should delete elements in order by CELL..NODE
......@@ -5278,7 +5288,8 @@ namespace INMOST
REPORT_VAL("number of edges to delete",delete_elements[1].size());
REPORT_VAL("number of faces to delete",delete_elements[2].size());
REPORT_VAL("number of cells to delete",delete_elements[3].size());
for(int j = ElementNum(CELL); j >= ElementNum(NODE); j--)
REPORT_VAL("number of esets to delete",delete_elements[4].size());
for(int j = ElementNum(ESET); j >= ElementNum(NODE); j--)
{
//this is not really needed because we destroy those elements
for(element_set::iterator kt = delete_elements[j].begin(); kt != delete_elements[j].end(); ++kt) RemMarker(*kt,delete_marker);
......@@ -5290,10 +5301,11 @@ namespace INMOST
REPORT_STR("Deleting some other not owned elements");
//now delete elements that we have not yet deleted
int count = 0;
for(ElementType etype = NODE; etype <= CELL; etype = NextElementType(etype))
for(ElementType etype = NODE; etype <= ESET; etype = NextElementType(etype)) if( tag_new_processors.isDefined(etype) )
for(iteratorElement it = BeginElement(etype); it != EndElement(); it++)
{
Storage::integer_array procs = it->IntegerArray(tag_new_processors);
if( procs.empty() ) continue;//don't delete elements without processors
if( !std::binary_search(procs.begin(),procs.end(),mpirank) )
{
//Destroy(*it);
......@@ -5358,9 +5370,10 @@ namespace INMOST
REPORT_STR("Computing new values");
Tag tag_new_owner = GetTag("TEMPORARY_NEW_OWNER");
Tag tag_new_processors = GetTag("TEMPORARY_NEW_PROCESSORS");
for(ElementType etype = NODE; etype <= CELL; etype = NextElementType(etype))
for(ElementType etype = NODE; etype <= ESET; etype = NextElementType(etype)) if( tag_new_owner.isDefined(etype) && tag_new_processors.isDefined(etype) )
for(iteratorElement it = BeginElement(etype); it != EndElement(); it++)
{
if( it->IntegerArray(tag_new_processors).empty() ) continue;
Storage::integer new_owner = it->Integer(tag_new_owner);
it->IntegerDF(tag_owner) = new_owner;
Storage::integer_array old_procs = it->IntegerArrayDV(tag_processors);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment