gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
SphericalRaise.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 "SphericalRaise.h"
7 #include "Numeric.h"
8 
10  {GMSH_FULLRC, "Xc", nullptr, 0.}, {GMSH_FULLRC, "Yc", nullptr, 0.},
11  {GMSH_FULLRC, "Zc", nullptr, 0.}, {GMSH_FULLRC, "Raise", nullptr, 1.},
12  {GMSH_FULLRC, "Offset", nullptr, 0.}, {GMSH_FULLRC, "TimeStep", nullptr, 0.},
13  {GMSH_FULLRC, "View", nullptr, -1.}};
14 
15 extern "C" {
17 {
18  return new GMSH_SphericalRaisePlugin();
19 }
20 }
21 
23 {
24  return "Plugin(SphericalRaise) transforms the "
25  "coordinates of the elements in the view "
26  "`View' using the values associated with the "
27  "`TimeStep'-th time step.\n\n"
28  "Instead of elevating the nodes along the X, Y "
29  "and Z axes as with the View[`View'].RaiseX, "
30  "View[`View'].RaiseY and View[`View'].RaiseZ "
31  "options, the raise is applied along the radius "
32  "of a sphere centered at (`Xc', `Yc', `Zc').\n\n"
33  "To produce a standard radiation pattern, set "
34  "`Offset' to minus the radius of the sphere the "
35  "original data lives on.\n\n"
36  "If `View' < 0, the plugin is run on the current view.\n\n"
37  "Plugin(SphericalRaise) is executed in-place.";
38 }
39 
41 {
42  return sizeof(SphericalRaiseOptions_Number) / sizeof(StringXNumber);
43 }
44 
46 {
47  return &SphericalRaiseOptions_Number[iopt];
48 }
49 
51 {
52  double center[3];
53  center[0] = SphericalRaiseOptions_Number[0].def;
54  center[1] = SphericalRaiseOptions_Number[1].def;
55  center[2] = SphericalRaiseOptions_Number[2].def;
56  double raise = SphericalRaiseOptions_Number[3].def;
57  double offset = SphericalRaiseOptions_Number[4].def;
58  int timeStep = (int)SphericalRaiseOptions_Number[5].def;
59  int iView = (int)SphericalRaiseOptions_Number[6].def;
60 
61  PView *v1 = getView(iView, v);
62  if(!v1) return v;
63 
64  PViewData *data1 = v1->getData();
65 
66  // sanity checks
67  if(timeStep < 0 || timeStep > data1->getNumTimeSteps() - 1) {
68  Msg::Error("Invalid TimeStep (%d) in view", timeStep);
69  return v;
70  }
71 
72  if(data1->isNodeData()) {
73  // tag all the nodes with "0" (the default tag)
74  for(int step = 0; step < data1->getNumTimeSteps(); step++) {
75  for(int ent = 0; ent < data1->getNumEntities(step); ent++) {
76  for(int ele = 0; ele < data1->getNumElements(step, ent); ele++) {
77  if(data1->skipElement(step, ent, ele)) continue;
78  for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++)
79  data1->tagNode(step, ent, ele, nod, 0);
80  }
81  }
82  }
83  }
84 
85  // transform all "0" nodes
86  for(int step = 0; step < data1->getNumTimeSteps(); step++) {
87  for(int ent = 0; ent < data1->getNumEntities(step); ent++) {
88  for(int ele = 0; ele < data1->getNumElements(step, ent); ele++) {
89  if(data1->skipElement(step, ent, ele)) continue;
90  for(int nod = 0; nod < data1->getNumNodes(step, ent, ele); nod++) {
91  double x, y, z;
92  int tag = data1->getNode(step, ent, ele, nod, x, y, z);
93  if(data1->isNodeData() && tag) continue;
94  double r[3], val;
95  r[0] = x - center[0];
96  r[1] = y - center[1];
97  r[2] = z - center[2];
98  norme(r);
99  data1->getScalarValue(step, ent, ele, nod, val);
100  double coef = offset + raise * val;
101  x += coef * r[0];
102  y += coef * r[1];
103  z += coef * r[2];
104  data1->setNode(step, ent, ele, nod, x, y, z);
105  if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
106  }
107  }
108  }
109  }
110 
111  data1->finalize();
112  v1->setChanged(true);
113 
114  return v1;
115 }
PView
Definition: PView.h:27
GMSH_SphericalRaisePlugin
Definition: SphericalRaise.h:15
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
GMSH_SphericalRaisePlugin::getHelp
std::string getHelp() const
Definition: SphericalRaise.cpp:22
StringXNumber::def
double def
Definition: Options.h:922
PViewData::getNumTimeSteps
virtual int getNumTimeSteps()=0
PViewData::isNodeData
virtual bool isNodeData()
Definition: PViewData.h:218
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
StringXNumber
Definition: Options.h:918
PViewData::setNode
virtual void setNode(int step, int ent, int ele, int nod, double x, double y, double z)
Definition: PViewData.cpp:124
PViewData::getNumEntities
virtual int getNumEntities(int step=-1)
Definition: PViewData.h:127
PView::setChanged
void setChanged(bool val)
Definition: PView.cpp:241
PViewData::tagNode
virtual void tagNode(int step, int ent, int ele, int nod, int tag)
Definition: PViewData.h:148
PViewData::getScalarValue
void getScalarValue(int step, int ent, int ele, int nod, double &val, int tensorRep=0, int forceNumComponents=0, int componentMap[9]=nullptr)
Definition: PViewData.cpp:97
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
Numeric.h
SphericalRaiseOptions_Number
StringXNumber SphericalRaiseOptions_Number[]
Definition: SphericalRaise.cpp:9
PView::getData
PViewData * getData(bool useAdaptiveIfAvailable=false)
Definition: PView.cpp:233
PViewData::getNumNodes
virtual int getNumNodes(int step, int ent, int ele)
Definition: PViewData.h:137
GMSH_RegisterSphericalRaisePlugin
GMSH_Plugin * GMSH_RegisterSphericalRaisePlugin()
Definition: SphericalRaise.cpp:16
PViewData
Definition: PViewData.h:29
SphericalRaise.h
z
const double z
Definition: GaussQuadratureQuad.cpp:56
GMSH_SphericalRaisePlugin::getNbOptions
int getNbOptions() const
Definition: SphericalRaise.cpp:40
GMSH_PostPlugin::getView
virtual PView * getView(int index, PView *view)
Definition: Plugin.cpp:81
PViewData::getNumElements
virtual int getNumElements(int step=-1, int ent=-1)
Definition: PViewData.h:131
norme
double norme(double a[3])
Definition: Numeric.h:123
GMSH_SphericalRaisePlugin::execute
PView * execute(PView *)
Definition: SphericalRaise.cpp:50
PViewData::finalize
virtual bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="")
Definition: PViewData.cpp:30
GMSH_SphericalRaisePlugin::getOption
StringXNumber * getOption(int iopt)
Definition: SphericalRaise.cpp:45