Commit 0dce3805 authored by Kilian Lackhove's avatar Kilian Lackhove
Browse files

pts Interpolation: return of the progress bar

parent 40f46e0b
......@@ -90,6 +90,11 @@ void PtsField::CalcWeights(
{
CalcW_Shepard(i, physPt);
}
if (m_progressCallback)
{
m_progressCallback(i, nPhysPts);
}
}
}
......
......@@ -40,6 +40,7 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
......@@ -153,6 +154,12 @@ class PtsField
void SetPointsPerEdge(const vector<int> nPtsPerEdge);
template<typename FuncPointerT, typename ObjectPointerT>
void setProgressCallback(FuncPointerT func, ObjectPointerT obj)
{
m_progressCallback = boost::bind(func, obj, _1, _2);
}
private:
/// Dimension of the pts field
......@@ -173,6 +180,8 @@ class PtsField
/// Structure: m_neighInds[ptIdx][neighbourIdx]
Array<OneD, Array<OneD, unsigned int> > m_neighInds;
boost::function<void (const int position, const int goal)> m_progressCallback;
void CalcW_Linear(const int physPtIdx, const NekDouble coord);
void CalcW_Shepard(const int physPtIdx,
......
......@@ -53,6 +53,7 @@
#include <SolverUtils/Diffusion/Diffusion.h>
#include <boost/format.hpp>
# include <boost/function.hpp>
#include <iostream>
......@@ -865,9 +866,13 @@ namespace Nektar
}
else
{
cout << "Computing interpolation weights for file " <<
filename << endl;
ptsField->setProgressCallback(&EquationSystem::PrintProgressbar, this);
ptsField->CalcWeights(coords);
if (m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolating: 100% [===================";
cout << "===============================]" << endl;
}
ptsField->GetWeights(m_interpWeights[weightsKey], m_interpInds[weightsKey]);
}
......@@ -890,6 +895,7 @@ namespace Nektar
}
}
/**
* @brief Provide a description of a function for a given field name.
*
......@@ -2362,5 +2368,33 @@ namespace Nektar
std::vector<std::string> &variables)
{
}
void EquationSystem::PrintProgressbar(const int position, const int goal) const
{
if (m_session->GetComm()->GetRank() != 0)
{
return;
}
if (position % (goal/100 +1))
{
cout << "Interpolating: ";
float progress = position / float(goal);
cout << int(100*progress) << "% [";
for (int j = 0; j < int(progress*50); j++)
{
cout << "=";
}
for (int j = int(progress*50); j < 50; j++)
{
cout << " ";
}
cout << "]" << flush;
// carriage return
cout << "\r";
}
}
}
}
......@@ -596,6 +596,9 @@ namespace Nektar
const Array<OneD, Array<OneD, NekDouble> > &ufield,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &qfield,
Array<OneD, Array<OneD, NekDouble > > &qflux);
SOLVER_UTILS_EXPORT void PrintProgressbar(const int position,
const int goal) const;
};
......
......@@ -101,13 +101,10 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
ASSERTL0(coord_id <= m_f->m_fieldPts->GetDim() - 1,
"interpcoord is bigger than the Pts files dimension");
if(m_f->m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolating..." << endl;
}
// interpolate points and transform
Array<OneD, Array<OneD, NekDouble> > intFields(nFields);
m_f->m_fieldPts->setProgressCallback(
&ProcessInterpPointDataToFld::PrintProgressbar, this);
m_f->m_fieldPts->Interpolate(coords, intFields, coord_id);
for(i = 0; i < totpoints; ++i)
......@@ -120,7 +117,8 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
if(m_f->m_session->GetComm()->GetRank() == 0)
{
cout << "Interpolation completed" << endl;
cout << "Interpolating: 100% [===================";
cout << "===============================]" << endl;
}
// forward transform fields
......@@ -151,6 +149,34 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
}
void ProcessInterpPointDataToFld::PrintProgressbar(const int position, const int goal) const
{
if (m_f->m_session->GetComm()->GetRank() != 0)
{
return;
}
if (position % (goal/100 +1))
{
cout << "Interpolating: ";
float progress = position / float(goal);
cout << int(100*progress) << "% [";
for (int j = 0; j < int(progress*50); j++)
{
cout << "=";
}
for (int j = int(progress*50); j < 50; j++)
{
cout << " ";
}
cout << "]" << flush;
// carriage return
cout << "\r";
}
}
}
}
......
......@@ -61,6 +61,8 @@ public:
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
void PrintProgressbar(const int position, const int goal) const;
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