Skip to content
Snippets Groups Projects
Commit 17b10e3d authored by Axel Modave's avatar Axel Modave
Browse files

up and fix Scal2Vec and Scal2Tens --- Scal2Vec is finally not deprecated (that...

up and fix Scal2Vec and Scal2Tens --- Scal2Vec is finally not deprecated (that makes sense to keep it) --- Sorry for multi-commits
parent c147da1a
No related branches found
No related tags found
No related merge requests found
...@@ -34,9 +34,9 @@ extern "C" ...@@ -34,9 +34,9 @@ extern "C"
std::string GMSH_Scal2TensPlugin::getHelp() const std::string GMSH_Scal2TensPlugin::getHelp() const
{ {
return "Plugin(Scal2Tens) converts some scalar fields into a field " return "Plugin(Scal2Tens) converts some scalar fields into a tensor field. "
"with several components. The number of components must be given (max. 9). " "The number of components must be given (max. 9). "
"The new view 'NameNewView' contains the new field. If the number " "The new view 'NameNewView' contains the new tensor field. If the number "
"of a view is -1, the value of the corresponding component is 0."; "of a view is -1, the value of the corresponding component is 0.";
} }
......
...@@ -56,38 +56,26 @@ StringXString *GMSH_Scal2VecPlugin::getOptionStr(int iopt) ...@@ -56,38 +56,26 @@ StringXString *GMSH_Scal2VecPlugin::getOptionStr(int iopt)
PView *GMSH_Scal2VecPlugin::execute(PView *v) PView *GMSH_Scal2VecPlugin::execute(PView *v)
{ {
int iViewX = (int)Scal2VecOptions_Number[0].def; // Load options
int iViewY = (int)Scal2VecOptions_Number[1].def; int iView[3];
int iViewZ = (int)Scal2VecOptions_Number[2].def; for (int comp=0; comp<3; comp++)
iView[comp] = (int)Scal2VecOptions_Number[comp+1].def;
// Load data // Load data
PView *vRef = 0, *vX = 0, *vY = 0, *vZ = 0; PView *vRef=0, *vComp[3];
if(iViewX >= 0){ for (int comp=0; comp<3; comp++) {
vX = getView(iViewX, v); if (iView[comp]<0) vComp[comp] = 0;
if(!vX){ else {
Msg::Error("Scal2Vec plugin could not find View X: %i", iViewX); vComp[comp] = getView(iView[comp], v);
if (!vComp[comp]) {
Msg::Error("Scal2Vec plugin could not find View '%i'", iView[comp]);
return v; return v;
} }
if(!vRef) vRef = vX; if (!vRef) vRef = vComp[comp];
} }
if(iViewY >= 0){
vY = getView(iViewY, v);
if(!vY){
Msg::Error("Scal2Vec plugin could not find View Y: %i", iViewY);
return v;
}
if(!vRef) vRef = vY;
}
if(iViewZ >= 0){
vZ = getView(iViewZ, v);
if(!vZ){
Msg::Error("Scal2Vec plugin could not find View Z: %i", iViewZ);
return v;
}
if(!vRef) vRef = vZ;
} }
if (!vRef) { if (!vRef) {
Msg::Error("Scal2Vec plugin could not find any view.", iViewZ); Msg::Error("Scal2Vec plugin could not find any view.");
return v; return v;
} }
PViewData *dataRef = vRef->getData(); PViewData *dataRef = vRef->getData();
...@@ -100,12 +88,11 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v) ...@@ -100,12 +88,11 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v)
for (int ent=0; ent < dataRef->getNumEntities(step0); ent++) { for (int ent=0; ent < dataRef->getNumEntities(step0); ent++) {
for (int ele=0; ele < dataRef->getNumElements(step0, ent); ele++) { for (int ele=0; ele < dataRef->getNumElements(step0, ent); ele++) {
if (dataRef->skipElement(step0, ent, ele)) continue; if (dataRef->skipElement(step0, ent, ele)) continue;
int numComp = 3; // The 3 components of the new view: x,y,z
int type = dataRef->getType(step0, ent, ele); int type = dataRef->getType(step0, ent, ele);
int numNodes = dataRef->getNumNodes(step0, ent, ele); int numNodes = dataRef->getNumNodes(step0, ent, ele);
std::vector<double> *out = dataNew->incrementList(numComp, type, numNodes); // Pointer in data of the new view std::vector<double> *out = dataNew->incrementList(3, type, numNodes); // Pointer in data of the new view
if (!out) continue; if (!out) continue;
double x[8], y[8], z[8], valX, valY, valZ; double x[8], y[8], z[8];
for (int nod=0; nod<numNodes; nod++) for (int nod=0; nod<numNodes; nod++)
dataRef->getNode(step0, ent, ele, nod, x[nod], y[nod], z[nod]); dataRef->getNode(step0, ent, ele, nod, x[nod], y[nod], z[nod]);
int dim = dataRef->getDimension(step0, ent, ele); int dim = dataRef->getDimension(step0, ent, ele);
...@@ -118,12 +105,11 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v) ...@@ -118,12 +105,11 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v)
for (int step=step0; step < dataRef->getNumTimeSteps(); step++) { for (int step=step0; step < dataRef->getNumTimeSteps(); step++) {
if (!dataRef->hasTimeStep(step)) continue; if (!dataRef->hasTimeStep(step)) continue;
for (int nod=0; nod<numNodes; nod++) { for (int nod=0; nod<numNodes; nod++) {
if (vX) vX->getData()->getValue(step, ent, ele, nod, 0, valX); else valX = 0; for (int comp=0; comp<3; comp++) {
if (vY) vY->getData()->getValue(step, ent, ele, nod, 0, valY); else valY = 0; double val=0.;
if (vZ) vZ->getData()->getValue(step, ent, ele, nod, 0, valZ); else valZ = 0; if(vComp[comp]) vComp[comp]->getData()->getValue(step, ent, ele, nod, 0, val);
out->push_back(valX); // Save values (fx,fy,fz) out->push_back(val); // Save value
out->push_back(valY); }
out->push_back(valZ);
} }
} }
delete element; delete element;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment