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

reduce memory overhead of empty steps in model-based views

(best solution would be not to allocate empty steps at all -- todo...)
parent 33a62fca
No related branches found
No related tags found
No related merge requests found
......@@ -51,8 +51,6 @@ class stepData{
: _model(model), _fileName(fileName), _fileIndex(fileIndex), _time(time),
_min(min), _max(max), _numComp(numComp), _data(0)
{
_model->getEntities(_entities);
_bbox = _model->bounds();
}
stepData(stepData<real> &other) : _data(0)
{
......@@ -82,6 +80,8 @@ class stepData{
_partitions = other._partitions;
}
~stepData(){ destroyData(); }
void fillEntities(){ _model->getEntities(_entities); }
void computeBoundingBox(){ _bbox = _model->bounds(); }
GModel *getModel(){ return _model; }
SBoundingBox3d getBoundingBox(){ return _bbox; }
int getNumEntities(){ return _entities.size(); }
......@@ -235,9 +235,10 @@ class PViewDataGModel : public PViewData {
int step, double time, int partition, int numComp);
// I/O routines
bool readMSH(const std::string &fileName, int fileIndex, FILE *fp, bool binary,
bool swap, int step, double time, int partition,
int numComp, int numNodes, const std::string &interpolationScheme);
bool readMSH(const std::string &viewName, const std::string &fileName,
int fileIndex, FILE *fp, bool binary, bool swap, int step,
double time, int partition, int numComp, int numNodes,
const std::string &interpolationScheme);
bool writeMSH(const std::string &fileName, bool binary=false, bool savemesh=true);
bool readMED(const std::string &fileName, int fileIndex);
bool writeMED(const std::string &fileName);
......
......@@ -25,7 +25,8 @@ bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> >
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(model, numComp));
_steps[step]->fillEntities();
_steps[step]->computeBoundingBox();
_steps[step]->setTime(time);
int numEnt = (_type == NodeData) ? model->getNumMeshVertices() :
......@@ -45,21 +46,18 @@ bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> >
return true;
}
bool PViewDataGModel::readMSH(const std::string &fileName, int fileIndex, FILE *fp,
bool binary, bool swap, int step, double time,
int partition, int numComp, int numEnt,
const std::string &interpolationScheme)
bool PViewDataGModel::readMSH(const std::string &viewName, const std::string &fileName,
int fileIndex, FILE *fp, bool binary, bool swap,
int step, double time, int partition, int numComp,
int numEnt, const std::string &interpolationScheme)
{
Msg::Info("Reading step %d (time %g) partition %d: %d records",
step, time, partition, numEnt);
while(step >= (int)_steps.size()){
if(_steps.empty() || _steps.back()->getNumData())
_steps.push_back(new stepData<double>(GModel::current(), numComp));
else // faster since we avoid computing model bounds
_steps.push_back(new stepData<double>(*_steps.back()));
}
Msg::Info("Reading view `%s' step %d (time %g) partition %d: %d records",
viewName.c_str(), step, time, partition, numEnt);
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(GModel::current(), numComp));
_steps[step]->fillEntities();
_steps[step]->computeBoundingBox();
_steps[step]->setFileName(fileName);
_steps[step]->setFileIndex(fileIndex);
_steps[step]->setTime(time);
......@@ -423,6 +421,8 @@ bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex)
}
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(m, numCompMsh));
_steps[step]->fillEntities();
_steps[step]->computeBoundingBox();
_steps[step]->setFileName(fileName);
_steps[step]->setFileIndex(fileIndex);
_steps[step]->setTime(dt);
......
......@@ -210,7 +210,7 @@ bool PView::readMSH(const std::string &fileName, int fileIndex)
if(p) d = dynamic_cast<PViewDataGModel*>(p->getData());
bool create = d ? false : true;
if(create) d = new PViewDataGModel(type);
if(!d->readMSH(fileName, fileIndex, fp, binary, swap, timeStep,
if(!d->readMSH(viewName, fileName, fileIndex, fp, binary, swap, timeStep,
time, partition, numComp, numEnt, interpolationScheme)){
Msg::Error("Could not read data in msh file");
if(create) delete d;
......
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