Select Git revision
Callbacks.cpp
Forked from
gmsh / gmsh
Source project has a limited visibility.
PViewDataGModelIO.cpp 17.86 KiB
// Gmsh - Copyright (C) 1997-2009 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)
{
if(data.empty()) return false;
int 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++){
double *d = _steps[step]->getData(it->first, true);
for(int j = 0; j < numComp; j++)
d[j] = it->second[j];
}
_partitions.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)
{
Msg::Info("Reading step %d (time %g) partition %d: %d records",
step, time, partition, numEnt);
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(GModel::current(), numComp));
_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++)
numSteps += _steps[i]->getNumData() ? 1 : 0;
if(numSteps > maxSteps) return true;
_steps[step]->resizeData(numEnt);
Msg::ResetProgressMeter();
for(int i = 0; i < numEnt; i++){
int num;
if(binary){
if(fread(&num, sizeof(int), 1, fp) != 1) return false;