gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
8 #include "GmshConfig.h"
21 {
GMSH_FULLRC,
"Expression0",
nullptr,
"v0 * Sin(x)"},
40 return "Plugin(ModifyComponents) modifies the components of "
41 "the `TimeStep'-th time step in the view `View', using the "
42 "expressions provided in `Expression0', ..., `Expression8'. "
43 "If an expression is empty, the corresponding component in "
44 "the view is not modified.\n\n"
45 "The expressions can contain:\n\n"
46 "- the usual mathematical functions (Log, Sqrt, "
47 "Sin, Cos, Fabs, ...) and operators (+, -, *, /, ^);\n\n"
48 "- the symbols x, y and z, to retrieve the "
49 "coordinates of the current node;\n\n"
50 "- the symbols Time and TimeStep, to retrieve the "
51 "current time and time step values;\n\n"
52 "- the symbols v0, v1, v2, ..., v8, to retrieve each "
53 "component of the field in `View' at the "
54 "`TimeStep'-th time step;\n\n"
55 "- the symbols w0, w1, w2, ..., w8, to retrieve each "
56 "component of the field in `OtherView' at the "
57 "`OtherTimeStep'-th time step. If `OtherView' "
58 "and `View' are based on different spatial grids, "
59 "or if their data types are different, `OtherView' "
60 "is interpolated onto `View'.\n\n"
61 "If `TimeStep' < 0, the plugin automatically loops "
62 "over all the time steps in `View' and evaluates "
63 "the expressions for each one.\n\n"
64 "If `OtherTimeStep' < 0, the plugin uses `TimeStep' "
66 "If `View' < 0, the plugin is run on the current view.\n\n"
67 "If `OtherView' < 0, the plugin uses `View' instead.\n\n"
68 "Plugin(ModifyComponents) is executed in-place.";
105 Msg::Error(
"Invalid time step (%d) in View[%d]: using step 0 instead",
116 Msg::Error(
"View[%d] does not exist: using self", otherView);
121 if(otherTimeStep < 0 &&
123 Msg::Error(
"Number of time steps don't match: using step 0");
127 Msg::Error(
"Invalid time step (%d) in View[%d]: using step 0 instead",
132 std::vector<std::string> expressions(9), expressions0(9);
133 for(
int i = 0; i < 9; i++) {
135 if(expressions[i].size())
136 expressions0[i] = expressions[i];
138 expressions0[i] =
"0.";
141 const char *names[] = {
"x",
"y",
"z",
"Time",
"TimeStep",
"v0",
"v1",
"v2",
142 "v3",
"v4",
"v5",
"v6",
"v7",
"v8",
"w0",
"w1",
143 "w2",
"w3",
"w4",
"w5",
"w6",
"w7",
"w8"};
144 std::size_t numVariables =
sizeof(names) /
sizeof(names[0]);
145 std::vector<std::string> variables(numVariables);
146 for(std::size_t i = 0; i < numVariables; i++) variables[i] = names[i];
149 std::vector<double> values(numVariables), res(9);
152 if(forceInterpolation ||
155 Msg::Info(
"Other view based on different grid: interpolating...");
160 if(timeStep >= 0 && timeStep != step)
continue;
162 double time = data1->
getTime(step);
163 int step2 = (otherTimeStep < 0) ? step : otherTimeStep;
170 for(
int nod = 0; nod < data1->
getNumNodes(step, ent, ele); nod++)
171 data1->
tagNode(step, ent, ele, nod, 0);
182 std::vector<double> x(numNodes), y(numNodes),
z(numNodes);
183 std::vector<int> tag(numNodes);
184 for(
int nod = 0; nod < numNodes; nod++)
186 data1->
getNode(step, ent, ele, nod, x[nod], y[nod],
z[nod]);
187 for(
int nod = 0; nod < numNodes; nod++) {
190 std::vector<double> v(std::max(9, numComp), 0.);
191 for(
int comp = 0; comp < numComp; comp++)
192 data1->
getValue(step, ent, ele, nod, comp, v[comp]);
193 std::vector<double> w(std::max(9, numComp2), 0.);
195 int qn = forceInterpolation ? numNodes : 0;
196 if(!octree->
searchScalar(x[nod], y[nod],
z[nod], &w[0], step2,
197 nullptr, qn, &x[0], &y[0], &
z[0]))
198 if(!octree->
searchVector(x[nod], y[nod],
z[nod], &w[0], step2,
199 nullptr, qn, &x[0], &y[0], &
z[0]))
201 nullptr, qn, &x[0], &y[0], &
z[0]);
204 for(
int comp = 0; comp < numComp2; comp++)
205 data2->
getValue(step2, ent, ele, nod, comp, w[comp]);
212 for(
int i = 0; i < 9; i++) values[5 + i] = v[i];
213 for(
int i = 0; i < 9; i++) values[14 + i] = w[i];
214 if(
f.eval(values, res)) {
215 for(
int comp = 0; comp < numComp; comp++) {
216 if(expressions[comp].size()) {
217 data1->
setValue(step, ent, ele, nod, comp, res[comp]);
227 if(octree)
delete octree;
int getNbOptionsStr() const
StringXNumber ModifyComponentsOptions_Number[]
bool searchScalar(double x, double y, double z, double *values, int step=-1, double *size=nullptr, int qn=0, double *qx=nullptr, double *qy=nullptr, double *qz=nullptr, bool grad=false, int dim=-1)
virtual bool skipElement(int step, int ent, int ele, bool checkVisibility=false, int samplingRate=1)
static void Info(const char *fmt,...)
virtual int getNumTimeSteps()=0
virtual void setValue(int step, int ent, int ele, int nod, int comp, double val)
virtual bool isNodeData()
std::string getHelp() const
virtual int getNode(int step, int ent, int ele, int nod, double &x, double &y, double &z)
static void Error(const char *fmt,...)
void f(int n, double u, double *val)
virtual void getValue(int step, int ent, int ele, int idx, double &val)
GMSH_Plugin * GMSH_RegisterModifyComponentsPlugin()
virtual int getNumEntities(int step=-1)
void setChanged(bool val)
virtual double getTime(int step)
virtual void tagNode(int step, int ent, int ele, int nod, int tag)
PViewData * getData(bool useAdaptiveIfAvailable=false)
virtual int getNumNodes(int step, int ent, int ele)
virtual int getNumComponents(int step, int ent, int ele)
StringXNumber * getOption(int iopt)
bool searchVector(double x, double y, double z, double *values, int step=-1, double *size=nullptr, int qn=0, double *qx=nullptr, double *qy=nullptr, double *qz=nullptr, bool grad=false, int dim=-1)
virtual PView * getView(int index, PView *view)
virtual PViewData * getPossiblyAdaptiveData(PView *view)
StringXString * getOptionStr(int iopt)
virtual int getNumElements(int step=-1, int ent=-1)
StringXString ModifyComponentsOptions_String[]
static std::vector< PView * > list
virtual bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="")
bool searchTensor(double x, double y, double z, double *values, int step=-1, double *size=nullptr, int qn=0, double *qx=nullptr, double *qy=nullptr, double *qz=nullptr, bool grad=false, int dim=-1)