Skip to content
Snippets Groups Projects
Commit ba01e291 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

plugin to get gauss points

parent 980c1541
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ set(SRC ...@@ -37,6 +37,7 @@ set(SRC
MeshSubEntities.cpp MeshSubEntities.cpp
CVTRemesh.cpp CVTRemesh.cpp
ShowNeighborElements.cpp ShowNeighborElements.cpp
GaussPoints.cpp
) )
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
......
// Gmsh - Copyright (C) 1997-2016 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@onelab.info>.
#include "GaussPoints.h"
#include "GModel.h"
#include "MElement.h"
#include "PView.h"
StringXNumber GaussPointsOptions_Number[] = {
{GMSH_FULLRC, "Order", NULL, 0},
{GMSH_FULLRC, "Dimension", NULL, 2},
{GMSH_FULLRC, "PhysicalGroup", NULL, 0}
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterGaussPointsPlugin()
{
return new GMSH_GaussPointsPlugin();
}
}
int GMSH_GaussPointsPlugin::getNbOptions() const
{
return sizeof(GaussPointsOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_GaussPointsPlugin::getOption(int iopt)
{
return &GaussPointsOptions_Number[iopt];
}
std::string GMSH_GaussPointsPlugin::getHelp() const
{
return "Given an input mesh, Plugin(GaussPoints) creates a view containing "
"the Gauss points for a given polynomial `Order'.\n\n"
"If `PhysicalGroup' is nonzero, the plugin only creates points for the "
"elements belonging to the group.";
}
PView* GMSH_GaussPointsPlugin::execute(PView *v)
{
int order = (int)GaussPointsOptions_Number[0].def;
int dim = (int)GaussPointsOptions_Number[1].def;
int physical = (int)GaussPointsOptions_Number[2].def;
GModel *m = GModel::current();
std::vector<GEntity*> entities;
if(physical){
std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups);
entities = groups[dim][physical];
}
else{
m->getEntities(entities, dim);
}
if(entities.empty()){
Msg::Error("No entities");
return v;
}
PView *v2 = new PView();
PViewDataList *data2 = getDataList(v2);
for(unsigned int i = 0; i < entities.size(); i++){
for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){
MElement *e = entities[i]->getMeshElement(j);
int npts; IntPt *gp;
e->getIntegrationPoints(order, &npts, &gp);
for (int i = 0; i < npts; i++){
double u = gp[i].pt[0];
double v = gp[i].pt[1];
double w = gp[i].pt[2];
double weight = gp[i].weight;
SPoint3 p;
e->pnt(u, v, w, p);
data2->SP.push_back(p.x());
data2->SP.push_back(p.y());
data2->SP.push_back(p.z());
data2->SP.push_back(e->getNum());
data2->NbSP++;
}
}
}
data2->setName("GaussPoints");
data2->setFileName("GaussPoints.pos");
data2->finalize();
return v;
}
// Gmsh - Copyright (C) 1997-2016 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@onelab.info>.
#ifndef _GAUSS_POINTS_H_
#define _GAUSS_POINTS_H_
#include "Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterGaussPointsPlugin();
}
class GMSH_GaussPointsPlugin : public GMSH_PostPlugin
{
public:
GMSH_GaussPointsPlugin(){}
std::string getName() const { return "GaussPoints"; }
std::string getShortHelp() const
{
return "Gauss points";
}
std::string getHelp() const;
int getNbOptions() const;
StringXNumber* getOption(int iopt);
PView *execute(PView *);
};
#endif
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include "MeshSubEntities.h" #include "MeshSubEntities.h"
#include "CVTRemesh.h" #include "CVTRemesh.h"
#include "ShowNeighborElements.h" #include "ShowNeighborElements.h"
#include "GaussPoints.h"
// for testing purposes only :-) // for testing purposes only :-)
#undef HAVE_DLOPEN #undef HAVE_DLOPEN
...@@ -266,6 +267,8 @@ void PluginManager::registerDefaultPlugins() ...@@ -266,6 +267,8 @@ void PluginManager::registerDefaultPlugins()
("ShowNeighborElements", GMSH_RegisterShowNeighborElementsPlugin())); ("ShowNeighborElements", GMSH_RegisterShowNeighborElementsPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("MeshSubEntities", GMSH_RegisterMeshSubEntitiesPlugin())); ("MeshSubEntities", GMSH_RegisterMeshSubEntitiesPlugin()));
allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("GaussPoints", GMSH_RegisterGaussPointsPlugin()));
#if defined(HAVE_MESH) #if defined(HAVE_MESH)
allPlugins.insert(std::pair<std::string, GMSH_Plugin*> allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
("AnalyseCurvedMesh", GMSH_RegisterAnalyseCurvedMeshPlugin())); ("AnalyseCurvedMesh", GMSH_RegisterAnalyseCurvedMeshPlugin()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment