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

better combineTime

parent 11b3db15
No related branches found
No related tags found
No related merge requests found
...@@ -515,33 +515,12 @@ bool PViewDataGModel::combineTime(nameData &nd) ...@@ -515,33 +515,12 @@ bool PViewDataGModel::combineTime(nameData &nd)
for(unsigned int i = 0; i < it->second.size(); i++) for(unsigned int i = 0; i < it->second.size(); i++)
_interpolation[it->first].push_back(new fullMatrix<double>(*it->second[i])); _interpolation[it->first].push_back(new fullMatrix<double>(*it->second[i]));
for(unsigned int i = 0; i < data.size(); i++){ // (deep) copy step data
// FIXME: this is a horrible hack (we copy the data twice, and use for(unsigned int i = 0; i < data.size(); i++)
// a map!); we need to store the number of values per for(unsigned int j = 0; j < data[i]->_steps.size(); j++)
// node/ele/... in stepData and provide a copy constructor, then if(data[i]->hasTimeStep(j))
// just copy the stepData _steps.push_back(new stepData<double>(*data[i]->_steps[j]));
for(unsigned int j = 0; j < data[i]->_steps.size(); j++){
if(data[i]->hasTimeStep(j)){
std::map<int, std::vector<double> > datamap;
if(getType() == NodeData){
stepData<double> *sd = data[i]->_steps[j];
for(unsigned int k = 0; k < sd->getNumData(); k++){
double *d = sd->getData(k);
if(d){
for(int l = 0; l < sd->getNumComponents(); l++){
datamap[k].push_back(d[l]);
}
}
}
}
else{
Msg::Error("Combine time not ready for non nodal model-based datasets");
}
addData(data[i]->getModel(j), datamap, i, data[i]->getTime(j), 0, -1);
}
}
}
std::string tmp; std::string tmp;
if(nd.name == "__all__") if(nd.name == "__all__")
tmp = "all"; tmp = "all";
......
...@@ -35,6 +35,11 @@ class stepData{ ...@@ -35,6 +35,11 @@ class stepData{
// the data and 2) not to store any additional info in MVertex or // the data and 2) not to store any additional info in MVertex or
// MElement) // MElement)
std::vector<real*> *_data; std::vector<real*> *_data;
// a vector containing the multiplying factor allowing to compute
// the number of values stored in _data for each index (number of
// values = getMult() * getNumComponents()). If _mult is empty, a
// default value of "1" is assumed
std::vector<int> _mult;
// a vector, indexed by MSH element type, of Gauss point locations // a vector, indexed by MSH element type, of Gauss point locations
// in parametric space // in parametric space
std::vector<std::vector<double> > _gaussPoints; std::vector<std::vector<double> > _gaussPoints;
...@@ -49,12 +54,44 @@ class stepData{ ...@@ -49,12 +54,44 @@ class stepData{
_model->getEntities(_entities); _model->getEntities(_entities);
_bbox = _model->bounds(); _bbox = _model->bounds();
} }
stepData(stepData<real> &other) : _data(0)
{
_model = other._model;
_entities = other._entities;
_bbox = other._bbox;
_fileName = other._fileName;
_fileIndex = other._fileIndex;
_time = other._time;
_min = other._min;
_max = other._max;
_numComp = other._numComp;
if(other._data){
int n = other.getNumData();
_data = new std::vector<real*>(n, (real*)0);
for(int i = 0; i < n; i++){
real *d = other.getData(i);
if(d){
int m = other.getMult(i) * _numComp;
(*_data)[i] = new real[m];
for(int j = 0; j < m; j++) (*_data)[i][j] = d[j];
}
}
}
_mult = other._mult;
_gaussPoints = other._gaussPoints;
_partitions = other._partitions;
}
~stepData(){ destroyData(); } ~stepData(){ destroyData(); }
GModel *getModel(){ return _model; } GModel *getModel(){ return _model; }
SBoundingBox3d getBoundingBox(){ return _bbox; } SBoundingBox3d getBoundingBox(){ return _bbox; }
int getNumEntities(){ return _entities.size(); } int getNumEntities(){ return _entities.size(); }
GEntity *getEntity(int ent){ return _entities[ent]; } GEntity *getEntity(int ent){ return _entities[ent]; }
int getNumComponents(){ return _numComp; } int getNumComponents(){ return _numComp; }
int getMult(int index)
{
if(index < 0 || index >= _mult.size()) return 1;
return _mult[index];
}
std::string getFileName(){ return _fileName; } std::string getFileName(){ return _fileName; }
void setFileName(std::string name){ _fileName = name; } void setFileName(std::string name){ _fileName = name; }
int getFileIndex(){ return _fileIndex; } int getFileIndex(){ return _fileIndex; }
...@@ -83,6 +120,10 @@ class stepData{ ...@@ -83,6 +120,10 @@ class stepData{
(*_data)[index] = new real[_numComp * mult]; (*_data)[index] = new real[_numComp * mult];
for(int i = 0; i < _numComp * mult; i++) (*_data)[index][i] = 0.; for(int i = 0; i < _numComp * mult; i++) (*_data)[index][i] = 0.;
} }
if(mult > 1){
if(index >= _mult.size()) _mult.resize(index + 100, 1); // optimize this
_mult[index] = mult;
}
} }
else{ else{
if(index >= getNumData()) return 0; if(index >= getNumData()) return 0;
......
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