File: GaussPoints.cpp

package info (click to toggle)
gmsh 4.8.4%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 87,812 kB
  • sloc: cpp: 378,014; ansic: 99,669; yacc: 7,216; python: 6,680; java: 3,486; lisp: 659; lex: 621; perl: 571; makefile: 470; sh: 440; xml: 415; javascript: 113; pascal: 35; modula3: 32
file content (92 lines) | stat: -rw-r--r-- 2,532 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Gmsh - Copyright (C) 1997-2021 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/gmsh/gmsh/issues.

#include "GaussPoints.h"
#include "GModel.h"
#include "MElement.h"
#include "PView.h"

StringXNumber GaussPointsOptions_Number[] = {
  {GMSH_FULLRC, "Order", nullptr, 0},
  {GMSH_FULLRC, "Dimension", nullptr, 2},
  {GMSH_FULLRC, "PhysicalGroup", nullptr, 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 list-based 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(std::size_t i = 0; i < entities.size(); i++) {
    for(std::size_t 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;
}