diff --git a/Numeric/fullMatrix.cpp b/Numeric/fullMatrix.cpp index bd4b139e060ae405ed20dc2639b98b285ccbe999..632e1a93ccc31f96f79ef6684025e50c7123a923 100644 --- a/Numeric/fullMatrix.cpp +++ b/Numeric/fullMatrix.cpp @@ -327,6 +327,9 @@ void fullMatrix<double>::registerBindings(binding *b) cm = cb->addMethod("set", &fullMatrix<double>::set); cm->setArgNames("i","j","v",NULL); cm->setDescription("Sets the (i,j) entry of the matrix to v"); + cm = cb->addMethod("resize", &fullMatrix<double>::resize); + cm->setArgNames("nRows","nColumns","reset",NULL); + cm->setDescription("Change the size of the fullMatrix (and re-alloc if needed), values are set to zero if reset is true"); cm = cb->addMethod("gemm", &fullMatrix<double>::gemm); cm->setArgNames("A","B","alpha","beta",NULL); cm->setDescription("this = beta*this + alpha * (A.B)"); diff --git a/Post/PViewData.cpp b/Post/PViewData.cpp index 2a1dc767dbd46638527ad0d6a8d55e4325cf54ac..25869290791d65ebc12c23182d22df8e584ed2b1 100644 --- a/Post/PViewData.cpp +++ b/Post/PViewData.cpp @@ -72,6 +72,12 @@ void PViewData::setValue(int step, int ent, int ele, int nod, int comp, double v Msg::Error("Cannot change field value in this view"); } +MElement *PViewData::getElement(int step, int ent, int ele) +{ + Msg::Error("Cannot get element from this view"); + return NULL; +} + void PViewData::setInterpolationMatrices(int type, const fullMatrix<double> &coefVal, const fullMatrix<double> &expVal) @@ -128,16 +134,13 @@ double PViewData::getValueBinding(int step, int ent, int ele, int nod, int comp) } void PViewData::getAllValuesForElementBinding(int step, int ent, int ele, fullMatrix<double> &m) { - int nNodes = getNumNodes(step,ent,ele); - int nComponents = getNumComponents(step,ent,ele); - for (int i=0; i<nNodes; i++) - for (int j=0; j<nComponents; j++) + for (int i=0; i<m.size1(); i++) + for (int j=0; j<m.size2(); j++) getValue(step,ent,ele,i,j,m(i,j)); } void PViewData::getAllNodesForElementBinding(int step, int ent, int ele, fullMatrix<double> &m) { - int nNodes = getNumNodes(step,ent,ele); - for (int i=0; i<nNodes; i++) + for (int i=0; i<m.size1(); i++) getNode(step,ent,ele,i,m(i,0),m(i,1),m(i,2)); } @@ -160,6 +163,10 @@ void PViewData::registerBindings(binding *b) { cm->setArgNames("step","entity","element",NULL); cm->setDescription("return the number of nodes of one element of an entity of a time step (-1 for default time step)"); + cm = cb->addMethod("getElement",&PViewData::getElement); + cm->setArgNames("step","entity","i",NULL); + cm->setDescription("return the i-th element of the given entity"); + cm = cb->addMethod("getNumValues",&PViewData::getNumValues); cm->setArgNames("step","entity","element",NULL); cm->setDescription("return the number of values of one element of an entity of a time step (-1 for default time step)"); @@ -174,9 +181,13 @@ void PViewData::registerBindings(binding *b) { cm = cb->addMethod("getAllValuesForElement",&PViewData::getAllValuesForElementBinding); cm->setArgNames("step","entity","element","values",NULL); - cm->setDescription("fill a fullMatrix with all values from the elements. The fullMatrix should have the size nbNodes x nbComponents."); + cm->setDescription("resize and fill a fullMatrix with all values from the element."); cm = cb->addMethod("getAllNodesForElement",&PViewData::getAllNodesForElementBinding); cm->setArgNames("step","entity","element","coordinates",NULL); - cm->setDescription("fill a fullMatrix with all coordinates from the nodes of the elements. The fullMatrix should have the size nbNodes x 3"); + cm->setDescription("resize fill a fullMatrix with all coordinates of the nodes of the element"); + + cm = cb->addMethod("getDimension",&PViewData::getDimension); + cm->setArgNames("step","entity","element",NULL); + cm->setDescription("return the geometrical dimension of the element-th element in the enttity-th entity"); } diff --git a/Post/PViewData.h b/Post/PViewData.h index 125a00608964ef612307bfca1b7722d03ce1b96c..e2ccaabdae580b1add96772d2a8a7c66ad63b228 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -17,6 +17,7 @@ class adaptiveData; class GModel; class GEntity; +class MElement; class nameData; class binding; @@ -220,7 +221,7 @@ class PViewData { virtual bool writeMSH(std::string fileName, bool binary=false); virtual bool writeMED(std::string fileName); // - virtual GEntity *getEntity (int step, int entity) {return NULL;} + virtual MElement *getElement (int step, int entity, int element); static void registerBindings(binding *b); }; diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 8b14f91532097d127c987424aa18256ce22e84d2..1b52eeff79c807229135f4daa213b67947de45ce 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -301,6 +301,14 @@ int PViewDataGModel::getNumElements(int step, int ent) return _steps[step]->getEntity(ent)->getNumMeshElements(); } +MElement *PViewDataGModel::getElement(int step, int ent, int element) +{ + if(_steps.empty()) return 0; + // to generalize + if(step < 0) return _steps[0]->getEntity(ent)->getMeshElement(element); + return _steps[step]->getEntity(ent)->getMeshElement(element); +} + int PViewDataGModel::getDimension(int step, int ent, int ele) { return _getElement(step, ent, ele)->getDim(); diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 263ecaef6a8207aa3ef2a44da9b3137c2ffdd3de..0119249e95573ba85b0e976528a3d69326f80e55 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -239,6 +239,7 @@ class PViewDataGModel : public PViewData { bool writeMSH(std::string fileName, bool binary=false); bool readMED(std::string fileName, int fileIndex); bool writeMED(std::string fileName); + MElement *getElement (int step, int entity, int element); }; #endif diff --git a/Post/PViewFactory.cpp b/Post/PViewFactory.cpp index df68730d59e1c58e02483f2362d655d1c9c38f3e..03029d510e9a33374711f29f4babbe1a476c062e 100644 --- a/Post/PViewFactory.cpp +++ b/Post/PViewFactory.cpp @@ -29,13 +29,13 @@ PView *PViewFactory::createView () void PViewFactory::registerBindings (class binding *b) { classBinding *cb = b->addClass<PViewFactory>("PViewFactory"); - cb->setDescription(" "); + cb->setDescription("A class to format the input data of post-procession views"); methodBinding *mb = cb->addMethod("setEntry", &PViewFactory::setEntry); - mb->setDescription(" "); - mb->setArgNames("elementId", "values", NULL); + mb->setDescription("attach data (values) on the ith nodes or elemnent"); + mb->setArgNames("i", "values", NULL); mb = cb->setConstructor<PViewFactory, std::string, std::string, GModel*,int,int>(); - mb->setDescription(" "); + mb->setDescription("create a new factory for post-processing view based on a GModel. The type can be 'NodeData', 'ElementData' or 'ElementNodeData'"); mb->setArgNames("name", "type", "model","timeStep", "dimension", NULL); mb = cb->addMethod("createView",&PViewFactory::createView); - mb->setDescription(" "); + mb->setDescription("create a post-processing view with the current data"); }