mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
don't store partition in element (most times waste of mem)
This commit is contained in:
parent
0a1976ba47
commit
179c3bb02f
@ -390,10 +390,10 @@ extern "C" {
|
||||
DLL_HEADER void Ng_AddPointCurvePoint(const double * point);
|
||||
|
||||
|
||||
#ifdef PARALLEL
|
||||
void Ng_SetElementPartition ( int elnr, int part );
|
||||
int Ng_GetElementPartition ( int elnr );
|
||||
#endif
|
||||
// #ifdef PARALLEL
|
||||
// void Ng_SetElementPartition ( int elnr, int part );
|
||||
// int Ng_GetElementPartition ( int elnr );
|
||||
// #endif
|
||||
|
||||
DLL_HEADER void Ng_SaveMesh ( const char * meshfile );
|
||||
DLL_HEADER void Ng_Bisect ( const char * refinementfile );
|
||||
|
@ -2069,7 +2069,7 @@ void Ng_SocketClientGetServerClientID ( const int number, int * id )
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#ifdef PARALLEL
|
||||
void Ng_SetElementPartition ( const int elnr, const int part )
|
||||
{
|
||||
@ -2081,6 +2081,7 @@ int Ng_GetElementPartition ( const int elnr )
|
||||
return mesh->VolumeElement(elnr+1).GetPartition();
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
void Ng_InitPointCurve(double red, double green, double blue)
|
||||
|
@ -860,6 +860,11 @@ namespace netgen
|
||||
void SendMesh ( ) const; // Mesh * mastermesh, Array<int> & neloc) const;
|
||||
/// loads a mesh sent from master processor
|
||||
void ReceiveParallelMesh ();
|
||||
|
||||
Array<int> vol_partition;
|
||||
Array<int> surf_partition;
|
||||
Array<int> seg_partition;
|
||||
|
||||
#else
|
||||
void Distribute () {}
|
||||
void SendRecvMesh () {}
|
||||
|
@ -1073,9 +1073,9 @@ namespace netgen
|
||||
flags.fixed = 0;
|
||||
orderx = ordery = orderz = 1;
|
||||
is_curved = typ != TET; // false;
|
||||
#ifdef PARALLEL
|
||||
partitionNumber = -1;
|
||||
#endif
|
||||
// #ifdef PARALLEL
|
||||
// partitionNumber = -1;
|
||||
// #endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -377,9 +377,9 @@ namespace netgen
|
||||
unsigned int orderx:6;
|
||||
unsigned int ordery:6;
|
||||
|
||||
#ifdef PARALLEL
|
||||
int partitionNumber;
|
||||
#endif
|
||||
// #ifdef PARALLEL
|
||||
// int partitionNumber;
|
||||
// #endif
|
||||
|
||||
/// a linked list for all segments in the same face
|
||||
SurfaceElementIndex next;
|
||||
@ -608,10 +608,12 @@ namespace netgen
|
||||
///
|
||||
int hp_elnr;
|
||||
|
||||
/*
|
||||
#ifdef PARALLEL
|
||||
int GetPartition () const { return partitionNumber; }
|
||||
void SetPartition (int nr) { partitionNumber = nr; };
|
||||
#endif
|
||||
*/
|
||||
};
|
||||
|
||||
ostream & operator<<(ostream & s, const Element2d & el);
|
||||
@ -676,11 +678,11 @@ namespace netgen
|
||||
float badness;
|
||||
bool is_curved:1; // element is (high order) curved
|
||||
|
||||
#ifdef PARALLEL
|
||||
// #ifdef PARALLEL
|
||||
/// number of partition for parallel computation
|
||||
int partitionNumber;
|
||||
// int partitionNumber;
|
||||
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
public:
|
||||
flagstruct flags;
|
||||
@ -902,13 +904,14 @@ namespace netgen
|
||||
bool IsCurved () const { return is_curved; }
|
||||
void SetCurved (bool acurved) { is_curved = acurved; }
|
||||
|
||||
|
||||
/*
|
||||
#ifdef PARALLEL
|
||||
int GetPartition () const { return partitionNumber; }
|
||||
void SetPartition (int nr) { partitionNumber = nr; };
|
||||
#else
|
||||
int GetPartition () const { return 0; }
|
||||
#endif
|
||||
*/
|
||||
|
||||
int hp_elnr;
|
||||
};
|
||||
@ -967,10 +970,10 @@ namespace netgen
|
||||
///
|
||||
int meshdocval;
|
||||
|
||||
#ifdef PARALLEL
|
||||
// #ifdef PARALLEL
|
||||
/// number of partition for parallel computation
|
||||
int partitionNumber;
|
||||
#endif
|
||||
// int partitionNumber;
|
||||
// #endif
|
||||
|
||||
private:
|
||||
string* bcname;
|
||||
@ -1025,12 +1028,15 @@ namespace netgen
|
||||
bool IsCurved () const { return is_curved; }
|
||||
void SetCurved (bool acurved) { is_curved = acurved; }
|
||||
|
||||
/*
|
||||
#ifdef PARALLEL
|
||||
int GetPartition () const { return partitionNumber; }
|
||||
void SetPartition (int nr) { partitionNumber = nr; };
|
||||
#else
|
||||
int GetPartition () const { return 0; }
|
||||
#endif
|
||||
*/
|
||||
|
||||
void DoArchive (Archive & ar);
|
||||
};
|
||||
|
||||
|
@ -87,34 +87,39 @@ namespace netgen
|
||||
Array<int> num_els_on_proc(ntasks);
|
||||
num_els_on_proc = 0;
|
||||
for (ElementIndex ei = 0; ei < GetNE(); ei++)
|
||||
num_els_on_proc[(*this)[ei].GetPartition()]++;
|
||||
// num_els_on_proc[(*this)[ei].GetPartition()]++;
|
||||
num_els_on_proc[vol_partition[ei]]++;
|
||||
|
||||
MPI_Scatter (&num_els_on_proc[0], 1, MPI_INT,
|
||||
MPI_IN_PLACE, -1, MPI_INT, 0, comm);
|
||||
|
||||
TABLE<ElementIndex> els_of_proc (num_els_on_proc);
|
||||
for (ElementIndex ei = 0; ei < GetNE(); ei++)
|
||||
els_of_proc.Add ( (*this)[ei].GetPartition(), ei);
|
||||
// els_of_proc.Add ( (*this)[ei].GetPartition(), ei);
|
||||
els_of_proc.Add (vol_partition[ei], ei);
|
||||
|
||||
PrintMessage ( 3, "Building vertex/proc mapping");
|
||||
|
||||
Array<int> num_sels_on_proc(ntasks);
|
||||
num_sels_on_proc = 0;
|
||||
for (SurfaceElementIndex ei = 0; ei < GetNSE(); ei++)
|
||||
num_sels_on_proc[(*this)[ei].GetPartition()]++;
|
||||
// num_sels_on_proc[(*this)[ei].GetPartition()]++;
|
||||
num_sels_on_proc[surf_partition[ei]]++;
|
||||
|
||||
TABLE<SurfaceElementIndex> sels_of_proc (num_sels_on_proc);
|
||||
for (SurfaceElementIndex ei = 0; ei < GetNSE(); ei++)
|
||||
sels_of_proc.Add ( (*this)[ei].GetPartition(), ei);
|
||||
// sels_of_proc.Add ( (*this)[ei].GetPartition(), ei);
|
||||
sels_of_proc.Add (surf_partition[ei], ei);
|
||||
|
||||
Array<int> num_segs_on_proc(ntasks);
|
||||
num_segs_on_proc = 0;
|
||||
for (SegmentIndex ei = 0; ei < GetNSeg(); ei++)
|
||||
num_segs_on_proc[(*this)[ei].GetPartition()]++;
|
||||
// num_segs_on_proc[(*this)[ei].GetPartition()]++;
|
||||
num_segs_on_proc[seg_partition[ei]]++;
|
||||
|
||||
TABLE<SegmentIndex> segs_of_proc (num_segs_on_proc);
|
||||
for (SegmentIndex ei = 0; ei < GetNSeg(); ei++)
|
||||
segs_of_proc.Add ( (*this)[ei].GetPartition(), ei);
|
||||
segs_of_proc.Add (seg_partition[ei], ei);
|
||||
|
||||
|
||||
/**
|
||||
@ -407,7 +412,8 @@ namespace netgen
|
||||
for ( int ei = 1; ei <= GetNE(); ei++)
|
||||
{
|
||||
const Element & el = VolumeElement (ei);
|
||||
int dest = el.GetPartition();
|
||||
// int dest = el.GetPartition();
|
||||
int dest = vol_partition[ei-1];
|
||||
elarraysize[dest] += 3 + el.GetNP();
|
||||
}
|
||||
|
||||
@ -416,7 +422,8 @@ namespace netgen
|
||||
for (int ei = 1; ei <= GetNE(); ei++)
|
||||
{
|
||||
const Element & el = VolumeElement (ei);
|
||||
int dest = el.GetPartition();
|
||||
// int dest = el.GetPartition();
|
||||
int dest = vol_partition[ei-1];
|
||||
|
||||
elementarrays.Add (dest, ei);
|
||||
elementarrays.Add (dest, el.GetIndex());
|
||||
@ -495,11 +502,13 @@ namespace netgen
|
||||
for (SurfaceElementIndex sei = 0; sei < GetNSE(); sei++ )
|
||||
{
|
||||
const Element2d & sel = (*this)[sei];
|
||||
int dest = (*this)[sei].GetPartition();
|
||||
// int dest = (*this)[sei].GetPartition();
|
||||
int dest = surf_partition[sei];
|
||||
f(sei, sel, dest);
|
||||
if(ided_sel[sei]!=-1)
|
||||
{
|
||||
int dest2 = (*this)[ided_sel[sei]].GetPartition();
|
||||
// int dest2 = (*this)[ided_sel[sei]].GetPartition();
|
||||
int dest2 = surf_partition[ided_sel[sei]];
|
||||
f(sei, sel, dest2);
|
||||
}
|
||||
}
|
||||
@ -637,10 +646,12 @@ namespace netgen
|
||||
{
|
||||
const Segment & seg = (*this)[segi];
|
||||
dests.SetSize(0);
|
||||
dests.Append(seg.GetPartition());
|
||||
// dests.Append(seg.GetPartition());
|
||||
dests.Append(seg_partition[segi]);
|
||||
for (int l = 0; l < per_seg_trans[segi].Size(); l++)
|
||||
{
|
||||
int dest2 = (*this)[per_seg_trans[segi][l]].GetPartition();
|
||||
// int dest2 = (*this)[per_seg_trans[segi][l]].GetPartition();
|
||||
int dest2 = seg_partition[per_seg_trans[segi][l]];
|
||||
if(!dests.Contains(dest2))
|
||||
dests.Append(dest2);
|
||||
}
|
||||
@ -1075,14 +1086,20 @@ namespace netgen
|
||||
|
||||
idxtype nparts = GetCommunicator().Size()-1;
|
||||
|
||||
vol_partition.SetSize(GetNE());
|
||||
surf_partition.SetSize(GetNSE());
|
||||
seg_partition.SetSize(GetNSeg());
|
||||
if (nparts == 1)
|
||||
{
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(1);
|
||||
// VolumeElement(i+1).SetPartition(1);
|
||||
vol_partition[i]= 1;
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(1);
|
||||
// SurfaceElement(i+1).SetPartition(1);
|
||||
surf_partition[i] = 1;
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(1);
|
||||
// LineSegment(i+1).SetPartition(1);
|
||||
seg_partition[i] = 1;
|
||||
}
|
||||
|
||||
else
|
||||
@ -1105,11 +1122,14 @@ namespace netgen
|
||||
// cout << "done" << endl;
|
||||
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(epart[i] + 1);
|
||||
// VolumeElement(i+1).SetPartition(epart[i] + 1);
|
||||
vol_partition[i]= epart[i] + 1;
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
|
||||
// SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
|
||||
surf_partition[i] = epart[i+GetNE()] + 1;
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
|
||||
// LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
|
||||
seg_partition[i] = epart[i+GetNE()+GetNSE()] + 1;
|
||||
}
|
||||
|
||||
|
||||
@ -1185,7 +1205,8 @@ namespace netgen
|
||||
// FlatArray<ElementIndex> els = pnt2el[pi1];
|
||||
FlatArray<int> els = pnt2el[pi1];
|
||||
|
||||
sel.SetPartition (-1);
|
||||
// sel.SetPartition (-1);
|
||||
surf_partition[sei] = -1;
|
||||
|
||||
for (int j = 0; j < els.Size(); j++)
|
||||
{
|
||||
@ -1205,11 +1226,13 @@ namespace netgen
|
||||
|
||||
if (hasall)
|
||||
{
|
||||
sel.SetPartition (el.GetPartition());
|
||||
// sel.SetPartition (el.GetPartition());
|
||||
surf_partition[sei] = vol_partition[ElementIndex(els[j])];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sel.GetPartition() == -1)
|
||||
// if (sel.GetPartition() == -1)
|
||||
if (surf_partition[sei] == -1)
|
||||
cerr << "no volume element found" << endl;
|
||||
}
|
||||
|
||||
@ -1220,7 +1243,8 @@ namespace netgen
|
||||
PointIndex pi1 = sel[0];
|
||||
FlatArray<int> els = pnt2el[pi1];
|
||||
|
||||
sel.SetPartition (-1);
|
||||
// sel.SetPartition (-1);
|
||||
seg_partition[si] = -1;
|
||||
|
||||
for (int j = 0; j < els.Size(); j++)
|
||||
{
|
||||
@ -1239,11 +1263,13 @@ namespace netgen
|
||||
|
||||
if (hasall)
|
||||
{
|
||||
sel.SetPartition (el.GetPartition());
|
||||
// sel.SetPartition (el.GetPartition());
|
||||
seg_partition[si] = vol_partition[ElementIndex(els[j])];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sel.GetPartition() == -1)
|
||||
// if (sel.GetPartition() == -1)
|
||||
if (seg_partition[si] == -1)
|
||||
cerr << "no volume element found" << endl;
|
||||
}
|
||||
}
|
||||
@ -1252,7 +1278,8 @@ namespace netgen
|
||||
for (SegmentIndex segi = 0; segi < GetNSeg(); segi++)
|
||||
{
|
||||
Segment & seg = (*this)[segi];
|
||||
seg.SetPartition(-1);
|
||||
// seg.SetPartition(-1);
|
||||
seg_partition[segi] = -1;
|
||||
PointIndex pi1 = seg[0];
|
||||
|
||||
FlatArray<int> sels = pnt2el[pi1];
|
||||
@ -1264,12 +1291,14 @@ namespace netgen
|
||||
for (int l = 0; l < se.GetNP(); l++ && !found)
|
||||
found |= (se[l]==seg[1]);
|
||||
if(found) {
|
||||
seg.SetPartition(se.GetPartition());
|
||||
// seg.SetPartition(se.GetPartition());
|
||||
seg_partition[segi] = surf_partition[sei];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (seg.GetPartition() == -1) {
|
||||
// if (seg.GetPartition() == -1) {
|
||||
if (seg_partition[segi] == -1) {
|
||||
cout << endl << "segi: " << segi << endl;
|
||||
cout << "points: " << seg[0] << " " << seg[1] << endl;
|
||||
cout << "surfels: " << endl << sels << endl;
|
||||
@ -1387,15 +1416,21 @@ namespace netgen
|
||||
Array<idx_t> epart(ne), npart(nn);
|
||||
|
||||
idxtype nparts = GetCommunicator().Size()-1;
|
||||
vol_partition.SetSize(GetNE());
|
||||
surf_partition.SetSize(GetNSE());
|
||||
seg_partition.SetSize(GetNSeg());
|
||||
|
||||
if (nparts == 1)
|
||||
{
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(1);
|
||||
// VolumeElement(i+1).SetPartition(1);
|
||||
vol_partition[i] = 1;
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(1);
|
||||
// SurfaceElement(i+1).SetPartition(1);
|
||||
surf_partition[i] = 1;
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(1);
|
||||
// LineSegment(i+1).SetPartition(1);
|
||||
seg_partition[i] = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1416,11 +1451,14 @@ namespace netgen
|
||||
// cout << "done" << endl;
|
||||
|
||||
for (int i = 0; i < GetNE(); i++)
|
||||
VolumeElement(i+1).SetPartition(epart[i] + 1);
|
||||
// VolumeElement(i+1).SetPartition(epart[i] + 1);
|
||||
vol_partition[i] = epart[i] + 1;
|
||||
for (int i = 0; i < GetNSE(); i++)
|
||||
SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
|
||||
// SurfaceElement(i+1).SetPartition(epart[i+GetNE()] + 1);
|
||||
surf_partition[i] = epart[i+GetNE()] + 1;
|
||||
for (int i = 0; i < GetNSeg(); i++)
|
||||
LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
|
||||
// LineSegment(i+1).SetPartition(epart[i+GetNE()+GetNSE()] + 1);
|
||||
seg_partition[i] = epart[i+GetNE()+GetNSE()] + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1648,7 +1686,7 @@ namespace netgen
|
||||
#endif
|
||||
|
||||
Array<int> nodesinpart(ntasks);
|
||||
|
||||
vol_partition.SetSize(ne);
|
||||
for ( int el = 1; el <= ne; el++ )
|
||||
{
|
||||
Element & volel = VolumeElement(el);
|
||||
@ -1664,7 +1702,8 @@ namespace netgen
|
||||
if ( nodesinpart[i] > nodesinpart[partition] )
|
||||
partition = i;
|
||||
|
||||
volel.SetPartition(partition);
|
||||
// volel.SetPartition(partition);
|
||||
vol_partition[el-1] = partition;
|
||||
}
|
||||
|
||||
delete [] xadj;
|
||||
@ -1766,13 +1805,14 @@ namespace netgen
|
||||
|
||||
Array<int> nodesinpart(ntasks);
|
||||
|
||||
vol_partition.SetSize(ne);
|
||||
for ( int el = 1; el <= ne; el++ )
|
||||
{
|
||||
// Element & volel = VolumeElement(el);
|
||||
nodesinpart = 0;
|
||||
|
||||
VolumeElement(el).SetPartition(part[el-1 ] + 1);
|
||||
|
||||
// VolumeElement(el).SetPartition(part[el-1 ] + 1);
|
||||
vol_partition[el-1] = part[el-1 ] + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1879,8 +1919,10 @@ namespace netgen
|
||||
#endif
|
||||
|
||||
|
||||
surf_partition.SetSize(ne);
|
||||
for (SurfaceElementIndex sei = 0; sei < ne; sei++)
|
||||
(*this) [sei].SetPartition (part[sei]+1);
|
||||
// (*this) [sei].SetPartition (part[sei]+1);
|
||||
surf_partition[sei] = part[sei]+1;
|
||||
#else
|
||||
cout << "partdualmesh not available" << endl;
|
||||
#endif
|
||||
|
@ -141,7 +141,8 @@ namespace netgen
|
||||
topology.GetElementEdges (el, edges);
|
||||
const Element & volel = mesh.VolumeElement (el);
|
||||
|
||||
Array<int> & sendarray = *sendarrays[volel.GetPartition()];
|
||||
// Array<int> & sendarray = *sendarrays[volel.GetPartition()];
|
||||
Array<int> & sendarray = *sendarrays[mesh.vol_partition[el-1]];
|
||||
|
||||
for ( int i = 0; i < edges.Size(); i++ )
|
||||
sendarray.Append (edges[i]);
|
||||
@ -153,7 +154,8 @@ namespace netgen
|
||||
{
|
||||
topology.GetSurfaceElementEdges (el, edges);
|
||||
const Element2d & surfel = mesh.SurfaceElement (el);
|
||||
Array<int> & sendarray = *sendarrays[surfel.GetPartition()];
|
||||
// Array<int> & sendarray = *sendarrays[surfel.GetPartition()];
|
||||
Array<int> & sendarray = *sendarrays[mesh.surf_partition[el-1]];
|
||||
|
||||
for ( int i = 0; i < edges.Size(); i++ )
|
||||
sendarray.Append (edges[i]);
|
||||
|
@ -1618,11 +1618,14 @@ namespace netgen
|
||||
{
|
||||
const Segment & seg = mesh->LineSegment(i);
|
||||
|
||||
/*
|
||||
#ifdef PARALLEL
|
||||
if (ntasks > 1 &&
|
||||
vispar.drawtetsdomain &&
|
||||
(vispar.drawtetsdomain != seg.GetPartition())) continue;
|
||||
// (vispar.drawtetsdomain != seg.GetPartition())) continue;
|
||||
(vispar.drawtetsdomain != mesh->seg_partition[i-1]) continue;
|
||||
#endif
|
||||
*/
|
||||
|
||||
const Point3d & p1 = (*mesh)[seg[0]];
|
||||
const Point3d & p2 = (*mesh)[seg[1]];
|
||||
@ -1865,9 +1868,11 @@ namespace netgen
|
||||
{
|
||||
if (vispar.drawtetsdomain > 0)
|
||||
{
|
||||
/*
|
||||
int tetid = vispar.drawmetispartition ?
|
||||
(*mesh)[ei].GetPartition() : (*mesh)[ei].GetIndex();
|
||||
|
||||
*/
|
||||
int tetid = (*mesh)[ei].GetIndex();
|
||||
if (vispar.drawtetsdomain != tetid) continue;
|
||||
}
|
||||
|
||||
@ -1884,8 +1889,8 @@ namespace netgen
|
||||
|
||||
int ind = el.GetIndex() % 4;
|
||||
|
||||
if (vispar.drawmetispartition && el.GetPartition()!=-1)
|
||||
ind = el.GetPartition() % 4;
|
||||
// if (vispar.drawmetispartition && el.GetPartition()!=-1)
|
||||
// ind = el.GetPartition() % 4;
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, tetcols[ind]);
|
||||
|
||||
|
@ -2264,8 +2264,9 @@ namespace netgen
|
||||
mesh->ParallelMetis();
|
||||
cout << "done" << endl;
|
||||
ntasks = 1;
|
||||
for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++)
|
||||
(*mesh)[ei].SetIndex ( (*mesh)[ei].GetPartition() );
|
||||
|
||||
// for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++)
|
||||
// (*mesh)[ei].SetIndex ( (*mesh)[ei].GetPartition() );
|
||||
|
||||
return TCL_OK;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user