Skip to content
Snippets Groups Projects
Commit 6af64fad authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

store partition ids per stepData (this should fix reading of

separate multistep, multipartition datasets)
parent e0b8d6e8
No related branches found
No related tags found
No related merge requests found
......@@ -278,7 +278,7 @@ PView *PView::getViewByName(std::string name, int timeStep, int partition)
for(unsigned int i = 0; i < list.size(); i++){
if(list[i]->getData()->getName() == name &&
((timeStep < 0 || !list[i]->getData()->hasTimeStep(timeStep)) ||
(partition < 0 || !list[i]->getData()->hasPartition(partition))))
(partition < 0 || !list[i]->getData()->hasPartition(timeStep, partition))))
return list[i];
}
return 0;
......@@ -289,7 +289,7 @@ PView *PView::getViewByNum(int num, int timeStep, int partition)
for(unsigned int i = 0; i < list.size(); i++){
if(list[i]->getNum() == num &&
((timeStep < 0 || !list[i]->getData()->hasTimeStep(timeStep)) ||
(partition < 0 || !list[i]->getData()->hasPartition(partition))))
(partition < 0 || !list[i]->getData()->hasPartition(timeStep, partition))))
return list[i];
}
return 0;
......
......@@ -164,7 +164,7 @@ class PViewData {
// check if the data has the given step/partition/etc.
virtual bool hasTimeStep(int step){ return step >= 0 && step < getNumTimeSteps(); }
virtual bool hasPartition(int part){ return false; }
virtual bool hasPartition(int step, int part){ return false; }
virtual bool hasMultipleMeshes(){ return false; }
virtual bool hasModel(GModel *model, int step=-1){ return false; }
......
......@@ -500,9 +500,11 @@ bool PViewDataGModel::hasTimeStep(int step)
return false;
}
bool PViewDataGModel::hasPartition(int part)
bool PViewDataGModel::hasPartition(int step, int part)
{
return _partitions.find(part) != _partitions.end();
if(step < 0 || step >= getNumTimeSteps())
return false;
return _steps[step]->getPartitions().find(part) != _steps[step]->getPartitions().end();
}
bool PViewDataGModel::hasMultipleMeshes()
......
......@@ -38,6 +38,8 @@ class stepData{
// a vector, indexed by MSH element type, of Gauss point locations
// in parametric space
std::vector<std::vector<double> > _gaussPoints;
// a set of all "partitions" encountered in the data
std::set<int> _partitions;
public:
stepData(GModel *model, int numComp, std::string fileName="", int fileIndex=-1,
double time=0., double min=VAL_INF, double max=-VAL_INF)
......@@ -101,6 +103,7 @@ class stepData{
if((int)_gaussPoints.size() <= msh) _gaussPoints.resize(msh + 1);
return _gaussPoints[msh];
}
std::set<int> &getPartitions(){ return _partitions; }
};
// The data container using elements from one or more GModel(s).
......@@ -117,8 +120,6 @@ class PViewDataGModel : public PViewData {
std::vector<stepData<double>*> _steps;
// the global min/max of the view
double _min, _max;
// a set of all "partitions" encountered in the input data
std::set<int> _partitions;
// the type of the dataset
DataType _type;
// cache last element to speed up loops
......@@ -168,7 +169,7 @@ class PViewDataGModel : public PViewData {
bool skipEntity(int step, int ent);
bool skipElement(int step, int ent, int ele, bool checkVisibility=false);
bool hasTimeStep(int step);
bool hasPartition(int part);
bool hasPartition(int step, int part);
bool hasMultipleMeshes();
bool hasModel(GModel *model, int step=-1);
bool useGaussPoints(){ return _type == GaussPointData; }
......
......@@ -39,7 +39,7 @@ bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> >
for(int j = 0; j < numComp; j++)
d[j] = it->second[j];
}
_partitions.insert(partition);
_steps[step]->getPartitions().insert(partition);
finalize();
return true;
}
......@@ -49,7 +49,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
int partition, int numComp, int numEnt)
{
Msg::Info("Reading step %d (time %g) partition %d: %d records",
step, time, partition, numEnt);
step, time, partition, numEnt);
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(GModel::current(), numComp));
......@@ -100,7 +100,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
Msg::ProgressMeter(i + 1, numEnt, "Reading data");
}
_partitions.insert(partition);
_steps[step]->getPartitions().insert(partition);
finalize();
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment