Select Git revision
Forked from
gmsh / gmsh
Source project has a limited visibility.
-
Christophe Geuzaine authoredChristophe Geuzaine authored
PViewDataGModelIO.cpp 20.58 KiB
// Gmsh - Copyright (C) 1997-2011 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include "GmshConfig.h"
#include "GmshMessage.h"
#include "PViewDataGModel.h"
#include "MVertex.h"
#include "MElement.h"
#include "Numeric.h"
#include "StringUtils.h"
bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> > &data,
int step, double time, int partition, int numComp)
{
if(data.empty()) return false;
if (numComp < 0){
numComp = 9;
for(std::map<int, std::vector<double> >::iterator it = data.begin();
it != data.end(); it++)
numComp = std::min(numComp, (int)it->second.size());
}
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(model, numComp));
_steps[step]->setTime(time);
int numEnt = (_type == NodeData) ? model->getNumMeshVertices() :
model->getNumMeshElements();
_steps[step]->resizeData(numEnt);
for(std::map<int, std::vector<double> >::iterator it = data.begin();
it != data.end(); it++){
int mult = it->second.size() / numComp;
double *d = _steps[step]->getData(it->first, true, mult);
for(int j = 0; j < numComp * mult; j++)
d[j] = it->second[j];
}
if(partition >= 0)
_steps[step]->getPartitions().insert(partition);
finalize();
return true;
}
bool PViewDataGModel::readMSH(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()));
}
_steps[step]->setFileName(fileName);
_steps[step]->setFileIndex(fileIndex);
_steps[step]->setTime(time);
/*
// if we already have maxSteps for this view, return
int numSteps = 0, maxSteps = 1000000000;
for(unsigned int i = 0; i < _steps.size(); i++)