Skip to content
Snippets Groups Projects
Commit ba47bd8f authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

Merge branch 'validity' into 'master'

Validity

See merge request !11
parents b3cbb0a7 a7f94810
No related branches found
No related tags found
No related merge requests found
...@@ -749,6 +749,8 @@ void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...) ...@@ -749,6 +749,8 @@ void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...)
double percent = 100. * (double)n/(double)N; double percent = 100. * (double)n/(double)N;
if(percent >= _progressMeterCurrent || n > N - 1){ if(percent >= _progressMeterCurrent || n > N - 1){
while(_progressMeterCurrent < percent)
_progressMeterCurrent += _progressMeterStep;
char str[5000], str2[5000]; char str[5000], str2[5000];
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
...@@ -775,10 +777,6 @@ void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...) ...@@ -775,10 +777,6 @@ void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...)
#if defined(_OPENMP) #if defined(_OPENMP)
#pragma omp critical #pragma omp critical
#endif #endif
{
while(_progressMeterCurrent < percent)
_progressMeterCurrent += _progressMeterStep;
}
} }
} }
...@@ -1560,3 +1558,47 @@ int Msg::GetMaxThreads(){ return 1; } ...@@ -1560,3 +1558,47 @@ int Msg::GetMaxThreads(){ return 1; }
int Msg::GetThreadNum(){ return 0; } int Msg::GetThreadNum(){ return 0; }
#endif #endif
MsgProgressStatus::MsgProgressStatus(int num)
: totalElementToTreat_(num), currentI_(0), nextIToCheck_(0),
initialTime_(Cpu()), lastTime_(initialTime_), lastPercentage_(0),
progressMeterStep_(Msg::GetProgressMeterStep())
{
Msg::SetProgressMeterStep(1);
Msg::ResetProgressMeter();
}
MsgProgressStatus::~MsgProgressStatus()
{
Msg::ProgressMeter(totalElementToTreat_, totalElementToTreat_, true, "done");
Msg::SetProgressMeterStep(progressMeterStep_);
}
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::ProgressMeter(currentI_-1, totalElementToTreat_, true, "%d%% (remaining time ~%g seconds)",
currentPercentage, remaining);
else if (remaining < 60*60*2)
Msg::ProgressMeter(currentI_-1, totalElementToTreat_, true, "%d%% (remaining time ~%g minutes)",
currentPercentage, remaining/60);
else
Msg::ProgressMeter(currentI_-1, totalElementToTreat_, true, "%d%% (remaining time ~%g hours)",
currentPercentage, remaining/3600);
}
}
\ No newline at end of file
...@@ -152,4 +152,20 @@ class Msg { ...@@ -152,4 +152,20 @@ class Msg {
static void ImportPhysicalGroupsInOnelab(); 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 #endif
...@@ -322,9 +322,9 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim) ...@@ -322,9 +322,9 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim)
default: break; default: break;
} }
double initial, time = initial = Cpu(); MsgProgressStatus progress(num);
unsigned int percentage = 0, nextCheck = 0;
_data.reserve(_data.size()+num);
for (unsigned i = 0; i < num; ++i) { for (unsigned i = 0; i < num; ++i) {
MElement *el = entity->getMeshElement(i); MElement *el = entity->getMeshElement(i);
double min, max; double min, max;
...@@ -333,51 +333,18 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim) ...@@ -333,51 +333,18 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim)
if (min < 0 && max < 0) { if (min < 0 && max < 0) {
Msg::Warning("Element %d is completely inverted", el->getNum()); Msg::Warning("Element %d is completely inverted", el->getNum());
} }
progress.next();
if (i >= nextCheck) {
nextCheck += _data.size() / 100;
double curTime = Cpu();
unsigned int curPercentage = i*100/_data.size();
if ((curTime - time > 10. && curPercentage > percentage + 4) ||
(curTime - time > 15. && curPercentage < 5)) {
percentage = curPercentage;
time = curTime;
const double remaining = (time-initial) / (i+1) * (_data.size() - i-1);
if (remaining < 60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g seconds)",
percentage, remaining);
else if (remaining < 60*60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g minutes)",
percentage, remaining/60);
else
Msg::StatusBar(true, "%d%% (remaining time ~%g hours)",
percentage, remaining/3600);
}
}
} }
delete normals; delete normals;
} }
_computedJ[dim-1] = true; _computedJ[dim-1] = true;
} }
void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(MElement *const*el, int numEl)
{
for (int k = 0; k < numEl; ++k) {
double min, max;
jacobianBasedQuality::minMaxJacobianDeterminant(el[k], min, max);
_data.push_back(data_elementMinMax(el[k], min, max));
if (min < 0 && max < 0) {
Msg::Warning("Element %d is completely inverted", el[k]->getNum());
}
}
}
void GMSH_AnalyseCurvedMeshPlugin::_computeMinScaledJac(int dim) void GMSH_AnalyseCurvedMeshPlugin::_computeMinScaledJac(int dim)
{ {
if (_computedS[dim-1]) return; if (_computedS[dim-1]) return;
double initial, time = initial = Cpu(); MsgProgressStatus progress(_data.size());
unsigned int percentage = 0, nextCheck = 0;
for (unsigned int i = 0; i < _data.size(); ++i) { for (unsigned int i = 0; i < _data.size(); ++i) {
MElement *const el = _data[i].element(); MElement *const el = _data[i].element();
...@@ -388,32 +355,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinScaledJac(int dim) ...@@ -388,32 +355,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinScaledJac(int dim)
else { else {
_data[i].setMinS(jacobianBasedQuality::minScaledJacobian(el, true)); _data[i].setMinS(jacobianBasedQuality::minScaledJacobian(el, true));
} }
// Msg::Info("Scaled Jac"); progress.next();
// Msg::Info("==========");
// for (int k = 1; k < 30; ++k) {
// Msg::Info("%.10g", jacobianBasedQuality::minSampledScaledJacobian(el, k));
// }
// Msg::Info(" ");
if (i >= nextCheck) {
nextCheck += _data.size() / 100;
double curTime = Cpu();
unsigned int curPercentage = i*100/_data.size();
if ((curTime - time > 10. && curPercentage > percentage + 4) ||
(curTime - time > 15. && curPercentage < 5)) {
percentage = curPercentage;
time = curTime;
const double remaining = (time-initial) / (i+1) * (_data.size() - i-1);
if (remaining < 60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g seconds)",
percentage, remaining);
else if (remaining < 60*60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g minutes)",
percentage, remaining/60);
else
Msg::StatusBar(true, "%d%% (remaining time ~%g hours)",
percentage, remaining/3600);
}
}
} }
_computedS[dim-1] = true; _computedS[dim-1] = true;
...@@ -423,8 +365,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinIsotropy(int dim) ...@@ -423,8 +365,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinIsotropy(int dim)
{ {
if (_computedI[dim-1]) return; if (_computedI[dim-1]) return;
double initial, time = initial = Cpu(); MsgProgressStatus progress(_data.size());
unsigned int percentage = 0, nextCheck = 0;
for (unsigned int i = 0; i < _data.size(); ++i) { for (unsigned int i = 0; i < _data.size(); ++i) {
MElement *const el = _data[i].element(); MElement *const el = _data[i].element();
...@@ -435,32 +376,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinIsotropy(int dim) ...@@ -435,32 +376,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinIsotropy(int dim)
else { else {
_data[i].setMinI(jacobianBasedQuality::minIsotropyMeasure(el, true)); _data[i].setMinI(jacobianBasedQuality::minIsotropyMeasure(el, true));
} }
// Msg::Info("Isotropy"); progress.next();
// Msg::Info("========");
// for (int k = 1; k < 30; ++k) {
// Msg::Info("%.10g", jacobianBasedQuality::minSampledIsotropyMeasure(el, k));
// }
// Msg::Info(" ");
if (i >= nextCheck) {
nextCheck += _data.size() / 100;
double curTime = Cpu();
unsigned int curPercentage = i*100/_data.size();
if ((curTime - time > 10. && curPercentage > percentage + 4) ||
(curTime - time > 15. && curPercentage < 5)) {
percentage = curPercentage;
time = curTime;
const double remaining = (time-initial) / (i+1) * (_data.size() - i-1);
if (remaining < 60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g seconds)",
percentage, remaining);
else if (remaining < 60*60*2)
Msg::StatusBar(true, "%d%% (remaining time ~%g minutes)",
percentage, remaining/60);
else
Msg::StatusBar(true, "%d%% (remaining time ~%g hours)",
percentage, remaining/3600);
}
}
} }
_computedI[dim-1] = true; _computedI[dim-1] = true;
...@@ -585,28 +501,4 @@ void GMSH_AnalyseCurvedMeshPlugin::_printStatIsotropy() ...@@ -585,28 +501,4 @@ void GMSH_AnalyseCurvedMeshPlugin::_printStatIsotropy()
infminI, avgminI, supminI); infminI, avgminI, supminI);
} }
// For testing
void GMSH_AnalyseCurvedMeshPlugin::computeMinR(MElement *const *el,
int numEl,
double *minR,
bool *straight)
{
_computedJ[el[0]->getDim()-1] = false;
_computedI[el[0]->getDim()-1] = false;
_data.clear();
_computeMinMaxJandValidity(el, numEl);
_computeMinIsotropy(el[0]->getDim());
if (minR) {
for (unsigned int i = 0; i < _data.size(); ++i) {
minR[i] = _data[i].minI();
}
}
if (straight) {
for (unsigned int i = 0; i < _data.size(); ++i) {
straight[i] = 0;
}
}
}
#endif #endif
...@@ -73,40 +73,8 @@ public : ...@@ -73,40 +73,8 @@ public :
StringXNumber* getOption(int); StringXNumber* getOption(int);
PView* execute(PView *); PView* execute(PView *);
// For testing
void computeMinJ(MElement *const *el, int numEl, double *minJ, bool *straight)
{
std::vector<data_elementMinMax> save(_data);
_data.clear();
_computeMinMaxJandValidity(el, numEl);
if (minJ) {
for (unsigned int i = 0; i < _data.size(); ++i) {
minJ[i] = _data[i].minJ();
}
}
if (straight) {
for (unsigned int i = 0; i < _data.size(); ++i) {
straight[i] = _data[i].maxJ() - _data[i].minJ() < 1e-5;
}
}
_data = save;
}
void computeMinR(MElement *const *el, int numEl, double *minR, bool *straight);
void test(MElement *const *el, int numEl, int dim)
{
std::vector<data_elementMinMax> save(_data);
_data.clear();
_computeMinMaxJandValidity(el, numEl);
Msg::Info("aaa");
Msg::Info("aaa");
_computeMinIsotropy(dim);
_data = save;
}
private : private :
void _computeMinMaxJandValidity(int dim); void _computeMinMaxJandValidity(int dim);
void _computeMinMaxJandValidity(MElement *const *, int numEl);
void _computeMinScaledJac(int dim); void _computeMinScaledJac(int dim);
void _computeMinIsotropy(int dim); void _computeMinIsotropy(int dim);
int _hideWithThreshold(int askedDim, int whichMeasure); int _hideWithThreshold(int askedDim, int whichMeasure);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment