Commit 46de0668 authored by Kilian Lackhove's avatar Kilian Lackhove
Browse files

PtsIO: handle number of pts files being different to number of ranks

We dont use the partition info here because pts files should be
independant of any meshes/expansions. Instead, we use the file matching
the rank and in case n_ranks!=n_files, we load all pts files for all ranks.
parent fa15c875
......@@ -137,6 +137,27 @@ void PtsField::AddField(const Array< OneD, NekDouble > &pts,
m_fieldNames.push_back(fieldName);
}
void PtsField::AddPoints(const Array<OneD, const Array<OneD, NekDouble> > &pts)
{
ASSERTL1(pts.num_elements() == m_pts.num_elements(),
"number of variables mismatch");
// TODO: dont copy, dont iterate
for (int i = 0; i < m_pts.num_elements(); ++i)
{
Array<OneD, NekDouble> tmp(m_pts[i].num_elements() + pts[i].num_elements());
for (int j = 0; j < m_pts[i].num_elements(); ++j)
{
tmp[j] = m_pts[i][j];
}
for (int j = 0; j < pts[i].num_elements(); ++j)
{
tmp[m_pts[i].num_elements() + j] = pts[i][j];
}
m_pts[i] = tmp;
}
}
int PtsField::GetNpoints() const
{
return m_pts[0].num_elements();
......
......@@ -114,6 +114,8 @@ public:
LIB_UTILITIES_EXPORT void AddField(const Array<OneD, NekDouble> &pts,
const std::string fieldName);
LIB_UTILITIES_EXPORT void AddPoints(const Array< OneD, const Array< OneD, NekDouble > > &pts);
LIB_UTILITIES_EXPORT int GetNpoints() const;
LIB_UTILITIES_EXPORT NekDouble GetPointVal(const int fieldInd,
......
......@@ -47,6 +47,7 @@
#include <LibUtilities/BasicUtils/FileSystem.h>
using namespace std;
namespace Nektar
{
......@@ -138,11 +139,14 @@ void PtsIO::Import(const string &inFile,
// Load metadata
ImportFieldMetaData(infile, fieldmetadatamap);
// TODO: This currently only loads the filename matching our rank.
filenames.clear();
boost::format pad("P%1$07d.%2$s");
pad % m_comm->GetRank() % GetFileEnding();
filenames.push_back(pad.str());
if (filenames.size() == m_comm->GetSize())
{
// only load the file that matches this rank
filenames.clear();
boost::format pad("P%1$07d.%2$s");
pad % m_comm->GetRank() % GetFileEnding();
filenames.push_back(pad.str());
}
for (int i = 0; i < filenames.size(); ++i)
{
......@@ -160,7 +164,19 @@ void PtsIO::Import(const string &inFile,
<< doc1.ErrorCol() << std::endl;
ASSERTL0(loadOkay1, errstr.str());
ImportFieldData(doc1, ptsField);
if (i == 0)
{
ImportFieldData(doc1, ptsField);
}
else
{
LibUtilities::PtsFieldSharedPtr newPtsField;
ImportFieldData(doc1, newPtsField);
Array<OneD, Array<OneD, NekDouble> > pts;
newPtsField->GetPts(pts);
ptsField->AddPoints(pts);
}
}
}
else
......
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