diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index f9eafc5f2da3d3141adb2df94f05d0d61ca80eb3..ad76d0a1514c824e2147fcc790a0509597ffc6bc 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -1,4 +1,4 @@ -// $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 // @@ -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) { // no sanity checks (assumed to be guarded by skipElement) + stepData<double> *sd = _steps[step]; if(_type == NodeData){ - MVertex *v = _steps[step]->getEntity(ent)->getMeshElement(ele)->getVertex(nod); - val = _steps[step]->getData(v->getNum())[comp]; + MVertex *v = sd->getEntity(ent)->getMeshElement(ele)->getVertex(nod); + val = sd->getData(v->getNum())[comp]; } else{ - MElement *e = _steps[step]->getEntity(ent)->getMeshElement(ele); - if(_type == ElementData) - val = _steps[step]->getData(e->getNum())[comp]; - else - Msg(GERROR, "ElementNode data not ready yet!"); + MElement *e = sd->getEntity(ent)->getMeshElement(ele); + switch(_type){ + case ElementNodeData: + val = sd->getData(e->getNum())[sd->getNumComponents() * nod + comp]; + 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; + } } } diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 659885b697eee29bc15dcf8faba0c13b3b9455d7..ec02ae11b58bf9d06f047c9b02f3a19767dbb26c 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -122,7 +122,8 @@ class PViewDataGModel : public PViewData { enum DataType { NodeData = 1, ElementData = 2, - ElementNodeData = 3 + ElementNodeData = 3, + GaussPointData = 4 }; private: // the data, indexed by time step diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index 38d0bdf05e261f3ea9a6fe23563bbd81ea711e2e..0dc751fe9f6ec13a08ea57a1dd4f03095fa8c75e 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -1,4 +1,4 @@ -// $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 // @@ -146,6 +146,8 @@ extern "C" { #include <med.h> } +extern int med2msh(med_geometrie_element med, int k); + bool PViewDataGModel::readMED(std::string fileName, int fileIndex) { med_idt fid = MEDouvrir((char*)fileName.c_str(), MED_LECTURE); @@ -249,8 +251,14 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex) MED_COMPACT); if(numVal <= 0) continue; int mult = 1; - if(getType() == ElementNodeData) mult = nodesPerEle[pairs[pair].second]; - if(ngauss) mult *= ngauss; + if(ent == MED_NOEUD_ELEMENT){ + mult = nodesPerEle[pairs[pair].second]; + } + else if(ngauss > 1){ + mult = ngauss; + setType(GaussPointData); + } + // only a guess, since several element types may be combined _steps[step]->resizeData(numVal / mult); @@ -314,18 +322,17 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex) else{ if(profile[i] == 0 || profile[i] > tags.size()){ 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; } num = tags[profile[i] - 1]; } double *d = _steps[step]->getData(num, true, mult); - // FIXME: for ElementNodeData, we need to reorder the data - // before storing it, using med2msh()). Also: what should we - // do with Gauss point data? - for(int j = 0; j < numComp * mult; j++) - d[j] = val[numComp * mult * i + j]; + for(int j = 0; j < mult; j++){ + // reorder nodes if we have ElementNode data + int j2 = (ent == MED_NOEUD_ELEMENT) ? med2msh(ele, j) : j; + for(int k = 0; k < numComp; k++) + d[numComp * j + k] = val[numComp * mult * i + numComp * j2 + k]; + } double s = ComputeScalarRep(_steps[step]->getNumComponents(), d); _steps[step]->setMin(std::min(_steps[step]->getMin(), s)); _steps[step]->setMax(std::max(_steps[step]->getMax(), s));