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

- implemented ElementNodeData

- last thing missing is GaussPointData
parent 467baccf
No related branches found
No related tags found
No related merge requests found
// $Id: PViewDataGModel.cpp,v 1.41 2008-03-30 14:04:21 geuzaine Exp $ // $Id: PViewDataGModel.cpp,v 1.42 2008-03-30 22:59:26 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -162,16 +162,26 @@ int PViewDataGModel::getNumComponents(int step, int ent, int ele) ...@@ -162,16 +162,26 @@ int PViewDataGModel::getNumComponents(int step, int ent, int ele)
void PViewDataGModel::getValue(int step, int ent, int ele, int nod, int comp, double &val) void PViewDataGModel::getValue(int step, int ent, int ele, int nod, int comp, double &val)
{ {
// no sanity checks (assumed to be guarded by skipElement) // no sanity checks (assumed to be guarded by skipElement)
stepData<double> *sd = _steps[step];
if(_type == NodeData){ if(_type == NodeData){
MVertex *v = _steps[step]->getEntity(ent)->getMeshElement(ele)->getVertex(nod); MVertex *v = sd->getEntity(ent)->getMeshElement(ele)->getVertex(nod);
val = _steps[step]->getData(v->getNum())[comp]; val = sd->getData(v->getNum())[comp];
} }
else{ else{
MElement *e = _steps[step]->getEntity(ent)->getMeshElement(ele); MElement *e = sd->getEntity(ent)->getMeshElement(ele);
if(_type == ElementData) switch(_type){
val = _steps[step]->getData(e->getNum())[comp]; case ElementNodeData:
else val = sd->getData(e->getNum())[sd->getNumComponents() * nod + comp];
Msg(GERROR, "ElementNode data not ready yet!"); break;
case GaussPointData:
Msg(WARNING, "GaussPoint data not ready yet!");
val = sd->getData(e->getNum())[comp];
break;
case ElementData:
default:
val = sd->getData(e->getNum())[comp];
break;
}
} }
} }
......
...@@ -122,7 +122,8 @@ class PViewDataGModel : public PViewData { ...@@ -122,7 +122,8 @@ class PViewDataGModel : public PViewData {
enum DataType { enum DataType {
NodeData = 1, NodeData = 1,
ElementData = 2, ElementData = 2,
ElementNodeData = 3 ElementNodeData = 3,
GaussPointData = 4
}; };
private: private:
// the data, indexed by time step // the data, indexed by time step
......
// $Id: PViewDataGModelIO.cpp,v 1.27 2008-03-30 21:35:07 geuzaine Exp $ // $Id: PViewDataGModelIO.cpp,v 1.28 2008-03-30 22:59:26 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -146,6 +146,8 @@ extern "C" { ...@@ -146,6 +146,8 @@ extern "C" {
#include <med.h> #include <med.h>
} }
extern int med2msh(med_geometrie_element med, int k);
bool PViewDataGModel::readMED(std::string fileName, int fileIndex) bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
{ {
med_idt fid = MEDouvrir((char*)fileName.c_str(), MED_LECTURE); med_idt fid = MEDouvrir((char*)fileName.c_str(), MED_LECTURE);
...@@ -249,8 +251,14 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex) ...@@ -249,8 +251,14 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
MED_COMPACT); MED_COMPACT);
if(numVal <= 0) continue; if(numVal <= 0) continue;
int mult = 1; int mult = 1;
if(getType() == ElementNodeData) mult = nodesPerEle[pairs[pair].second]; if(ent == MED_NOEUD_ELEMENT){
if(ngauss) mult *= ngauss; mult = nodesPerEle[pairs[pair].second];
}
else if(ngauss > 1){
mult = ngauss;
setType(GaussPointData);
}
// only a guess, since several element types may be combined // only a guess, since several element types may be combined
_steps[step]->resizeData(numVal / mult); _steps[step]->resizeData(numVal / mult);
...@@ -314,18 +322,17 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex) ...@@ -314,18 +322,17 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
else{ else{
if(profile[i] == 0 || profile[i] > tags.size()){ if(profile[i] == 0 || profile[i] > tags.size()){
Msg(GERROR, "Wrong index in profile"); Msg(GERROR, "Wrong index in profile");
Msg(DEBUG, "nodal=%d prof[%d]=%d #prof=%d #tags=%d numVal=%d mult=%d",
nodal, i, profile[i], profile.size(), tags.size(), numVal, mult);
return false; return false;
} }
num = tags[profile[i] - 1]; num = tags[profile[i] - 1];
} }
double *d = _steps[step]->getData(num, true, mult); double *d = _steps[step]->getData(num, true, mult);
// FIXME: for ElementNodeData, we need to reorder the data for(int j = 0; j < mult; j++){
// before storing it, using med2msh()). Also: what should we // reorder nodes if we have ElementNode data
// do with Gauss point data? int j2 = (ent == MED_NOEUD_ELEMENT) ? med2msh(ele, j) : j;
for(int j = 0; j < numComp * mult; j++) for(int k = 0; k < numComp; k++)
d[j] = val[numComp * mult * i + j]; d[numComp * j + k] = val[numComp * mult * i + numComp * j2 + k];
}
double s = ComputeScalarRep(_steps[step]->getNumComponents(), d); double s = ComputeScalarRep(_steps[step]->getNumComponents(), d);
_steps[step]->setMin(std::min(_steps[step]->getMin(), s)); _steps[step]->setMin(std::min(_steps[step]->getMin(), s));
_steps[step]->setMax(std::max(_steps[step]->getMax(), s)); _steps[step]->setMax(std::max(_steps[step]->getMax(), s));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment