Commit eabb9627 authored by daniele.corallo's avatar daniele.corallo
Browse files

[403-add-stdist-warnings] added warnings to stdisc

parent fa34b96d
...@@ -69,7 +69,7 @@ void Distribution::DistributeMesh(Mesh &mesh) { ...@@ -69,7 +69,7 @@ void Distribution::DistributeMesh(Mesh &mesh) {
if (distribute) { if (distribute) {
for(int i = startDist; i<cells.size(); ++i){ for (int i = startDist; i < cells.size(); ++i) {
distributedCells.emplace_back(cells[i]()); distributedCells.emplace_back(cells[i]());
} }
...@@ -85,8 +85,7 @@ void Distribution::DistributeMesh(Mesh &mesh) { ...@@ -85,8 +85,7 @@ void Distribution::DistributeMesh(Mesh &mesh) {
<< endl; << endl;
if (PPM->Min(cellCount, commSplit) == 0) if (PPM->Min(cellCount, commSplit) == 0)
VerboseWarning( VerboseWarning("At least one processor has no cells!", 1);
"At least one processor has no cells!", 1);
emptyData(clearDistributed); emptyData(clearDistributed);
mout.EndBlock(true); mout.EndBlock(true);
...@@ -327,6 +326,21 @@ bool TLess_t(const cell &c0, const cell &c1) { ...@@ -327,6 +326,21 @@ bool TLess_t(const cell &c0, const cell &c1) {
return false; return false;
} }
std::function<bool(const cell &, const cell &)> GetLess(char var) {
switch (var) {
case 'x':
return Less_x;
case 'y':
return Less_y;
case 'z':
return Less_z;
case 't':
return Less_t;
default:
THROW("Dimension " + std::to_string(var) + " not known");
}
}
void Distribution::RCB_x(int rekDepth, int begin, int end) { void Distribution::RCB_x(int rekDepth, int begin, int end) {
if (rekDepth == 0) return; if (rekDepth == 0) return;
sort(cells.begin() + begin, cells.begin() + end, Less_x); sort(cells.begin() + begin, cells.begin() + end, Less_x);
...@@ -794,19 +808,7 @@ void Distribution::timeOpt(int tProc, int level, int begin, int end) { ...@@ -794,19 +808,7 @@ void Distribution::timeOpt(int tProc, int level, int begin, int end) {
void Distribution::timercb(int level, int begin, int end, char d) { void Distribution::timercb(int level, int begin, int end, char d) {
int N = end - begin; int N = end - begin;
switch (d) { sort(cells.begin() + begin, cells.begin() + end, GetLess(d));
case 'x':
sort(cells.begin() + begin, cells.begin() + end, TLess_x);
break;
case 'y':
sort(cells.begin() + begin, cells.begin() + end, TLess_y);
break;
case 't':
sort(cells.begin() + begin, cells.begin() + end, TLess_t);
break;
default:
break;
}
if (level == 0) { if (level == 0) {
return; return;
} else { } else {
...@@ -865,23 +867,8 @@ void Distribution::timercb_weighted(int tlevel, int xlevel, int ylevel, ...@@ -865,23 +867,8 @@ void Distribution::timercb_weighted(int tlevel, int xlevel, int ylevel,
int default_weight) { int default_weight) {
int N = end - begin; int N = end - begin;
int level = tlevel + xlevel + ylevel; int level = tlevel + xlevel + ylevel;
sort(cells.begin() + begin, cells.begin() + end, GetLess(d));
switch (d) {
case 'x':
sort(cells.begin() + begin, cells.begin() + end, TLess_x);
break;
case 'y':
sort(cells.begin() + begin, cells.begin() + end, TLess_y);
break;
case 't':
sort(cells.begin() + begin, cells.begin() + end, TLess_t);
break;
default:
break;
}
if (PPM->proc() == 0) { if (PPM->proc() == 0) {
int W_sum = 0; int W_sum = 0;
for (int i = begin; i < end; ++i) { for (int i = begin; i < end; ++i) {
if (W.find(cells[i]()) != W.end()) if (W.find(cells[i]()) != W.end())
...@@ -919,7 +906,7 @@ void Distribution::timercb_weighted(int tlevel, int xlevel, int ylevel, ...@@ -919,7 +906,7 @@ void Distribution::timercb_weighted(int tlevel, int xlevel, int ylevel,
while (cells[mid]().t() == cells[mid - 1]().t() || a == b) { while (cells[mid]().t() == cells[mid - 1]().t() || a == b) {
--mid; --mid;
if (mid < begin) break; if (mid < begin || mid == 0) break;
a = cells[mid]().CopyWithT(0.0); a = cells[mid]().CopyWithT(0.0);
b = cells[mid + 1]().CopyWithT(0.0); b = cells[mid + 1]().CopyWithT(0.0);
} }
...@@ -1046,25 +1033,30 @@ void Distribution::DistributeSTMesh(Mesh &mesh) { ...@@ -1046,25 +1033,30 @@ void Distribution::DistributeSTMesh(Mesh &mesh) {
} else if (_distName == "deformed_optimized") { } else if (_distName == "deformed_optimized") {
int S = mesh.steps() - 1; int S = mesh.steps() - 1;
int Slice_Maximum = int(log(double(S)) / log(2.0) + 1e-10); int Slice_Maximum = int(log(double(S)) / log(2.0) + 1e-10);
int X_Maximum = int(log(double(sqrt(N / (S)))) / log(2.0) + 1e-10); int X_Maximum = int(log(double(sqrt(N / S))) / log(2.0) + 1e-10);
int Y_Maximum = X_Maximum; int Y_Maximum = X_Maximum;
if (Slice_Maximum == 0 && X_Maximum == 0 && Y_Maximum == 0) {
THROW("Not enough cells to distribute. Level: " + mesh.Level().str())
}
int tL = 0; int tL = 0;
int yL = 0; int yL = 0;
int xL = 0; int xL = 0;
int L0 = rekDepth; int L0 = rekDepth;
for (int i = 0; i < rekDepth; ++i) { for (int i = 0; i < rekDepth; ++i) {
if (L0 == 0) break; if (L0 == 0) break;
if (tL < Slice_Maximum) { if (tL < Slice_Maximum && Slice_Maximum > 0) {
++tL; ++tL;
--L0; --L0;
} }
if (L0 == 0) break; if (L0 == 0) break;
if (xL < X_Maximum) { if (xL < X_Maximum && X_Maximum > 0) {
++xL; ++xL;
--L0; --L0;
} }
if (L0 == 0) break; if (L0 == 0) break;
if (yL < Y_Maximum) { if (yL < Y_Maximum && Y_Maximum > 0) {
++yL; ++yL;
--L0; --L0;
} }
......
Supports Markdown
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