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

new plugin Scal2Tens (evolution of Scal2Vec) --- Scal2Vec in deprecated (no...

new plugin Scal2Tens (evolution of Scal2Vec) --- Scal2Vec in deprecated (no longer available in the GUI - available for scripts)
parent 175141b1
No related branches found
No related tags found
No related merge requests found
...@@ -247,6 +247,8 @@ void PluginManager::registerDefaultPlugins() ...@@ -247,6 +247,8 @@ void PluginManager::registerDefaultPlugins()
("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin())); ("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("Scal2Tens", GMSH_RegisterScal2TensPlugin())); ("Scal2Tens", GMSH_RegisterScal2TensPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("Scal2Vec", GMSH_RegisterScal2VecPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("NewView", GMSH_RegisterNewViewPlugin())); ("NewView", GMSH_RegisterNewViewPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
......
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
#include "shapeFunctions.h" #include "shapeFunctions.h"
StringXNumber Scal2TensOptions_Number[] = { StringXNumber Scal2TensOptions_Number[] = {
{GMSH_FULLRC, "NumberOfComponents", NULL, 3.}, {GMSH_FULLRC, "NumberOfComponents", NULL, 9},
{GMSH_FULLRC, "Comp0", NULL, -1.}, {GMSH_FULLRC, "View0", NULL, -1},
{GMSH_FULLRC, "Comp1", NULL, -1.}, {GMSH_FULLRC, "View1", NULL, -1},
{GMSH_FULLRC, "Comp2", NULL, -1.}, {GMSH_FULLRC, "View2", NULL, -1},
{GMSH_FULLRC, "Comp3", NULL, -1.}, {GMSH_FULLRC, "View3", NULL, -1},
{GMSH_FULLRC, "Comp4", NULL, -1.}, {GMSH_FULLRC, "View4", NULL, -1},
{GMSH_FULLRC, "Comp5", NULL, -1.}, {GMSH_FULLRC, "View5", NULL, -1},
{GMSH_FULLRC, "Comp6", NULL, -1.}, {GMSH_FULLRC, "View6", NULL, -1},
{GMSH_FULLRC, "Comp7", NULL, -1.}, {GMSH_FULLRC, "View7", NULL, -1},
{GMSH_FULLRC, "Comp8", NULL, -1.} {GMSH_FULLRC, "View8", NULL, -1}
}; };
StringXString Scal2TensOptions_String[] = { StringXString Scal2TensOptions_String[] = {
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include "shapeFunctions.h" #include "shapeFunctions.h"
StringXNumber Scal2VecOptions_Number[] = { StringXNumber Scal2VecOptions_Number[] = {
{GMSH_FULLRC, "ViewX", NULL, -1.}, {GMSH_FULLRC, "ViewX", NULL, -1},
{GMSH_FULLRC, "ViewY", NULL, -1.}, {GMSH_FULLRC, "ViewY", NULL, -1},
{GMSH_FULLRC, "ViewZ", NULL, -1.} {GMSH_FULLRC, "ViewZ", NULL, -1}
}; };
StringXString Scal2VecOptions_String[] = { StringXString Scal2VecOptions_String[] = {
...@@ -30,9 +30,7 @@ std::string GMSH_Scal2VecPlugin::getHelp() const ...@@ -30,9 +30,7 @@ std::string GMSH_Scal2VecPlugin::getHelp() const
return "Plugin(Scal2Vec) converts the scalar fields into a vectorial field. " return "Plugin(Scal2Vec) converts the scalar fields into a vectorial field. "
"The new view 'NameNewView' contains it. " "The new view 'NameNewView' contains it. "
"If the number of a view is -1, the value of the corresponding " "If the number of a view is -1, the value of the corresponding "
"component of the vector field is 0." "component of the vector field is 0.";
"\n\n"
"DEPRECATE: Use plugin 'Scal2Tens' instead.'";
} }
int GMSH_Scal2VecPlugin::getNbOptions() const int GMSH_Scal2VecPlugin::getNbOptions() const
...@@ -61,7 +59,6 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v) ...@@ -61,7 +59,6 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v)
int iViewX = (int)Scal2VecOptions_Number[0].def; int iViewX = (int)Scal2VecOptions_Number[0].def;
int iViewY = (int)Scal2VecOptions_Number[1].def; int iViewY = (int)Scal2VecOptions_Number[1].def;
int iViewZ = (int)Scal2VecOptions_Number[2].def; int iViewZ = (int)Scal2VecOptions_Number[2].def;
std::string nameNewView = Scal2VecOptions_String[0].def;
// Load data // Load data
PView *vRef = 0, *vX = 0, *vY = 0, *vZ = 0; PView *vRef = 0, *vX = 0, *vY = 0, *vZ = 0;
...@@ -100,29 +97,30 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v) ...@@ -100,29 +97,30 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v)
PViewDataList *dataNew = getDataList(vNew); PViewDataList *dataNew = getDataList(vNew);
int step0 = dataRef->getFirstNonEmptyTimeStep(); int step0 = dataRef->getFirstNonEmptyTimeStep();
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 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(numComp, 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], valX, valY, valZ;
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);
elementFactory factory; elementFactory factory;
element *element = factory.create(numNodes, dim, x, y, z); element *element = factory.create(numNodes, dim, x, y, z);
if(!element) continue; if (!element) continue;
for(int nod = 0; nod < numNodes; nod++) out->push_back(x[nod]); // Save coordinates (x,y,z) for (int nod=0; nod<numNodes; nod++) out->push_back(x[nod]); // Save coordinates (x,y,z)
for(int nod = 0; nod < numNodes; nod++) out->push_back(y[nod]); for (int nod=0; nod<numNodes; nod++) out->push_back(y[nod]);
for(int nod = 0; nod < numNodes; nod++) out->push_back(z[nod]); for (int nod=0; nod<numNodes; nod++) out->push_back(z[nod]);
for(int step = step0; step < dataRef->getNumTimeSteps(); step++){ for (int step=step0; step < dataRef->getNumTimeSteps(); step++) {
for(int nod = 0; nod < numNodes; nod++){ if (!dataRef->hasTimeStep(step)) continue;
if(vX) vX->getData()->getValue(step, ent, ele, nod, 0, valX); else valX = 0; for (int nod=0; nod<numNodes; nod++) {
if(vY) vY->getData()->getValue(step, ent, ele, nod, 0, valY); else valY = 0; if (vX) vX->getData()->getValue(step, ent, ele, nod, 0, valX); else valX = 0;
if(vZ) vZ->getData()->getValue(step, ent, ele, nod, 0, valZ); else valZ = 0; if (vY) vY->getData()->getValue(step, ent, ele, nod, 0, valY); else valY = 0;
if (vZ) vZ->getData()->getValue(step, ent, ele, nod, 0, valZ); else valZ = 0;
out->push_back(valX); // Save values (fx,fy,fz) out->push_back(valX); // Save values (fx,fy,fz)
out->push_back(valY); out->push_back(valY);
out->push_back(valZ); out->push_back(valZ);
...@@ -132,13 +130,12 @@ PView *GMSH_Scal2VecPlugin::execute(PView *v) ...@@ -132,13 +130,12 @@ 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)){ if (!dataRef->hasTimeStep(step)) continue;
double time = dataRef->getTime(step); dataNew->Time.push_back(dataRef->getTime(step));
dataNew->Time.push_back(time);
}
} }
std::string nameNewView = Scal2VecOptions_String[0].def;
dataNew->setName(nameNewView); dataNew->setName(nameNewView);
dataNew->setFileName(nameNewView + ".pos"); dataNew->setFileName(nameNewView + ".pos");
dataNew->finalize(); dataNew->finalize();
......
...@@ -20,7 +20,7 @@ class GMSH_Scal2VecPlugin : public GMSH_PostPlugin ...@@ -20,7 +20,7 @@ class GMSH_Scal2VecPlugin : public GMSH_PostPlugin
std::string getName() const { return "Scal2Vec"; } std::string getName() const { return "Scal2Vec"; }
std::string getShortHelp() const std::string getShortHelp() const
{ {
return "Convert some scalar fields into a vector field [DEPRECATE]"; return "Convert some scalar fields into a vector field";
} }
std::string getHelp() const; std::string getHelp() const;
int getNbOptions() const; int getNbOptions() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment