Skip to content
Snippets Groups Projects
Commit f56897c6 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

more bindings on PViewData : I'm not sure those bindings are the way to go but...

more bindings on PViewData : I'm not sure those bindings are the way to go but I needed a quick solution for the summer school, christophe please remove this commit if you think they are bad.
parent 86729b9c
No related branches found
No related tags found
No related merge requests found
...@@ -327,6 +327,9 @@ void fullMatrix<double>::registerBindings(binding *b) ...@@ -327,6 +327,9 @@ void fullMatrix<double>::registerBindings(binding *b)
cm = cb->addMethod("set", &fullMatrix<double>::set); cm = cb->addMethod("set", &fullMatrix<double>::set);
cm->setArgNames("i","j","v",NULL); cm->setArgNames("i","j","v",NULL);
cm->setDescription("Sets the (i,j) entry of the matrix to v"); 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 = cb->addMethod("gemm", &fullMatrix<double>::gemm);
cm->setArgNames("A","B","alpha","beta",NULL); cm->setArgNames("A","B","alpha","beta",NULL);
cm->setDescription("this = beta*this + alpha * (A.B)"); cm->setDescription("this = beta*this + alpha * (A.B)");
......
...@@ -72,6 +72,12 @@ void PViewData::setValue(int step, int ent, int ele, int nod, int comp, double v ...@@ -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"); 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, void PViewData::setInterpolationMatrices(int type,
const fullMatrix<double> &coefVal, const fullMatrix<double> &coefVal,
const fullMatrix<double> &expVal) const fullMatrix<double> &expVal)
...@@ -128,16 +134,13 @@ double PViewData::getValueBinding(int step, int ent, int ele, int nod, int comp) ...@@ -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) { void PViewData::getAllValuesForElementBinding(int step, int ent, int ele, fullMatrix<double> &m) {
int nNodes = getNumNodes(step,ent,ele); for (int i=0; i<m.size1(); i++)
int nComponents = getNumComponents(step,ent,ele); for (int j=0; j<m.size2(); j++)
for (int i=0; i<nNodes; i++)
for (int j=0; j<nComponents; j++)
getValue(step,ent,ele,i,j,m(i,j)); getValue(step,ent,ele,i,j,m(i,j));
} }
void PViewData::getAllNodesForElementBinding(int step, int ent, int ele, fullMatrix<double> &m) { void PViewData::getAllNodesForElementBinding(int step, int ent, int ele, fullMatrix<double> &m) {
int nNodes = getNumNodes(step,ent,ele); for (int i=0; i<m.size1(); i++)
for (int i=0; i<nNodes; i++)
getNode(step,ent,ele,i,m(i,0),m(i,1),m(i,2)); getNode(step,ent,ele,i,m(i,0),m(i,1),m(i,2));
} }
...@@ -160,6 +163,10 @@ void PViewData::registerBindings(binding *b) { ...@@ -160,6 +163,10 @@ void PViewData::registerBindings(binding *b) {
cm->setArgNames("step","entity","element",NULL); 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->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 = cb->addMethod("getNumValues",&PViewData::getNumValues);
cm->setArgNames("step","entity","element",NULL); 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)"); 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) { ...@@ -174,9 +181,13 @@ void PViewData::registerBindings(binding *b) {
cm = cb->addMethod("getAllValuesForElement",&PViewData::getAllValuesForElementBinding); cm = cb->addMethod("getAllValuesForElement",&PViewData::getAllValuesForElementBinding);
cm->setArgNames("step","entity","element","values",NULL); 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 = cb->addMethod("getAllNodesForElement",&PViewData::getAllNodesForElementBinding);
cm->setArgNames("step","entity","element","coordinates",NULL); 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");
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
class adaptiveData; class adaptiveData;
class GModel; class GModel;
class GEntity; class GEntity;
class MElement;
class nameData; class nameData;
class binding; class binding;
...@@ -220,7 +221,7 @@ class PViewData { ...@@ -220,7 +221,7 @@ class PViewData {
virtual bool writeMSH(std::string fileName, bool binary=false); virtual bool writeMSH(std::string fileName, bool binary=false);
virtual bool writeMED(std::string fileName); 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); static void registerBindings(binding *b);
}; };
......
...@@ -301,6 +301,14 @@ int PViewDataGModel::getNumElements(int step, int ent) ...@@ -301,6 +301,14 @@ int PViewDataGModel::getNumElements(int step, int ent)
return _steps[step]->getEntity(ent)->getNumMeshElements(); 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) int PViewDataGModel::getDimension(int step, int ent, int ele)
{ {
return _getElement(step, ent, ele)->getDim(); return _getElement(step, ent, ele)->getDim();
......
...@@ -239,6 +239,7 @@ class PViewDataGModel : public PViewData { ...@@ -239,6 +239,7 @@ class PViewDataGModel : public PViewData {
bool writeMSH(std::string fileName, bool binary=false); bool writeMSH(std::string fileName, bool binary=false);
bool readMED(std::string fileName, int fileIndex); bool readMED(std::string fileName, int fileIndex);
bool writeMED(std::string fileName); bool writeMED(std::string fileName);
MElement *getElement (int step, int entity, int element);
}; };
#endif #endif
...@@ -29,13 +29,13 @@ PView *PViewFactory::createView () ...@@ -29,13 +29,13 @@ PView *PViewFactory::createView ()
void PViewFactory::registerBindings (class binding *b) void PViewFactory::registerBindings (class binding *b)
{ {
classBinding *cb = b->addClass<PViewFactory>("PViewFactory"); 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); methodBinding *mb = cb->addMethod("setEntry", &PViewFactory::setEntry);
mb->setDescription(" "); mb->setDescription("attach data (values) on the ith nodes or elemnent");
mb->setArgNames("elementId", "values", NULL); mb->setArgNames("i", "values", NULL);
mb = cb->setConstructor<PViewFactory, std::string, std::string, GModel*,int,int>(); 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->setArgNames("name", "type", "model","timeStep", "dimension", NULL);
mb = cb->addMethod("createView",&PViewFactory::createView); mb = cb->addMethod("createView",&PViewFactory::createView);
mb->setDescription(" "); mb->setDescription("create a post-processing view with the current data");
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment