Commit 1d1e6195 by Kilian Lackhove

Merge branch 'fix/CsvIO-columnsort' into 'master'

csvIO: sort columns in case xyz are not the first ones

See merge request !835
parents ae4f433f d2c5c6fb
......@@ -12,7 +12,7 @@ v5.0.0
- Use chrono in Timer (!807)
- Fix caching of FUNCTION tags that read from file and provide the same
functionality in FUNCTIONs defined for forcings (!759)
- Added native support for csv files in addititon to pts (!760)
- Added native support for csv files in addititon to pts (!760 !835)
- Utilize LAPACK_DIR env variable to find the native blas/lapack install (!827)
**NekMesh**:
......
......@@ -133,10 +133,8 @@ void CsvIO::v_ImportFieldData(const std::string inFile, PtsFieldSharedPtr& ptsFi
dim++;
}
}
fieldNames.erase(fieldNames.begin(), fieldNames.begin() + dim);
int nfields = fieldNames.size();
int totvars = dim + nfields;
int totvars = fieldNames.size();
vector<NekDouble> ptsSerial;
typedef boost::tokenizer< boost::escaped_list_separator<char> > Tokenizer;
......@@ -176,6 +174,31 @@ void CsvIO::v_ImportFieldData(const std::string inFile, PtsFieldSharedPtr& ptsFi
}
}
// reorder pts to make x,y,z the first columns
vector<string> dimNames = {"x", "y", "z"};
for (int i = 0; i < dim; ++i)
{
auto p = find(fieldNames.begin(), fieldNames.end(), dimNames[i]);
if (p != fieldNames.end())
{
int j = distance(fieldNames.begin(), p);
if (i == j)
{
continue;
}
Array<OneD, NekDouble> tmp = pts[i];
pts[i] = pts[j];
pts[j] = tmp;
string tmp2 = fieldNames[i];
fieldNames[i] = fieldNames[j];
fieldNames[j] = tmp2;
}
}
fieldNames.erase(fieldNames.begin(), fieldNames.begin() + dim);
ptsField = MemoryManager<PtsField>::AllocateSharedPtr(dim, fieldNames, pts);
}
......
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 sign in to comment