Commit 6f95ba59 authored by Kilian Lackhove's avatar Kilian Lackhove Committed by Yan Bao
Browse files

revised progressbar

parent 1976cf9f
......@@ -57,6 +57,7 @@ void PtsField::CalcWeights(
ASSERTL1(physCoords.num_elements() >= m_dim, "physCoords is smaller than number of dimesnions");
int nPhysPts = physCoords[0].num_elements();
int lastProg = 0;
m_weights = Array<OneD, Array<OneD, float> >(nPhysPts);
m_neighInds = Array<OneD, Array<OneD, unsigned int> >(nPhysPts);
......@@ -91,9 +92,11 @@ void PtsField::CalcWeights(
CalcW_Shepard(i, physPt);
}
if (m_progressCallback)
int progress = int(100 * i / nPhysPts);
if (m_progressCallback && progress > lastProg)
{
m_progressCallback(i, nPhysPts);
lastProg = progress;
}
}
}
......
......@@ -56,9 +56,17 @@
# include <boost/function.hpp>
#include <iostream>
#include <iomanip>
#include <string>
#ifdef _WIN32
#include <io.h>
#define ISTTY _isatty(_fileno(stdout))
#else
#include <unistd.h>
#define ISTTY isatty(fileno(stdout))
#endif
using std::string;
......@@ -872,11 +880,14 @@ namespace Nektar
else
{
ptsField->setProgressCallback(&EquationSystem::PrintProgressbar, this);
if (m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolating: ";
}
ptsField->CalcWeights(coords);
if (m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolating: 100% [===================";
cout << "===============================]" << endl;
cout << endl;
}
ptsField->GetWeights(m_interpWeights[weightsKey], m_interpInds[weightsKey]);
}
......@@ -2393,24 +2404,31 @@ namespace Nektar
return;
}
if (position % (goal/100 +1))
if (ISTTY)
{
cout << "Interpolating: ";
// carriage return
cout << "\r";
cout << "Interpolating: ";
float progress = position / float(goal);
cout << int(100*progress) << "% [";
for (int j = 0; j < int(progress*50); j++)
cout << setw(3) << int(100* progress) << "% [";
for (int j = 0; j < int(progress *49); j++)
{
cout << "=";
}
for (int j = int(progress*50); j < 50; j++)
for (int j = int(progress *49); j < 49; j++)
{
cout << " ";
}
cout << "]" << flush;
// carriage return
cout << "\r";
}
else
{
// print only every 2 percent
if (int(100 * position / goal) % 2 == 0)
{
cout << "." << flush;
}
}
}
}
......
......@@ -36,6 +36,15 @@
#include <string>
#include <iostream>
#include <iomanip>
#ifdef _WIN32
#include <io.h>
#define ISTTY _isatty(_fileno(stdout))
#else
#include <unistd.h>
#define ISTTY isatty(fileno(stdout))
#endif
using namespace std;
#include "ProcessInterpPointDataToFld.h"
......@@ -105,6 +114,10 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
Array<OneD, Array<OneD, NekDouble> > intFields(nFields);
m_f->m_fieldPts->setProgressCallback(
&ProcessInterpPointDataToFld::PrintProgressbar, this);
if(m_f->m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolating: ";
}
m_f->m_fieldPts->Interpolate(coords, intFields, coord_id);
for(i = 0; i < totpoints; ++i)
......@@ -117,8 +130,7 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
if(m_f->m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolating: 100% [===================";
cout << "===============================]" << endl;
cout << endl;
}
// forward transform fields
......@@ -156,24 +168,31 @@ void ProcessInterpPointDataToFld::PrintProgressbar(const int position, const int
return;
}
if (position % (goal/100 +1))
if (ISTTY)
{
cout << "Interpolating: ";
// carriage return
cout << "\r";
cout << "Interpolating: ";
float progress = position / float(goal);
cout << int(100*progress) << "% [";
for (int j = 0; j < int(progress*50); j++)
cout << setw(3) << int(100* progress) << "% [";
for (int j = 0; j < int(progress *49); j++)
{
cout << "=";
}
for (int j = int(progress*50); j < 50; j++)
for (int j = int(progress *49); j < 49; j++)
{
cout << " ";
}
cout << "]" << flush;
// carriage return
cout << "\r";
}
else
{
// print only every 2 percent
if (int(100 * position / goal) % 2 == 0)
{
cout << "." << flush;
}
}
}
......
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