Skip to content
Snippets Groups Projects
Commit ef1464bd authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

Add nodal data on the fly

parent aa2cff58
No related branches found
No related tags found
No related merge requests found
......@@ -192,6 +192,14 @@ class PViewDataGModel : public PViewData {
// direct access to value by index
bool getValueByIndex(int step, int dataIndex, int node, int comp, double &val);
// Add some data "on the fly"
// data are stored by vertex, i.e., if field has let's say 3 components,
// nodalData contains 3 * N entries with N being the number of mesh vertices
// of in the model.
// nodlaData [ iVer * N + jComp] is the jComp th component at vertex iVer
bool addNodalData(int step, double time, int partition,
int numComp, const std::vector<double> &nodalData);
// I/O routines
bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary,
bool swap, int step, double time, int partition,
......
// $Id: PViewDataGModelIO.cpp,v 1.42 2008-04-17 10:45:23 geuzaine Exp $
// $Id: PViewDataGModelIO.cpp,v 1.43 2008-04-22 10:02:44 remacle Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
......@@ -30,6 +30,38 @@
#include "Numeric.h"
#include "StringUtils.h"
bool PViewDataGModel::addNodalData(int step,
double time,
int partition,
int numComp,
const std::vector<double> &nodalData){
// add empty steps up to the actual step
while(step >= (int)_steps.size())
_steps.push_back(new stepData<double>(GModel::current(), numComp));
const int mult = 1;
int numEnt = _steps[step]->getModel()->getNumMeshVertices();
if (nodalData.size() != numEnt * numComp){
Msg(GERROR, "adding nodal data with wrong number of entries (%d != %d)",
nodalData.size(), numEnt);
return false;
}
_steps[step]->setTime(time);
_steps[step]->resizeData(numEnt);
for(int i = 0; i < numEnt; i++){
// MVertex *v = _steps[step]->getModel()->getMeshVertexByTag(i);
double *d = _steps[step]->getData(i, true, 1);
for(int j = 0; j < numComp * mult; j++)
d[j] = nodalData[i * numComp + 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment