gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GaussPoints.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "GaussPoints.h"
7 #include "GModel.h"
8 #include "MElement.h"
9 #include "PView.h"
10 
12  {GMSH_FULLRC, "Order", nullptr, 0},
13  {GMSH_FULLRC, "Dimension", nullptr, 2},
14  {GMSH_FULLRC, "PhysicalGroup", nullptr, 0}};
15 
16 extern "C" {
18 {
19  return new GMSH_GaussPointsPlugin();
20 }
21 }
22 
24 {
25  return sizeof(GaussPointsOptions_Number) / sizeof(StringXNumber);
26 }
27 
29 {
30  return &GaussPointsOptions_Number[iopt];
31 }
32 
34 {
35  return "Given an input mesh, Plugin(GaussPoints) creates a list-based view "
36  "containing the Gauss points for a given polynomial `Order'.\n\n"
37  "If `PhysicalGroup' is nonzero, the plugin only creates points for "
38  "the elements belonging to the group.";
39 }
40 
42 {
43  int order = (int)GaussPointsOptions_Number[0].def;
44  int dim = (int)GaussPointsOptions_Number[1].def;
45  int physical = (int)GaussPointsOptions_Number[2].def;
46 
47  GModel *m = GModel::current();
48  std::vector<GEntity *> entities;
49  if(physical) {
50  std::map<int, std::vector<GEntity *> > groups[4];
51  m->getPhysicalGroups(groups);
52  entities = groups[dim][physical];
53  }
54  else {
55  m->getEntities(entities, dim);
56  }
57 
58  if(entities.empty()) {
59  Msg::Error("No entities");
60  return v;
61  }
62 
63  PView *v2 = new PView();
64  PViewDataList *data2 = getDataList(v2);
65  for(std::size_t i = 0; i < entities.size(); i++) {
66  for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++) {
67  MElement *e = entities[i]->getMeshElement(j);
68  int npts;
69  IntPt *gp;
70  e->getIntegrationPoints(order, &npts, &gp);
71  for(int i = 0; i < npts; i++) {
72  double u = gp[i].pt[0];
73  double v = gp[i].pt[1];
74  double w = gp[i].pt[2];
75  // double weight = gp[i].weight;
76  SPoint3 p;
77  e->pnt(u, v, w, p);
78  data2->SP.push_back(p.x());
79  data2->SP.push_back(p.y());
80  data2->SP.push_back(p.z());
81  data2->SP.push_back(e->getNum());
82  data2->NbSP++;
83  }
84  }
85  }
86 
87  data2->setName("GaussPoints");
88  data2->setFileName("GaussPoints.pos");
89  data2->finalize();
90 
91  return v;
92 }
MElement::getNum
virtual std::size_t getNum() const
Definition: MElement.h:68
PView
Definition: PView.h:27
GaussPointsOptions_Number
StringXNumber GaussPointsOptions_Number[]
Definition: GaussPoints.cpp:11
GMSH_Plugin
Definition: Plugin.h:26
MElement::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MElement.h:436
PViewDataList
Definition: PViewDataList.h:17
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
PViewDataList::NbSP
int NbSP
Definition: PViewDataList.h:26
SPoint3
Definition: SPoint3.h:14
StringXNumber
Definition: Options.h:918
GMSH_GaussPointsPlugin::getOption
StringXNumber * getOption(int iopt)
Definition: GaussPoints.cpp:28
PView.h
IntPt::pt
double pt[3]
Definition: GaussIntegration.h:13
PViewData::setFileName
virtual void setFileName(const std::string &val)
Definition: PViewData.h:75
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
GModel::getPhysicalGroups
void getPhysicalGroups(std::map< int, std::vector< GEntity * > > groups[4]) const
Definition: GModel.cpp:837
GMSH_GaussPointsPlugin::getNbOptions
int getNbOptions() const
Definition: GaussPoints.cpp:23
GMSH_GaussPointsPlugin
Definition: GaussPoints.h:15
PViewDataList::SP
std::vector< double > SP
Definition: PViewDataList.h:27
GaussPoints.h
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
GModel
Definition: GModel.h:44
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
PViewDataList::finalize
bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="")
Definition: PViewDataList.cpp:81
PViewData::setName
virtual void setName(const std::string &val)
Definition: PViewData.h:71
MElement
Definition: MElement.h:30
GMSH_RegisterGaussPointsPlugin
GMSH_Plugin * GMSH_RegisterGaussPointsPlugin()
Definition: GaussPoints.cpp:17
GMSH_GaussPointsPlugin::execute
PView * execute(PView *)
Definition: GaussPoints.cpp:41
GModel::getEntities
void getEntities(std::vector< GEntity * > &entities, int dim=-1) const
Definition: GModel.cpp:651
MElement::pnt
virtual void pnt(double u, double v, double w, SPoint3 &p) const
Definition: MElement.cpp:1072
IntPt
Definition: GaussIntegration.h:12
MElement.h
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
GModel.h
GMSH_GaussPointsPlugin::getHelp
std::string getHelp() const
Definition: GaussPoints.cpp:33
GModel::current
static GModel * current(int index=-1)
Definition: GModel.cpp:136
GMSH_PostPlugin::getDataList
virtual PViewDataList * getDataList(PView *view, bool showError=true)
Definition: Plugin.cpp:107