Skip to content
Snippets Groups Projects
Commit 175141b1 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 2aba81e3
No related branches found
No related tags found
No related merge requests found
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
set(SRC set(SRC
Plugin.cpp PluginManager.cpp Plugin.cpp PluginManager.cpp
Levelset.cpp Levelset.cpp
CutPlane.cpp CutSphere.cpp Isosurface.cpp CutPlane.cpp CutSphere.cpp Isosurface.cpp
Smooth.cpp CutParametric.cpp Smooth.cpp CutParametric.cpp
Lambda2.cpp Lambda2.cpp
Eigenvectors.cpp Eigenvalues.cpp Eigenvectors.cpp Eigenvalues.cpp
StreamLines.cpp Particles.cpp CutGrid.cpp CutBox.cpp StreamLines.cpp Particles.cpp CutGrid.cpp CutBox.cpp
Transform.cpp Transform.cpp
LongitudeLatitude.cpp LongitudeLatitude.cpp
Triangulate.cpp Tetrahedralize.cpp Triangulate.cpp Tetrahedralize.cpp
Warp.cpp SphericalRaise.cpp Warp.cpp SphericalRaise.cpp
Skin.cpp Skin.cpp
...@@ -29,7 +29,7 @@ set(SRC ...@@ -29,7 +29,7 @@ set(SRC
FieldFromAmplitudePhase.cpp FieldFromAmplitudePhase.cpp
Bubbles.cpp NearToFarField.cpp Bubbles.cpp NearToFarField.cpp
DiscretizationError.cpp DiscretizationError.cpp
Scal2Vec.cpp Scal2Tens.cpp Scal2Vec.cpp
CutMesh.cpp CutMesh.cpp
NewView.cpp NewView.cpp
SimplePartition.cpp Crack.cpp SimplePartition.cpp Crack.cpp
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "Bubbles.h" #include "Bubbles.h"
#include "NearToFarField.h" #include "NearToFarField.h"
#include "DiscretizationError.h" #include "DiscretizationError.h"
#include "Scal2Tens.h"
#include "Scal2Vec.h" #include "Scal2Vec.h"
#include "CutMesh.h" #include "CutMesh.h"
#include "NewView.h" #include "NewView.h"
...@@ -245,7 +246,7 @@ void PluginManager::registerDefaultPlugins() ...@@ -245,7 +246,7 @@ void PluginManager::registerDefaultPlugins()
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin())); ("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("Scal2Vec", GMSH_RegisterScal2VecPlugin())); ("Scal2Tens", GMSH_RegisterScal2TensPlugin()));
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*>
......
// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#include "Scal2Tens.h"
#include "PViewOptions.h"
#include "shapeFunctions.h"
StringXNumber Scal2TensOptions_Number[] = {
{GMSH_FULLRC, "NumberOfComponents", NULL, 3.},
{GMSH_FULLRC, "Comp0", NULL, -1.},
{GMSH_FULLRC, "Comp1", NULL, -1.},
{GMSH_FULLRC, "Comp2", NULL, -1.},
{GMSH_FULLRC, "Comp3", NULL, -1.},
{GMSH_FULLRC, "Comp4", NULL, -1.},
{GMSH_FULLRC, "Comp5", NULL, -1.},
{GMSH_FULLRC, "Comp6", NULL, -1.},
{GMSH_FULLRC, "Comp7", NULL, -1.},
{GMSH_FULLRC, "Comp8", NULL, -1.}
};
StringXString Scal2TensOptions_String[] = {
{GMSH_FULLRC, "NameNewView", NULL, "NewView"}
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterScal2TensPlugin()
{
return new GMSH_Scal2TensPlugin();
}
}
std::string GMSH_Scal2TensPlugin::getHelp() const
{
return "Plugin(Scal2Tens) converts some scalar fields into a field "
"with several components. The number of components must be given (max. 9). "
"The new view 'NameNewView' contains the new field. If the number "
"of a view is -1, the value of the corresponding component is 0.";
}
int GMSH_Scal2TensPlugin::getNbOptions() const
{
return sizeof(Scal2TensOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_Scal2TensPlugin::getOption(int iopt)
{
return &Scal2TensOptions_Number[iopt];
}
int GMSH_Scal2TensPlugin::getNbOptionsStr() const
{
return sizeof(Scal2TensOptions_String) / sizeof(StringXString);
}
StringXString *GMSH_Scal2TensPlugin::getOptionStr(int iopt)
{
return &Scal2TensOptions_String[iopt];
}
PView *GMSH_Scal2TensPlugin::execute(PView *v)
{
// Load options
int numComp = (int)Scal2TensOptions_Number[0].def;
if ((numComp<1) || (numComp>9)) {
Msg::Error("Scal2Tens plugin: NumberOfComponents must be between 1 and 9 (not '%i')", numComp);
return v;
}
int iView[9];
for (int comp=0; comp<numComp; comp++)
iView[comp] = (int)Scal2TensOptions_Number[comp+1].def;
// Load data
PView *vRef=0, *vComp[9];
for (int comp=0; comp<numComp; comp++) {
if (iView[comp]<0) vComp[comp] = 0;
else {
vComp[comp] = getView(iView[comp], v);
if (!vComp[comp]) {
Msg::Error("Scal2Tens plugin could not find View '%i'", iView[comp]);
return v;
}
if (!vRef) vRef = vComp[comp];
}
}
if (!vRef) {
Msg::Error("Scal2Tens plugin could not find any view.");
return v;
}
PViewData *dataRef = vRef->getData();
// Initialize the new view
PView *vNew = new PView();
PViewDataList *dataNew = getDataList(vNew);
int step0 = dataRef->getFirstNonEmptyTimeStep();
for (int ent=0; ent < dataRef->getNumEntities(step0); ent++) {
for (int ele=0; ele < dataRef->getNumElements(step0, ent); ele++) {
if (dataRef->skipElement(step0, ent, ele)) continue;
int type = dataRef->getType(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
if (!out) continue;
double x[8], y[8], z[8];
for (int nod=0; nod<numNodes; nod++)
dataRef->getNode(step0, ent, ele, nod, x[nod], y[nod], z[nod]);
int dim = dataRef->getDimension(step0, ent, ele);
elementFactory factory;
element *element = factory.create(numNodes, dim, x, y, z);
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(y[nod]);
for (int nod=0; nod<numNodes; nod++) out->push_back(z[nod]);
for (int step=step0; step < dataRef->getNumTimeSteps(); step++) {
if (!dataRef->hasTimeStep(step)) continue;
for (int nod=0; nod<numNodes; nod++) {
for (int comp=0; comp<numComp; comp++) {
double val=0.;
if(vComp[comp]) vComp[comp]->getData()->getValue(step, ent, ele, nod, 0, val);
out->push_back(val); // Save value
}
}
}
delete element;
}
}
for (int step=step0; step < dataRef->getNumTimeSteps(); step++) {
if (!dataRef->hasTimeStep(step)) continue;
dataNew->Time.push_back(dataRef->getTime(step));
}
std::string nameNewView = Scal2TensOptions_String[0].def;
dataNew->setName(nameNewView);
dataNew->setFileName(nameNewView + ".pos");
dataNew->finalize();
return vNew;
}
// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@geuz.org>.
#ifndef _SCAL2TENS_H_
#define _SCAL2TENS_H_
#include "Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterScal2TensPlugin();
}
class GMSH_Scal2TensPlugin : public GMSH_PostPlugin
{
public:
GMSH_Scal2TensPlugin(){}
std::string getName() const { return "Scal2Tens"; }
std::string getShortHelp() const
{
return "Convert some scalar fields into a tensor field with several components";
}
std::string getHelp() const;
int getNbOptions() const;
StringXNumber *getOption(int iopt);
int getNbOptionsStr() const;
StringXString* getOptionStr(int iopt);
PView *execute(PView *);
};
#endif
...@@ -27,11 +27,12 @@ extern "C" ...@@ -27,11 +27,12 @@ extern "C"
std::string GMSH_Scal2VecPlugin::getHelp() const std::string GMSH_Scal2VecPlugin::getHelp() const
{ {
return "Plugin(Scal2Vec) converts the scalar fields of 'ViewX', " return "Plugin(Scal2Vec) converts the scalar fields into a vectorial field. "
"'ViewY' and/or 'ViewZ' into a vectorial field. " "The new view 'NameNewView' contains it. "
"The new view 'NameNewView' contains it.\n\n" "If the number of a view is -1, the value of the corresponding "
"If the value of 'ViewX', 'ViewY' or 'ViewZ' is -1, " "component of the vector field is 0."
"the value of the vectorial field in the corresponding direction is 0."; "\n\n"
"DEPRECATE: Use plugin 'Scal2Tens' instead.'";
} }
int GMSH_Scal2VecPlugin::getNbOptions() const int GMSH_Scal2VecPlugin::getNbOptions() const
......
...@@ -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"; return "Convert some scalar fields into a vector field [DEPRECATE]";
} }
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