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

fixes for ElementNodeData

parent c4531470
No related branches found
No related tags found
No related merge requests found
// $Id: OctreePost.cpp,v 1.10 2008-03-30 15:37:42 geuzaine Exp $ // $Id: OctreePost.cpp,v 1.11 2008-04-02 16:30:29 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -435,7 +435,7 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, doub ...@@ -435,7 +435,7 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, doub
if(timestep < 0 || step == timestep){ if(timestep < 0 || step == timestep){
for(int nod = 0; nod < e->getNumVertices(); nod++){ for(int nod = 0; nod < e->getNumVertices(); nod++){
for(int comp = 0; comp < nbComp; comp++){ for(int comp = 0; comp < nbComp; comp++){
if(!_theViewDataGModel->getValue(step, dataIndex[nod], comp, if(!_theViewDataGModel->getValue(step, dataIndex[nod], nod, comp,
nodeval[nod * nbComp + comp])) nodeval[nod * nbComp + comp]))
return false; return false;
} }
......
// $Id: PViewDataGModel.cpp,v 1.45 2008-04-01 18:20:02 geuzaine Exp $ // $Id: PViewDataGModel.cpp,v 1.46 2008-04-02 16:30:29 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -193,27 +193,19 @@ void PViewDataGModel::getValue(int step, int ent, int ele, int nod, int comp, do ...@@ -193,27 +193,19 @@ void PViewDataGModel::getValue(int step, int ent, int ele, int nod, int comp, do
{ {
// no sanity checks (assumed to be guarded by skipElement) // no sanity checks (assumed to be guarded by skipElement)
stepData<double> *sd = _steps[step]; stepData<double> *sd = _steps[step];
MElement *e = sd->getEntity(ent)->getMeshElement(ele);
switch(_type){ switch(_type){
case NodeData: case NodeData:
{ val = sd->getData(e->getVertex(nod)->getNum())[comp];
MVertex *v = sd->getEntity(ent)->getMeshElement(ele)->getVertex(nod); break;
val = sd->getData(v->getNum())[comp];
break;
}
case ElementNodeData: case ElementNodeData:
case GaussPointData: case GaussPointData:
{ val = sd->getData(e->getNum())[sd->getNumComponents() * nod + comp];
MElement *e = sd->getEntity(ent)->getMeshElement(ele); break;
val = sd->getData(e->getNum())[sd->getNumComponents() * nod + comp];
break;
}
case ElementData: case ElementData:
default: default:
{ val = sd->getData(e->getNum())[comp];
MElement *e = sd->getEntity(ent)->getMeshElement(ele); break;
val = sd->getData(e->getNum())[comp];
break;
}
} }
} }
...@@ -225,7 +217,7 @@ int PViewDataGModel::getNumEdges(int step, int ent, int ele) ...@@ -225,7 +217,7 @@ int PViewDataGModel::getNumEdges(int step, int ent, int ele)
void PViewDataGModel::smooth() void PViewDataGModel::smooth()
{ {
if(_type == NodeData) return; if(_type == NodeData || _type == GaussPointData) return;
std::vector<stepData<double>*> _steps2; std::vector<stepData<double>*> _steps2;
for(unsigned int step = 0; step < _steps.size(); step++){ for(unsigned int step = 0; step < _steps.size(); step++){
GModel *m = _steps[step]->getModel(); GModel *m = _steps[step]->getModel();
...@@ -237,7 +229,7 @@ void PViewDataGModel::smooth() ...@@ -237,7 +229,7 @@ void PViewDataGModel::smooth()
for(int ele = 0; ele < getNumElements(step, ent); ele++){ for(int ele = 0; ele < getNumElements(step, ent); ele++){
MElement *e = _steps[step]->getEntity(ent)->getMeshElement(ele); MElement *e = _steps[step]->getEntity(ent)->getMeshElement(ele);
double val; double val;
if(!getValue(step, e->getNum(), 0, val)) continue; if(!getValue(step, e->getNum(), 0, 0, val)) continue;
for(int nod = 0; nod < e->getNumVertices(); nod++){ for(int nod = 0; nod < e->getNumVertices(); nod++){
MVertex *v = e->getVertex(nod); MVertex *v = e->getVertex(nod);
if(nodeConnect.count(v->getNum())) if(nodeConnect.count(v->getNum()))
...@@ -246,7 +238,7 @@ void PViewDataGModel::smooth() ...@@ -246,7 +238,7 @@ void PViewDataGModel::smooth()
nodeConnect[v->getNum()] = 1; nodeConnect[v->getNum()] = 1;
double *d = _steps2.back()->getData(v->getNum(), true); double *d = _steps2.back()->getData(v->getNum(), true);
for(int j = 0; j < numComp; j++) for(int j = 0; j < numComp; j++)
if(getValue(step, e->getNum(), j, val)) d[j] += val; if(getValue(step, e->getNum(), nod, j, val)) d[j] += val;
} }
} }
} }
...@@ -275,16 +267,16 @@ bool PViewDataGModel::skipEntity(int step, int ent) ...@@ -275,16 +267,16 @@ bool PViewDataGModel::skipEntity(int step, int ent)
bool PViewDataGModel::skipElement(int step, int ent, int ele) bool PViewDataGModel::skipElement(int step, int ent, int ele)
{ {
if(step >= getNumTimeSteps()) return true; if(step >= getNumTimeSteps()) return true;
stepData<double> *data = _steps[step]; stepData<double> *sd = _steps[step];
if(!_steps[step]->getNumData()) return true; if(!_steps[step]->getNumData()) return true;
MElement *e = data->getEntity(ent)->getMeshElement(ele); MElement *e = sd->getEntity(ent)->getMeshElement(ele);
if(!e->getVisibility()) return true; if(!e->getVisibility()) return true;
if(_type == NodeData){ if(_type == NodeData){
for(int i = 0; i < e->getNumVertices(); i++) for(int i = 0; i < e->getNumVertices(); i++)
if(!data->getData(e->getVertex(i)->getNum())) return true; if(!sd->getData(e->getVertex(i)->getNum())) return true;
} }
else{ else{
if(!data->getData(e->getNum())) return true; if(!sd->getData(e->getNum())) return true;
} }
return false; return false;
} }
...@@ -314,10 +306,14 @@ GEntity *PViewDataGModel::getEntity(int step, int ent) ...@@ -314,10 +306,14 @@ GEntity *PViewDataGModel::getEntity(int step, int ent)
return _steps[step]->getEntity(ent); return _steps[step]->getEntity(ent);
} }
bool PViewDataGModel::getValue(int step, int dataIndex, int comp, double &val) bool PViewDataGModel::getValue(int step, int dataIndex, int nod, int comp, double &val)
{ {
double *d = _steps[step]->getData(dataIndex); double *d = _steps[step]->getData(dataIndex);
if(!d) return false; if(!d) return false;
val = d[comp];
if(_type == NodeData || _type == ElementData)
val = d[comp];
else
val = d[_steps[step]->getNumComponents() * nod + comp];
return true; return true;
} }
...@@ -176,7 +176,7 @@ class PViewDataGModel : public PViewData { ...@@ -176,7 +176,7 @@ class PViewDataGModel : public PViewData {
// direct access to GModel entities // direct access to GModel entities
GEntity *getEntity(int step, int ent); GEntity *getEntity(int step, int ent);
// direct access to value by index // direct access to value by index
bool getValue(int step, int dataIndex, int comp, double &val); bool getValue(int step, int dataIndex, int node, int comp, double &val);
// I/O routines // I/O routines
bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary, bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment