Skip to content
Snippets Groups Projects
Select Git revision
  • ec9ac174fd7cf9a554a1d7ed014dc9e943f9d071
  • master default protected
  • cyrielle
  • vinayak
  • ujwal_21_08_2024
  • dev_mm_torchSCRU
  • dev_mm_pf
  • debug_mm_pf
  • newStructureNonLocal
  • Mohamed_stochasticDMN
  • dev_mm_bench
  • stochdmn
  • revert-351ff7aa
  • ujwal_29April2024
  • dev_mm_ann
  • mohamed_vevp
  • ujwal_debug
  • ujwal_2ndApril2024
  • ujwal_October_2023
  • gabriel
  • SFEM
  • v4.0
  • v3.2.3_multiplePhase
  • v3.5
  • v3.3.2
  • v3.4
  • v3.3
  • ver3.2
  • verJulienWork
  • ver3.1
  • ver2
  • ver1.1.2
  • ver1.1.1
  • ver1.1
34 results

model.py

Blame
  • GaussPoints.cpp 2.46 KiB
    // Gmsh - Copyright (C) 1997-2019 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", 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(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;
    }