Commit 4d363998 authored by SilverLife's avatar SilverLife

Add ExchangeData for REFERENSES. Add ResolveSets. Add transfer to other processor for sets.

parent 949d38d0
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace INMOST namespace INMOST
{ {
std::string ro();
class Mesh; class Mesh;
class Storage; class Storage;
...@@ -38,6 +39,7 @@ namespace INMOST ...@@ -38,6 +39,7 @@ namespace INMOST
static const SyncBitOp SYNC_BIT_XOR = 2; static const SyncBitOp SYNC_BIT_XOR = 2;
static const SyncBitOp SYNC_BIT_AND = 3; static const SyncBitOp SYNC_BIT_AND = 3;
///Definition for data type of topology error or event. This type may be extended later to 64 bits ///Definition for data type of topology error or event. This type may be extended later to 64 bits
/// to accomodate more topological errors or events. /// to accomodate more topological errors or events.
...@@ -1286,12 +1288,11 @@ namespace INMOST ...@@ -1286,12 +1288,11 @@ namespace INMOST
//INMOST_MPI_Group group; //INMOST_MPI_Group group;
Tag tag_shared; Tag tag_shared;
Tag tag_owner; Tag tag_owner;
Tag tag_processors;
Tag tag_layers; Tag tag_layers;
Tag tag_sendto;
Tag tag_bridge; Tag tag_bridge;
Tag tag_redistribute; Tag tag_redistribute;
private: private:
double dist(Cell a, Cell b);
void AllocatePrivateMarkers(); void AllocatePrivateMarkers();
void DeallocatePrivateMarkers(); void DeallocatePrivateMarkers();
__INLINE static sparse_rec mkrec (const Tag & t) {sparse_rec ret; ret.tag = t.mem; ret.rec = NULL; return ret;} __INLINE static sparse_rec mkrec (const Tag & t) {sparse_rec ret; ret.tag = t.mem; ret.rec = NULL; return ret;}
...@@ -1310,6 +1311,9 @@ namespace INMOST ...@@ -1310,6 +1311,9 @@ namespace INMOST
void AllocateSparseData (void * & q, const Tag & t); void AllocateSparseData (void * & q, const Tag & t);
void Init (std::string name); void Init (std::string name);
public: public:
Tag tag_sendto;
TagInteger tag_an_id;
Tag tag_processors;
/// Go through all elements and detect presence of prescribed element in /// Go through all elements and detect presence of prescribed element in
/// any reference data tag. /// any reference data tag.
void ReportConnection(HandleType h); void ReportConnection(HandleType h);
...@@ -2222,10 +2226,10 @@ namespace INMOST ...@@ -2222,10 +2226,10 @@ namespace INMOST
class elements_by_type class elements_by_type
{ {
private: private:
element_set container[4]; element_set container[5];
public: public:
elements_by_type() {} elements_by_type() {}
elements_by_type(const elements_by_type & other) {for(int i = 0; i < 4; i++) container[i] = other.container[i];} elements_by_type(const elements_by_type & other) {for(int i = 0; i < 5; i++) container[i] = other.container[i];}
~elements_by_type(){} ~elements_by_type(){}
element_set & operator [](int i){ return container[i]; } element_set & operator [](int i){ return container[i]; }
const element_set & operator [](int i) const { return container[i]; } const element_set & operator [](int i) const { return container[i]; }
...@@ -2251,7 +2255,7 @@ namespace INMOST ...@@ -2251,7 +2255,7 @@ namespace INMOST
private: private:
void ComputeSharedProcs (); void ComputeSharedProcs ();
proc_elements ComputeSharedSkinSet(ElementType bridge); proc_elements ComputeSharedSkinSet(ElementType bridge);
void PackTagData (const Tag & tag, const elements_by_type & elements, ElementType mask, MarkerType select, buffer_type & buffer); 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 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); void PackElementsData (element_set & input, buffer_type & buffer, int destination, const std::vector<std::string> & tag_list);
void UnpackElementsData (element_set & output, buffer_type & buffer, int source, std::vector<std::string> & tag_list); void UnpackElementsData (element_set & output, buffer_type & buffer, int source, std::vector<std::string> & tag_list);
...@@ -2263,6 +2267,7 @@ namespace INMOST ...@@ -2263,6 +2267,7 @@ namespace INMOST
void SortParallelStorage(parallel_storage & ghost, parallel_storage & shared,ElementType mask); void SortParallelStorage(parallel_storage & ghost, parallel_storage & shared,ElementType mask);
void GatherParallelStorage(parallel_storage & ghost, parallel_storage & shared, ElementType mask); void GatherParallelStorage(parallel_storage & ghost, parallel_storage & shared, ElementType mask);
public: public:
bool FindSharedGhost(int global_id, INMOST_DATA_INTEGER_TYPE el_type_num, HandleType& res);
#if defined(USE_PARALLEL_WRITE_TIME) #if defined(USE_PARALLEL_WRITE_TIME)
//this part is needed to test parallel performance //this part is needed to test parallel performance
void Enter (); void Enter ();
...@@ -2417,7 +2422,9 @@ namespace INMOST ...@@ -2417,7 +2422,9 @@ namespace INMOST
/// Set MPI communicator /// Set MPI communicator
void SetCommunicator (INMOST_MPI_Comm _comm); void SetCommunicator (INMOST_MPI_Comm _comm);
/// Find elements that are common between processors. /// Find elements that are common between processors.
void ResolveShared (); void ResolveShared (bool only_new = false);
/// Find sets that are common between processors.
void ResolveSets ();
/// Delete all the ghost cells. /// Delete all the ghost cells.
void RemoveGhost (); void RemoveGhost ();
/// Delete some ghost cells provided in array. /// Delete some ghost cells provided in array.
...@@ -3223,6 +3230,20 @@ namespace INMOST ...@@ -3223,6 +3230,20 @@ namespace INMOST
bool operator() (HandleType a, integer gid) const {if( a == InvalidHandle() ) return false; return m->GlobalID(a) < gid;} bool operator() (HandleType a, integer gid) const {if( a == InvalidHandle() ) return false; return m->GlobalID(a) < gid;}
}; };
class SetNameComparator
{
Mesh * m;
public:
SetNameComparator(Mesh * m) :m(m) {}
bool operator()(HandleType a, HandleType b) const
{
if( a == InvalidHandle() || b == InvalidHandle() ) return a > b;
return ElementSet(m,a).GetName() < ElementSet(m,b).GetName();
}
};
class HierarchyComparator class HierarchyComparator
{ {
Mesh * m; Mesh * m;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
// incident_matrix class should measure for minimal volume, // incident_matrix class should measure for minimal volume,
// possibly check and update from projects/OctreeCutcell/octgrid.cpp // possibly check and update from projects/OctreeCutcell/octgrid.cpp
using namespace std;
namespace INMOST namespace INMOST
{ {
...@@ -1523,9 +1525,80 @@ namespace INMOST ...@@ -1523,9 +1525,80 @@ namespace INMOST
//Destroy(erase);//old approach //Destroy(erase);//old approach
} }
double Mesh::dist(Cell a, Cell b)
{
double xyza[3];
double xyzb[3];
a.Centroid(xyza);
b.Centroid(xyzb);
double dx = xyza[0] - xyzb[0];
double dy = xyza[1] - xyzb[1];
double dz = xyza[2] - xyzb[2];
return sqrt(dx*dx + dy*dy + dz*dz);
}
void OperationMinDistance(const Tag & tag, const Element & element, const INMOST_DATA_BULK_TYPE * data, INMOST_DATA_ENUM_TYPE size)
{
int owner = *((double*)data);
double dist = *((double*)(data+sizeof(double)));
TagReal r_tag = tag;
if (dist < element->RealArray(tag)[1])
{
element->RealArray(tag)[0] = owner;
element->RealArray(tag)[1] = dist;
}
}
void Mesh::ResolveModification() void Mesh::ResolveModification()
{ {
throw NotImplemented; int rank = GetProcessorRank(),mpisize = GetProcessorsNumber();
Tag tag = CreateTag("TEMP_DISTANSE",DATA_REAL,CELL,CELL,2);
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++) if (GetMarker(*it,NewMarker()))
{
double min = 0;
int first = 0;
Cell near_cell;
for(Mesh::iteratorCell jt = BeginCell(); jt != EndCell(); jt++) if (GetMarker(*jt,NewMarker()) == false)
{
double d = dist(it->getAsCell(), jt->getAsCell());
if (first++ == 0 || min > d)
{
min = d;
near_cell = jt->getAsCell();
}
}
int owner1 = it->IntegerDF(tag_owner);
int owner2 = near_cell.IntegerDF(tag_owner);
it->RealArray(tag)[0] = owner2;
it->RealArray(tag)[1] = min;
}
ReduceData(tag, CELL, 0, OperationMinDistance);
ExchangeData(tag, CELL, 0);
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++) if (GetMarker(*it,NewMarker()))
{
int new_owner = it->RealArray(tag)[0];
it->IntegerDF(tag_owner) = new_owner;
if (rank == new_owner)
{
it->SetStatus(Element::Shared);
}
else
{
it->SetStatus(Element::Ghost);
}
}
} }
void Mesh::EndModification() void Mesh::EndModification()
......
This diff is collapsed.
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