Commit fb1b5fda authored by SilverLife's avatar SilverLife
Browse files

Fixed status definition after coarse. Added ComputeSharedSkin by marker.

parent 9924abdb
#include "amesh.h"
#include <iomanip>
#include <set>
using namespace std;
......@@ -620,25 +621,31 @@ namespace INMOST
DeleteTag(indicator,FACE|EDGE);
stringstream ss;
ss << ro() << rank << ": during refine: ";
MarkerType marker_new = CreateMarker();
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); ++it)
{
int marked = (it->GetMarker(NewMarker())) ? 1 : 0;
int st = 0;
if (it->GetStatus() == Element::Shared) st = 1;
else if (it->GetStatus() == Element::Ghost) st = 2;
//tag_an[it->self()] = it->IntegerDF(OwnerTag());
tag_an[it->self()] = marked;
ss << "(" << it->GlobalID() << "," << level[it->self()] << "," << marked << ") ";
if (it->GetMarker(NewMarker()) == false) continue;
it->SetMarker(marker_new);
}
for(Mesh::iteratorFace it = BeginFace(); it != EndFace(); ++it)
{
if (it->GetMarker(NewMarker()) == false) continue;
it->SetMarker(marker_new);
}
for(Mesh::iteratorEdge it = BeginEdge(); it != EndEdge(); ++it)
{
if (it->GetMarker(NewMarker()) == false) continue;
it->SetMarker(marker_new);
}
for(Mesh::iteratorNode it = BeginNode(); it != EndNode(); ++it)
{
int marked = (it->GetMarker(NewMarker())) ? 1 : 0;
tag_an[it->self()] = marked;
if (it->GetMarker(NewMarker()) == false) continue;
it->SetMarker(marker_new);
}
//cout << ss.str() << endl;
//11. Restore parallel connectivity, global ids
......@@ -653,6 +660,9 @@ namespace INMOST
//cout << rank << ": Before end " << endl;
EndModification();
CheckCentroids();
//RemoveGhost(&marker_new);
//ExchangeGhost(1,FACE,&marker_new); // Construct Ghost cells in 2 layers connected via nodes
//ReleaseMarker(marker_new);
//ExchangeData(hanging_nodes,CELL | FACE,0);
//cout << rank << ": After end " << endl;
//reorder element's data to free up space
......
......@@ -2254,7 +2254,7 @@ namespace INMOST
int parallel_file_strategy;
private:
void ComputeSharedProcs ();
proc_elements ComputeSharedSkinSet(ElementType bridge);
proc_elements ComputeSharedSkinSet(ElementType bridge, MarkerType* marker = NULL);
void PackTagData (const Tag & tag, const elements_by_type & elements, int destination, ElementType mask, MarkerType select, buffer_type & buffer);
void UnpackTagData (const Tag & tag, const elements_by_type & elements, ElementType mask, MarkerType select, buffer_type & buffer, int & position, ReduceOperation op);
void PackElementsData (element_set & input, buffer_type & buffer, int destination, const std::vector<std::string> & tag_list);
......@@ -2426,7 +2426,7 @@ namespace INMOST
/// Find sets that are common between processors.
void ResolveSets ();
/// Delete all the ghost cells.
void RemoveGhost ();
void RemoveGhost (MarkerType* marker = NULL);
/// Delete some ghost cells provided in array.
/// Non-ghost elements will also be deleted.
///
......@@ -2681,7 +2681,7 @@ namespace INMOST
/// @param bridge bitwise mask of elements for which neighbouring cells should be considered a layer
/// @see Mesh::ExchangeMarked
/// @see Mesh::Redistribute
void ExchangeGhost (integer layers, ElementType bridge);
void ExchangeGhost (integer layers, ElementType bridge, MarkerType* marker = NULL);
/// Migrate all the elements to the new owners prescribed in data corresponding to RedistributeTag.
/// This will perform all the actions to send mesh elements and data and reproduce new mesh partitions
/// on remote elements and correctly resolve parallel state of the mesh. If you have priviously
......@@ -3168,6 +3168,7 @@ namespace INMOST
enumerator getNext (const HandleType * arr, enumerator size, enumerator k, MarkerType marker) const;
enumerator Count (const HandleType * arr, enumerator size, MarkerType marker) const;
void Dijkstra();
void CheckFaces();
void CheckCentroids();
//implemented in mesh.cpp
private:
......
......@@ -525,6 +525,9 @@ namespace INMOST
aret.data()[1] = temp;
}
adj_type::size_type it = i, iend = lc.size()-1;
while (m->GetMarker(lc[iend],hm) && iend > 0) iend--;
while(it != iend)
{
if( !m->GetMarker(lc[it],hm) ) //loop over edges
......@@ -539,7 +542,7 @@ namespace INMOST
else
aret.push_back(ilc[k1]);
}
++it;
++it;
}
}
......
......@@ -168,6 +168,37 @@ namespace INMOST
e->SetData(tag,old_size,size,data);
}
}
void Mesh::CheckFaces()
{
std::cout << "Check faces" << endl;
for(Mesh::iteratorFace it = BeginFace(); it != EndFace(); ++it)
{
std::set<int> set_nodes;
ElementArray<Node> nodes = it->getNodes();
bool suc = true;
for (ElementArray<Node>::iterator node = nodes.begin(); node != nodes.end(); node++)
if (set_nodes.find(node->LocalID()) != set_nodes.end())
{
suc = false;
break;
}
else
{
set_nodes.insert(node->LocalID());
}
if (suc) std::cout << "-=== Good face: " << setw(2) << it->LocalID();
else std::cout << "-=== Error face: " << setw(2) << it->LocalID();
cout << ". Nodes = " << nodes.size() << ": ";
for (ElementArray<Node>::iterator node = nodes.begin(); node != nodes.end(); node++)
std::cout << node->LocalID() << " ";
std::cout << endl;
}
}
void UnpackSyncMarkerOR(const Tag & tag, const Element & element, const INMOST_DATA_BULK_TYPE * data, INMOST_DATA_ENUM_TYPE size)
......@@ -1706,7 +1737,7 @@ namespace INMOST
}
void Mesh::RemoveGhost()
void Mesh::RemoveGhost(MarkerType* marker)
{
if( m_state == Mesh::Serial ) return;
ENTER_FUNC()
......@@ -1720,6 +1751,7 @@ namespace INMOST
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++)
{
if (marker && !it->GetMarker(*marker)) continue;
Element::Status estat = GetStatus(*it);
if( estat == Element::Ghost )
{
......@@ -2119,7 +2151,7 @@ namespace INMOST
Mesh::proc_elements Mesh::ComputeSharedSkinSet(ElementType bridge_type)
Mesh::proc_elements Mesh::ComputeSharedSkinSet(ElementType bridge_type, MarkerType* marker)
{
ENTER_FUNC();
#if defined(USE_MPI)
......@@ -2196,6 +2228,7 @@ namespace INMOST
bool flag = false;
Element::Status estat1 = GetStatus(*it), estat2;
if( estat1 == Element::Owned ) continue;
if (marker && !it->GetMarker(*marker)) continue;
//Storage::integer_array skin_data = it->IntegerArray(tag_skin);
//REPORT_STR("face " << it->LocalID() << " global " << it->GlobalID() << " type " << Element::StatusName(estat1));
//for(Storage::integer_array::iterator kt = skin_data.begin(); kt != skin_data.end(); kt+=2)
......@@ -2449,7 +2482,7 @@ namespace INMOST
if (refs[i] == InvalidElement()) continue;
HandleType data = ComposeHandle(refs[i]->GetElementType(), refs[i]->GlobalID());
memcpy(&array_data_send[had_s+i*bytes],&data,sizeof(HandleType));
cout << ro() << rank << ": Pack elem " << refs[i]->GlobalID() << endl;
cout << ro() << rank << ": Pack elem " << refs[i]->GlobalID() <<endl;
}
}
else
......@@ -3504,7 +3537,7 @@ namespace INMOST
{
std::vector<INMOST_DATA_ENUM_TYPE> low_conn_size(selems[4].size());
std::vector<INMOST_DATA_ENUM_TYPE> high_conn_size(selems[4].size()); // TODO - 3
cout << "@@@ size" << selems[4].size() << endl;
//cout << "@@@ size" << selems[4].size() << endl;
std::vector<Storage::integer> low_conn_nums; // array composed elements : ElementType and position in array
std::vector<int> high_conn_nums(selems[4].size() * 3); // array of indexes of children, sibling, parent. -1 if has't
INMOST_DATA_ENUM_TYPE num_high = 0;
......@@ -5039,7 +5072,7 @@ namespace INMOST
EXIT_FUNC();
}
void Mesh::ExchangeGhost(Storage::integer layers, ElementType bridge)
void Mesh::ExchangeGhost(Storage::integer layers, ElementType bridge, MarkerType* marker)
{
//printf("%d called exchange ghost with layers %d bridge %s\n",GetProcessorRank(), layers,ElementTypeName(bridge));
if( m_state == Serial ) return;
......@@ -5064,10 +5097,9 @@ namespace INMOST
Storage::integer_array procs = IntegerArrayDV(GetHandle(),tag_processors);
proc_elements old_layers;
proc_elements current_layers;
element_set all_visited;
{
proc_elements shared_skin = ComputeSharedSkinSet(bridge);
element_set all_visited;
{
proc_elements shared_skin = ComputeSharedSkinSet(bridge, marker);
//printf("%d shared skin size %d\n",GetProcessorRank(),shared_skin.size());
time = Timer();
for(Storage::integer_array::iterator p = procs.begin(); p != procs.end(); p++)
......
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