Commit 5bf8ba92 by Amaury Johnen

move progressStatus into GmshMessage

parent 5a38aefc
......@@ -1560,3 +1560,36 @@ int Msg::GetMaxThreads(){ return 1; }
int Msg::GetThreadNum(){ return 0; }
#endif
MsgProgressStatus::MsgProgressStatus(int num)
: totalElementToTreat_(num), currentI_(0), nextIToCheck_(0),
initialTime_(Cpu()), lastTime_(initialTime_), lastPercentage_(0)
{}
void MsgProgressStatus::next()
{
++currentI_;
if (currentI_ < nextIToCheck_) return;
unsigned int currentPercentage = currentI_*100/totalElementToTreat_;
// check every percentage only
nextIToCheck_ = (currentPercentage+1) * totalElementToTreat_ / 100 + 1;
double currentTime = Cpu();
if ((currentPercentage < 5 && currentTime - lastTime_ > 15.) ||
(currentPercentage > lastPercentage_ + 4 && currentTime - lastTime_ > 10.)) {
lastPercentage_ = currentPercentage;
lastTime_ = currentTime;
const double remaining = (currentTime-initialTime_) / (currentI_+1) *
(totalElementToTreat_ - currentI_-1);
if (remaining < 60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g seconds)",
currentPercentage, remaining);
else if (remaining < 60*60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g minutes)",
currentPercentage, remaining/60);
else
Msg::StatusBar(true, "%d%% (remaining time ~%g hours)",
currentPercentage, remaining/3600);
}
}
\ No newline at end of file
......@@ -152,4 +152,20 @@ class Msg {
static void ImportPhysicalGroupsInOnelab();
};
// a class to print the progression and estimated remaining time
class MsgProgressStatus
{
private:
int totalElementToTreat_, currentI_, nextIToCheck_;
double initialTime_, lastTime_;
int lastPercentage_;
int progressMeterStep_;
public:
MsgProgressStatus(int numElementToTreat);
~MsgProgressStatus();
void setInitialTime(double time) {initialTime_ = time;}
void next();
};
#endif
......@@ -22,39 +22,6 @@
class bezierBasis;
ProgressStatus::ProgressStatus(int num)
: totalElementToTreat_(num), currentI_(0), nextIToCheck_(0),
initialTime_(Cpu()), lastTime_(initialTime_), lastPercentage_(0)
{}
void ProgressStatus::check()
{
++currentI_;
if (currentI_ < nextIToCheck_) return;
unsigned int currentPercentage = currentI_*100/totalElementToTreat_;
nextIToCheck_ = (currentPercentage+1) * totalElementToTreat_ / 100 + 1;
//nextIToCheck_ += totalElementToTreat_ / 100;
double currentTime = Cpu();
if ((currentPercentage < 5 && currentTime - lastTime_ > 15.) ||
(currentPercentage > lastPercentage_ + 4 && currentTime - lastTime_ > 10.)) {
lastPercentage_ = currentPercentage;
lastTime_ = currentTime;
const double remaining = (currentTime-initialTime_) / (currentI_+1) *
(totalElementToTreat_ - currentI_-1);
if (remaining < 60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g seconds)",
currentPercentage, remaining);
else if (remaining < 60*60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g minutes)",
currentPercentage, remaining/60);
else
Msg::StatusBar(true, "%d%% (remaining time ~%g hours)",
currentPercentage, remaining/3600);
}
}
StringXNumber CurvedMeshOptions_Number[] = {
{GMSH_FULLRC, "Jacobian determinant", NULL, 1},
{GMSH_FULLRC, "Scaled Jacobian", NULL, 0},
......@@ -355,7 +322,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim)
default: break;
}
ProgressStatus progress(num);
MsgProgressStatus progress(num);
_data.reserve(_data.size()+num);
for (unsigned i = 0; i < num; ++i) {
......@@ -366,7 +333,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim)
if (min < 0 && max < 0) {
Msg::Warning("Element %d is completely inverted", el->getNum());
}
progress.check();
progress.next();
}
delete normals;
}
......@@ -377,7 +344,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinScaledJac(int dim)
{
if (_computedS[dim-1]) return;
ProgressStatus progress(_data.size());
MsgProgressStatus progress(_data.size());
for (unsigned int i = 0; i < _data.size(); ++i) {
MElement *const el = _data[i].element();
......@@ -388,7 +355,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinScaledJac(int dim)
else {
_data[i].setMinS(jacobianBasedQuality::minScaledJacobian(el, true));
}
progress.check();
progress.next();
}
_computedS[dim-1] = true;
......@@ -398,7 +365,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinIsotropy(int dim)
{
if (_computedI[dim-1]) return;
ProgressStatus progress(_data.size());
MsgProgressStatus progress(_data.size());
for (unsigned int i = 0; i < _data.size(); ++i) {
MElement *const el = _data[i].element();
......@@ -409,7 +376,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinIsotropy(int dim)
else {
_data[i].setMinI(jacobianBasedQuality::minIsotropyMeasure(el, true));
}
progress.check();
progress.next();
}
_computedI[dim-1] = true;
......
......@@ -36,18 +36,6 @@ public:
double minI() { return _minI; }
};
class ProgressStatus
{
private:
int totalElementToTreat_, currentI_, nextIToCheck_;
double initialTime_, lastTime_;
int lastPercentage_;
public:
ProgressStatus(int num);
void setInitialTime(double time) {initialTime_ = time;}
void check();
};
class GMSH_AnalyseCurvedMeshPlugin : public GMSH_PostPlugin
{
private :
......
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