Commit e953e5eb authored by Kirill Terekhov's avatar Kirill Terekhov Committed by GitHub

Merge pull request #30 from INMOST-DEV/andre_branch

Add ExchangeData for REFERENSES. Add ResolveSets. Add transfer to oth…
parents d9a63eb6 a3c82add
......@@ -12,6 +12,7 @@
namespace INMOST
{
std::string ro();
class Mesh;
class Storage;
......@@ -38,6 +39,7 @@ namespace INMOST
static const SyncBitOp SYNC_BIT_XOR = 2;
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
/// to accomodate more topological errors or events.
......@@ -1286,12 +1288,11 @@ namespace INMOST
//INMOST_MPI_Group group;
Tag tag_shared;
Tag tag_owner;
Tag tag_processors;
Tag tag_layers;
Tag tag_sendto;
Tag tag_bridge;
Tag tag_redistribute;
private:
double dist(Cell a, Cell b);
void AllocatePrivateMarkers();
void DeallocatePrivateMarkers();
__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
void AllocateSparseData (void * & q, const Tag & t);
void Init (std::string name);
public:
Tag tag_sendto;
TagInteger tag_an_id;
Tag tag_processors;
/// Go through all elements and detect presence of prescribed element in
/// any reference data tag.
void ReportConnection(HandleType h);
......@@ -2222,10 +2226,10 @@ namespace INMOST
class elements_by_type
{
private:
element_set container[4];
element_set container[5];
public:
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(){}
element_set & operator [](int i){ return container[i]; }
const element_set & operator [](int i) const { return container[i]; }
......@@ -2251,7 +2255,7 @@ namespace INMOST
private:
void ComputeSharedProcs ();
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 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);
......@@ -2263,6 +2267,7 @@ namespace INMOST
void SortParallelStorage(parallel_storage & ghost, parallel_storage & shared,ElementType mask);
void GatherParallelStorage(parallel_storage & ghost, parallel_storage & shared, ElementType mask);
public:
bool FindSharedGhost(int global_id, INMOST_DATA_INTEGER_TYPE el_type_num, HandleType& res);
#if defined(USE_PARALLEL_WRITE_TIME)
//this part is needed to test parallel performance
void Enter ();
......@@ -2417,7 +2422,9 @@ namespace INMOST
/// Set MPI communicator
void SetCommunicator (INMOST_MPI_Comm _comm);
/// 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.
void RemoveGhost ();
/// Delete some ghost cells provided in array.
......@@ -3223,6 +3230,20 @@ namespace INMOST
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
{
Mesh * m;
......
......@@ -6,6 +6,8 @@
// incident_matrix class should measure for minimal volume,
// possibly check and update from projects/OctreeCutcell/octgrid.cpp
using namespace std;
namespace INMOST
{
......@@ -1591,9 +1593,80 @@ namespace INMOST
//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()
{
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()
......
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