gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
Eigenvalues.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 "Eigenvalues.h"
7 #include "Numeric.h"
8 #include "GmshDefines.h"
9 
11  {GMSH_FULLRC, "View", nullptr, -1.}};
12 
13 extern "C" {
15 {
16  return new GMSH_EigenvaluesPlugin();
17 }
18 }
19 
21 {
22  return "Plugin(Eigenvalues) computes the three real "
23  "eigenvalues of each tensor in the view `View'.\n\n"
24  "If `View' < 0, the plugin is run on the current view.\n\n"
25  "Plugin(Eigenvalues) creates three new list-based scalar views.";
26 }
27 
29 {
30  return sizeof(EigenvaluesOptions_Number) / sizeof(StringXNumber);
31 }
32 
34 {
35  return &EigenvaluesOptions_Number[iopt];
36 }
37 
39 {
40  int iView = (int)EigenvaluesOptions_Number[0].def;
41 
42  PView *v1 = getView(iView, v);
43  if(!v1) return v;
44 
46  if(data1->hasMultipleMeshes()) {
47  Msg::Error("Eigenvalues plugin cannot be run on multi-mesh views");
48  return v;
49  }
50 
51  PView *min = new PView();
52  PView *mid = new PView();
53  PView *max = new PView();
54 
55  PViewDataList *dmin = getDataList(min);
56  PViewDataList *dmid = getDataList(mid);
57  PViewDataList *dmax = getDataList(max);
58 
59  for(int ent = 0; ent < data1->getNumEntities(0); ent++) {
60  for(int ele = 0; ele < data1->getNumElements(0, ent); ele++) {
61  if(data1->skipElement(0, ent, ele)) continue;
62  int numComp = data1->getNumComponents(0, ent, ele);
63  if(numComp != 9) continue;
64  int type = data1->getType(0, ent, ele);
65  int numNodes = data1->getNumNodes(0, ent, ele);
66  std::vector<double> *outmin = dmin->incrementList(1, type, numNodes);
67  std::vector<double> *outmid = dmid->incrementList(1, type, numNodes);
68  std::vector<double> *outmax = dmax->incrementList(1, type, numNodes);
69  if(!outmin || !outmid || !outmax) continue;
70  double xyz[3][8];
71  for(int nod = 0; nod < numNodes; nod++)
72  data1->getNode(0, ent, ele, nod, xyz[0][nod], xyz[1][nod], xyz[2][nod]);
73  for(int i = 0; i < 3; i++) {
74  for(int nod = 0; nod < numNodes; nod++) {
75  outmin->push_back(xyz[i][nod]);
76  outmid->push_back(xyz[i][nod]);
77  outmax->push_back(xyz[i][nod]);
78  }
79  }
80  for(int step = 0; step < data1->getNumTimeSteps(); step++) {
81  for(int nod = 0; nod < numNodes; nod++) {
82  double val[9], w[3];
83  for(int comp = 0; comp < numComp; comp++)
84  data1->getValue(step, ent, ele, nod, comp, val[comp]);
85  double A[3][3] = {{val[0], val[1], val[2]},
86  {val[3], val[4], val[5]},
87  {val[6], val[7], val[8]}};
88  eigenvalue(A, w);
89  outmin->push_back(w[2]);
90  outmid->push_back(w[1]);
91  outmax->push_back(w[0]);
92  }
93  }
94  }
95  }
96 
97  for(int i = 0; i < data1->getNumTimeSteps(); i++) {
98  double time = data1->getTime(i);
99  dmin->Time.push_back(time);
100  dmid->Time.push_back(time);
101  dmax->Time.push_back(time);
102  }
103  dmin->setName(data1->getName() + "_MinEigenvalues");
104  dmin->setFileName(data1->getName() + "_MinEigenvalues.pos");
105  dmin->finalize();
106  dmid->setName(data1->getName() + "_MidEigenvalues");
107  dmid->setFileName(data1->getName() + "_MidEigenvalues.pos");
108  dmid->finalize();
109  dmax->setName(data1->getName() + "_MaxEigenvalues");
110  dmax->setFileName(data1->getName() + "_MaxEigenvalues.pos");
111  dmax->finalize();
112 
113  return nullptr;
114 }
GMSH_EigenvaluesPlugin::getHelp
std::string getHelp() const
Definition: Eigenvalues.cpp:20
PView
Definition: PView.h:27
PViewData::skipElement
virtual bool skipElement(int step, int ent, int ele, bool checkVisibility=false, int samplingRate=1)
Definition: PViewData.cpp:90
GMSH_Plugin
Definition: Plugin.h:26
PViewData::getNumTimeSteps
virtual int getNumTimeSteps()=0
PViewDataList
Definition: PViewDataList.h:17
PViewData::getNode
virtual int getNode(int step, int ent, int ele, int nod, double &x, double &y, double &z)
Definition: PViewData.h:141
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
PViewDataList::incrementList
std::vector< double > * incrementList(int numComp, int type, int numNodes=0)
Definition: PViewDataList.cpp:1243
StringXNumber
Definition: Options.h:918
PViewData::getValue
virtual void getValue(int step, int ent, int ele, int idx, double &val)
Definition: PViewData.h:159
GMSH_EigenvaluesPlugin::execute
PView * execute(PView *)
Definition: Eigenvalues.cpp:38
Eigenvalues.h
PViewData::hasMultipleMeshes
virtual bool hasMultipleMeshes()
Definition: PViewData.h:216
PViewData::getNumEntities
virtual int getNumEntities(int step=-1)
Definition: PViewData.h:127
PViewData::setFileName
virtual void setFileName(const std::string &val)
Definition: PViewData.h:75
GMSH_EigenvaluesPlugin::getNbOptions
int getNbOptions() const
Definition: Eigenvalues.cpp:28
PViewData::getTime
virtual double getTime(int step)
Definition: PViewData.h:94
PViewData::getType
virtual int getType(int step, int ent, int ele)
Definition: PViewData.h:183
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
Numeric.h
PViewData::getNumNodes
virtual int getNumNodes(int step, int ent, int ele)
Definition: PViewData.h:137
GmshDefines.h
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
GMSH_EigenvaluesPlugin
Definition: Eigenvalues.h:15
PViewData
Definition: PViewData.h:29
GMSH_RegisterEigenvaluesPlugin
GMSH_Plugin * GMSH_RegisterEigenvaluesPlugin()
Definition: Eigenvalues.cpp:14
PViewData::getNumComponents
virtual int getNumComponents(int step, int ent, int ele)
Definition: PViewData.h:152
GMSH_PostPlugin::getView
virtual PView * getView(int index, PView *view)
Definition: Plugin.cpp:81
GMSH_PostPlugin::getPossiblyAdaptiveData
virtual PViewData * getPossiblyAdaptiveData(PView *view)
Definition: Plugin.cpp:94
PViewDataList::Time
std::vector< double > Time
Definition: PViewDataList.h:25
eigenvalue
void eigenvalue(double mat[3][3], double v[3])
Definition: Numeric.cpp:550
PViewData::getNumElements
virtual int getNumElements(int step=-1, int ent=-1)
Definition: PViewData.h:131
PViewData::getName
virtual std::string getName()
Definition: PViewData.h:70
EigenvaluesOptions_Number
StringXNumber EigenvaluesOptions_Number[]
Definition: Eigenvalues.cpp:10
GMSH_EigenvaluesPlugin::getOption
StringXNumber * getOption(int iopt)
Definition: Eigenvalues.cpp:33
GMSH_PostPlugin::getDataList
virtual PViewDataList * getDataList(PView *view, bool showError=true)
Definition: Plugin.cpp:107