gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
NearToFarField.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 // Contributor(s):
7 // Ruth Sabariego
8 //
9 
10 #include <complex>
11 #include "NearToFarField.h"
12 #include "OS.h"
13 
15  {GMSH_FULLRC, "Wavenumber", nullptr, 1.},
16  {GMSH_FULLRC, "PhiStart", nullptr, 0.},
17  {GMSH_FULLRC, "PhiEnd", nullptr, 2. * M_PI},
18  {GMSH_FULLRC, "NumPointsPhi", nullptr, 60},
19  {GMSH_FULLRC, "ThetaStart", nullptr, 0.},
20  {GMSH_FULLRC, "ThetaEnd", nullptr, M_PI},
21  {GMSH_FULLRC, "NumPointsTheta", nullptr, 30},
22  {GMSH_FULLRC, "EView", nullptr, 0},
23  {GMSH_FULLRC, "HView", nullptr, 1},
24  {GMSH_FULLRC, "Normalize", nullptr, 1},
25  {GMSH_FULLRC, "dB", nullptr, 1},
26  {GMSH_FULLRC, "NegativeTime", nullptr, 0.},
27  {GMSH_FULLRC, "RFar", nullptr, 0},
28 };
29 
31  {GMSH_FULLRC, "MatlabOutputFile", nullptr, "farfield.m"},
32 };
33 
34 extern "C" {
36 {
37  return new GMSH_NearToFarFieldPlugin();
38 }
39 }
40 
42 {
43  return "Plugin(NearToFarField) computes the far field pattern "
44  "from the near electric E and magnetic H fields on a surface "
45  "enclosing the radiating device (antenna).\n\n"
46  "Parameters: the wavenumber, the "
47  "angular discretisation (phi in [0, 2*Pi] and theta in [0, Pi]) "
48  "of the far field sphere and the indices of the views containing the "
49  "complex-valued E and H fields. If `Normalize' is set, the far field "
50  "is normalized to 1. If `dB' is set, the far field is computed in dB. "
51  "If `NegativeTime' is set, E and H are assumed to have exp(-iwt) time "
52  "dependency; otherwise they are assume to have exp(+iwt) time "
53  "dependency. If `MatlabOutputFile' is given the raw far field data is "
54  "also exported in Matlab format.\n\n"
55  "Plugin(NearToFarField) creates one new view.";
56 }
57 
59 {
60  return sizeof(NearToFarFieldOptions_Number) / sizeof(StringXNumber);
61 }
62 
64 {
65  return sizeof(NearToFarFieldOptions_String) / sizeof(StringXString);
66 }
67 
69 {
70  return &NearToFarFieldOptions_Number[iopt];
71 }
72 
74 {
75  return &NearToFarFieldOptions_String[iopt];
76 }
77 
78 // Compute field using e^{j\omega t} time dependency, following Jin in "Finite
79 // Element Analysis of Antennas and Arrays", p. 176. This is not the usual `far
80 // field', as it still contains the e^{ikr}/r factor.
82  std::vector<element *> &allElems, std::vector<std::vector<double> > &js,
83  std::vector<std::vector<double> > &ms, double k0, double rFar, double theta,
84  double phi)
85 {
86  // theta in [0, pi] (elevation/polar angle)
87  // phi in [0, 2*pi] (azimuthal angle)
88 
89  double sTheta = sin(theta);
90  double cTheta = cos(theta);
91  double sPhi = sin(phi);
92  double cPhi = cos(phi);
93  double r[3] = {sTheta * cPhi, sTheta * sPhi, cTheta}; // Unit vector position
94 
95  double Z0 = 120 * M_PI; // free-space impedance
96 
97  int numComps = 3, numSteps = 2;
98  std::vector<std::vector<double> > N;
99  std::vector<std::vector<double> > Ns;
100  std::vector<std::vector<double> > L;
101  std::vector<std::vector<double> > Ls;
102 
103  N.resize(numSteps);
104  Ns.resize(numSteps);
105  L.resize(numSteps);
106  Ls.resize(numSteps);
107  for(int step = 0; step < numSteps; step++) {
108  N[step].resize(numComps, 0.);
109  Ns[step].resize(numComps);
110  L[step].resize(numComps, 0.);
111  Ls[step].resize(numComps);
112  }
113 
114  int i = 0;
115  for(std::size_t ele = 0; ele < allElems.size(); ele++) {
116  element *e = allElems[ele];
117  int numNodes = e->getNumNodes();
118 
119  std::vector<double> valN0(numNodes * numComps), valN1(numNodes * numComps);
120  std::vector<double> valL0(numNodes * numComps), valL1(numNodes * numComps);
121 
122  for(int nod = 0; nod < numNodes; nod++) {
123  double x, y, z;
124  e->getXYZ(nod, x, y, z);
125  double r_nod[3] = {x, y, z};
126  double rr = prosca(r_nod, r);
127  double e_jk0rr[2] = {cos(k0 * rr), sin(k0 * rr)};
128 
129  for(int comp = 0; comp < numComps; comp++) {
130  if(i < (int)js[0].size()) {
131  valN0[numComps * nod + comp] =
132  js[0][i] * e_jk0rr[0] - js[1][i] * e_jk0rr[1];
133  valN1[numComps * nod + comp] =
134  js[0][i] * e_jk0rr[1] + js[1][i] * e_jk0rr[0];
135  valL0[numComps * nod + comp] =
136  ms[0][i] * e_jk0rr[0] - ms[1][i] * e_jk0rr[1];
137  valL1[numComps * nod + comp] =
138  ms[0][i] * e_jk0rr[1] + ms[1][i] * e_jk0rr[0];
139  i++;
140  }
141  }
142  }
143 
144  N[0][0] += e->integrate(&valN0[0], 3);
145  N[1][0] += e->integrate(&valN1[0], 3);
146  N[0][1] += e->integrate(&valN0[1], 3);
147  N[1][1] += e->integrate(&valN1[1], 3);
148  N[0][2] += e->integrate(&valN0[2], 3);
149  N[1][2] += e->integrate(&valN1[2], 3);
150 
151  L[0][0] += e->integrate(&valL0[0], 3);
152  L[1][0] += e->integrate(&valL1[0], 3);
153  L[0][1] += e->integrate(&valL0[1], 3);
154  L[1][1] += e->integrate(&valL1[1], 3);
155  L[0][2] += e->integrate(&valL0[2], 3);
156  L[1][2] += e->integrate(&valL1[2], 3);
157  }
158 
159  // From Cartesian to spherical coordinates
160  for(int step = 0; step < 2; step++) {
161  Ns[step][0] = N[step][0] * sTheta * cPhi + N[step][1] * sTheta * sPhi +
162  N[step][2] * cTheta;
163  Ns[step][1] = N[step][0] * cTheta * cPhi + N[step][1] * cTheta * sPhi -
164  N[step][2] * sTheta;
165  Ns[step][2] = -N[step][0] * sPhi + N[step][1] * cPhi;
166 
167  Ls[step][0] = L[step][0] * sTheta * cPhi + L[step][1] * sTheta * sPhi +
168  L[step][2] * cTheta;
169  Ls[step][1] = L[step][0] * cTheta * cPhi + L[step][1] * cTheta * sPhi -
170  L[step][2] * sTheta;
171  Ls[step][2] = -L[step][0] * sPhi + L[step][1] * cPhi;
172  }
173 
174  // E_r radial component is negligible in far field
175  double E_theta[2];
176  double E_phi[2];
177  double k0_over_4pir = k0 / (4 * M_PI * rFar);
178  double cos_k0r = cos(k0 * rFar);
179  double sin_k0r = sin(k0 * rFar);
180 
181  // Elevation component
182  E_theta[0] = -k0_over_4pir * ((Ls[0][2] + Z0 * Ns[0][1]) * sin_k0r -
183  (Ls[1][2] + Z0 * Ns[1][1]) * cos_k0r);
184  E_theta[1] = -k0_over_4pir * ((Ls[0][2] + Z0 * Ns[0][1]) * cos_k0r +
185  (Ls[1][2] + Z0 * Ns[1][1]) * sin_k0r);
186  // Azimuthal component
187  E_phi[0] = k0_over_4pir * ((Ls[0][1] - Z0 * Ns[0][2]) * sin_k0r -
188  (Ls[1][1] - Z0 * Ns[1][2]) * cos_k0r);
189  E_phi[1] = k0_over_4pir * ((Ls[0][1] - Z0 * Ns[0][2]) * cos_k0r +
190  (Ls[1][1] - Z0 * Ns[1][2]) * sin_k0r);
191 
192  double farF = 1. / 2. / Z0 *
193  ((E_theta[0] * E_theta[0] + E_theta[1] * E_theta[1]) +
194  (E_phi[0] * E_phi[0] + E_phi[1] * E_phi[1]));
195 
196  return farF;
197 }
198 
199 // Compute far field using e^{-i\omega t} time dependency, following Monk in
200 // "Finite Element Methods for Maxwell's equations", p. 233
202  std::vector<element *> &allElems, std::vector<std::vector<double> > &ffvec,
203  std::vector<std::vector<double> > &js, std::vector<std::vector<double> > &ms,
204  double k0, double theta, double phi)
205 {
206  double sTheta = sin(theta);
207  double cTheta = cos(theta);
208  double sPhi = sin(phi);
209  double cPhi = cos(phi);
210  double xHat[3] = {sTheta * cPhi, sTheta * sPhi, cTheta};
211  std::complex<double> I(0., 1.);
212  double Z0 = 120 * M_PI; // free-space impedance
213 
214  double integral_r[3] = {0., 0., 0.}, integral_i[3] = {0., 0., 0.};
215  int i = 0;
216  for(std::size_t ele = 0; ele < allElems.size(); ele++) {
217  element *e = allElems[ele];
218  int numNodes = e->getNumNodes();
219  std::vector<double> integrand_r(numNodes * 3), integrand_i(numNodes * 3);
220  for(int nod = 0; nod < numNodes; nod++) {
221  double y[3];
222  e->getXYZ(nod, y[0], y[1], y[2]);
223  double const xHat_dot_y = prosca(xHat, y);
224  double n_x_e_r[3] = {-ms[0][i], -ms[0][i + 1], -ms[0][i + 2]};
225  double n_x_e_i[3] = {-ms[1][i], -ms[1][i + 1], -ms[1][i + 2]};
226  double n_x_h_r[3] = {js[0][i], js[0][i + 1], js[0][i + 2]};
227  double n_x_h_i[3] = {js[1][i], js[1][i + 1], js[1][i + 2]};
228  double n_x_h_x_xHat_r[3], n_x_h_x_xHat_i[3];
229  prodve(n_x_h_r, xHat, n_x_h_x_xHat_r);
230  prodve(n_x_h_i, xHat, n_x_h_x_xHat_i);
231  for(int comp = 0; comp < 3; comp++) {
232  std::complex<double> n_x_e(n_x_e_r[comp], n_x_e_i[comp]);
233  std::complex<double> n_x_h_x_xHat(n_x_h_x_xHat_r[comp],
234  n_x_h_x_xHat_i[comp]);
235  // Warning: Z0 == 1 in Monk
236  std::complex<double> integrand =
237  (n_x_e + Z0 * n_x_h_x_xHat) *
238  (cos(-k0 * xHat_dot_y) + I * sin(-k0 * xHat_dot_y));
239  integrand_r[3 * nod + comp] = integrand.real();
240  integrand_i[3 * nod + comp] = integrand.imag();
241  }
242  i += 3;
243  }
244  for(int comp = 0; comp < 3; comp++) {
245  integral_r[comp] += e->integrate(&integrand_r[comp], 3);
246  integral_i[comp] += e->integrate(&integrand_i[comp], 3);
247  }
248  }
249 
250  double xHat_x_integral_r[3], xHat_x_integral_i[3];
251  prodve(xHat, integral_r, xHat_x_integral_r);
252  prodve(xHat, integral_i, xHat_x_integral_i);
253  std::complex<double> coef = I * k0 / 4. / M_PI;
254  std::complex<double> einf[3] = {
255  coef * (xHat_x_integral_r[0] + I * xHat_x_integral_i[0]),
256  coef * (xHat_x_integral_r[1] + I * xHat_x_integral_i[1]),
257  coef * (xHat_x_integral_r[2] + I * xHat_x_integral_i[2])};
258 
259  double coef1 = k0 / 4. / M_PI;
260  for(int comp = 0; comp < 3; comp++) {
261  ffvec[comp][0] = -coef1 * xHat_x_integral_i[comp];
262  ffvec[comp][1] = coef1 * xHat_x_integral_r[comp];
263  }
264 
265  return (norm(einf[0]) + norm(einf[1]) + norm(einf[2]));
266 }
267 
268 static void printVector(FILE *fp, const std::string &name,
269  std::vector<std::vector<double> > &vec)
270 {
271  fprintf(fp, "%s = [", name.c_str());
272  for(std::size_t i = 0; i < vec.size(); i++)
273  for(std::size_t j = 0; j < vec[i].size(); j++)
274  fprintf(fp, "%.16g ", vec[i][j]);
275  fprintf(fp, "];\n");
276 }
277 
279 {
280  double _k0 = (double)NearToFarFieldOptions_Number[0].def;
281  double _phiStart = (double)NearToFarFieldOptions_Number[1].def;
282  double _phiEnd = (double)NearToFarFieldOptions_Number[2].def;
283  int _nbPhi = (int)NearToFarFieldOptions_Number[3].def;
284  double _thetaStart = (double)NearToFarFieldOptions_Number[4].def;
285  double _thetaEnd = (double)NearToFarFieldOptions_Number[5].def;
286  int _nbThe = (int)NearToFarFieldOptions_Number[6].def;
287  int _eView = (int)NearToFarFieldOptions_Number[7].def;
288  int _hView = (int)NearToFarFieldOptions_Number[8].def;
289  bool _normalize = (bool)NearToFarFieldOptions_Number[9].def;
290  bool _dB = (bool)NearToFarFieldOptions_Number[10].def;
291  int _negativeTime = (int)NearToFarFieldOptions_Number[11].def;
292  double _rfar = (int)NearToFarFieldOptions_Number[12].def;
293 
294  std::string _outFile = NearToFarFieldOptions_String[0].def;
295 
296  PView *ve = getView(_eView, v);
297  if(!ve) {
298  Msg::Error("NearToFarField plugin could not find EView %i", _eView);
299  return v;
300  }
301  PView *vh = getView(_hView, v);
302  if(!vh) {
303  Msg::Error("NearToFarField plugin could not find HView %i", _hView);
304  return v;
305  }
306  PViewData *eData = ve->getData();
307  PViewData *hData = vh->getData();
308 
309  if(eData->getNumEntities() != hData->getNumEntities() ||
310  eData->getNumElements() != hData->getNumElements() ||
311  eData->getNumTimeSteps() != hData->getNumTimeSteps()) {
312  Msg::Error("Incompatible views for E field and H field");
313  return v;
314  }
315 
316  if(eData->getNumTimeSteps() != 2 || hData->getNumTimeSteps() != 2) {
317  Msg::Error("Invalid number of steps for E or H fields (must be complex)");
318  return v;
319  }
320 
321  // center and radius of the visualization sphere
322  SBoundingBox3d bbox = eData->getBoundingBox();
323  double x0 = bbox.center().x();
324  double y0 = bbox.center().y();
325  double z0 = bbox.center().z();
326  double lc = norm(SVector3(bbox.max(), bbox.min()));
327  double r_sph = lc ? lc / 2. : 1;
328 
329  if(x0 != hData->getBoundingBox().center().x() ||
330  y0 != hData->getBoundingBox().center().y() ||
331  z0 != hData->getBoundingBox().center().z()) {
332  Msg::Error("E and H fields must be given on the same grid");
333  return v;
334  }
335 
336  // compute surface currents on all input elements
337  std::vector<element *> allElems;
338  std::vector<std::vector<double> > js(2);
339  std::vector<std::vector<double> > ms(2);
340 
341  for(int ent = 0; ent < eData->getNumEntities(0); ent++) {
342  for(int ele = 0; ele < eData->getNumElements(0, ent); ele++) {
343  if(eData->skipElement(0, ent, ele)) continue;
344  if(hData->skipElement(0, ent, ele)) continue;
345  int numComp = eData->getNumComponents(0, ent, ele);
346  if(numComp != 3) continue;
347  int dim = eData->getDimension(0, ent, ele);
348  if(dim != 1 && dim != 2) continue;
349  int numNodes = eData->getNumNodes(0, ent, ele);
350  std::vector<double> x(numNodes), y(numNodes), z(numNodes);
351  for(int nod = 0; nod < numNodes; nod++)
352  eData->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]);
353 
354  elementFactory factory;
355  allElems.push_back(
356  factory.create(numNodes, dim, &x[0], &y[0], &z[0], true));
357 
358  double n[3] = {0., 0., 0.};
359  if(numNodes > 2)
360  normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n);
361  else
362  normal2points(x[0], y[0], z[0], x[1], y[1], z[1], n);
363 
364  for(int step = 0; step < 2; step++) {
365  for(int nod = 0; nod < numNodes; nod++) {
366  double h[3], e[3];
367  for(int comp = 0; comp < numComp; comp++) {
368  eData->getValue(step, ent, ele, nod, comp, e[comp]);
369  hData->getValue(step, ent, ele, nod, comp, h[comp]);
370  }
371  double j[3], m[3];
372  prodve(n, h, j); // Js = n x H ; Surface electric current
373  prodve(e, n, m); // Ms = - n x E ; Surface magnetic current
374  js[step].push_back(j[0]);
375  js[step].push_back(j[1]);
376  js[step].push_back(j[2]);
377  ms[step].push_back(m[0]);
378  ms[step].push_back(m[1]);
379  ms[step].push_back(m[2]);
380  }
381  }
382  }
383  }
384 
385  if(allElems.empty()) {
386  Msg::Error("No valid elements found to compute far field");
387  return v;
388  }
389 
390  // view for far field that will contain the radiation pattern
391  PView *vf = new PView();
392  PViewDataList *dataFar = getDataList(vf);
393 
394  std::vector<std::vector<double> > phi(_nbPhi + 1), theta(_nbPhi + 1);
395  std::vector<std::vector<double> > x(_nbPhi + 1), y(_nbPhi + 1), z(_nbPhi + 1);
396  std::vector<std::vector<double> > farField(_nbPhi + 1);
397  std::vector<std::vector<double> > farField1r(_nbPhi + 1);
398  std::vector<std::vector<double> > farField2r(_nbPhi + 1);
399  std::vector<std::vector<double> > farField3r(_nbPhi + 1);
400  std::vector<std::vector<double> > farField1i(_nbPhi + 1);
401  std::vector<std::vector<double> > farField2i(_nbPhi + 1);
402  std::vector<std::vector<double> > farField3i(_nbPhi + 1);
403  std::vector<std::vector<double> > farFieldVec(3);
404  for(int comp = 0; comp < 3; comp++) { farFieldVec[comp].resize(2, 0.); }
405 
406  for(int i = 0; i <= _nbPhi; i++) {
407  phi[i].resize(_nbThe + 1);
408  theta[i].resize(_nbThe + 1);
409  x[i].resize(_nbThe + 1);
410  y[i].resize(_nbThe + 1);
411  z[i].resize(_nbThe + 1);
412  farField[i].resize(_nbThe + 1);
413 
414  farField1r[i].resize(_nbThe + 1);
415  farField2r[i].resize(_nbThe + 1);
416  farField3r[i].resize(_nbThe + 1);
417  farField1i[i].resize(_nbThe + 1);
418  farField2i[i].resize(_nbThe + 1);
419  farField3i[i].resize(_nbThe + 1);
420  }
421 
422  double dPhi = (_phiEnd - _phiStart) / _nbPhi;
423  double dTheta = (_thetaEnd - _thetaStart) / _nbThe;
424  double ffmin = 1e200, ffmax = -1e200;
425  Msg::StartProgressMeter(_nbPhi);
426  for(int i = 0; i <= _nbPhi; i++) {
427  for(int j = 0; j <= _nbThe; j++) {
428  phi[i][j] = _phiStart + i * dPhi;
429  theta[i][j] = _thetaStart + j * dTheta;
430  if(_negativeTime) {
431  farField[i][j] = getFarFieldMonk(allElems, farFieldVec, js, ms, _k0,
432  theta[i][j], phi[i][j]);
433  farField1r[i][j] = farFieldVec[0][0];
434  farField2r[i][j] = farFieldVec[1][0];
435  farField3r[i][j] = farFieldVec[2][0];
436  farField1i[i][j] = farFieldVec[0][1];
437  farField2i[i][j] = farFieldVec[1][1];
438  farField3i[i][j] = farFieldVec[2][1];
439  }
440  else {
441  double rfar = (_rfar ? _rfar : 10 * lc);
442  farField[i][j] =
443  getFarFieldJin(allElems, js, ms, _k0, rfar, theta[i][j], phi[i][j]);
444  }
445  ffmin = std::min(ffmin, farField[i][j]);
446  ffmax = std::max(ffmax, farField[i][j]);
447  }
448  Msg::ProgressMeter(i, true, "Computing far field");
449  }
451  for(std::size_t i = 0; i < allElems.size(); i++) delete allElems[i];
452 
453  if(_normalize) {
454  if(!ffmax)
455  Msg::Warning("Cannot normalize far field (max = 0)");
456  else
457  for(int i = 0; i <= _nbPhi; i++)
458  for(int j = 0; j <= _nbThe; j++) farField[i][j] /= ffmax;
459  }
460 
461  if(_dB) {
462  ffmin = 1e200;
463  ffmax = -1e200;
464  for(int i = 0; i <= _nbPhi; i++) {
465  for(int j = 0; j <= _nbThe; j++) {
466  farField[i][j] = 10 * log10(farField[i][j]);
467  ffmin = std::min(ffmin, farField[i][j]);
468  ffmax = std::max(ffmax, farField[i][j]);
469  }
470  }
471  }
472 
473  for(int i = 0; i <= _nbPhi; i++) {
474  for(int j = 0; j <= _nbThe; j++) {
475  double df = (ffmax - ffmin);
476  if(!df) {
477  Msg::Warning("zero far field range");
478  df = 1.;
479  }
480  double f = (farField[i][j] - ffmin) / df; // in [0,1]
481  x[i][j] = x0 + r_sph * f * sin(theta[i][j]) * cos(phi[i][j]);
482  y[i][j] = y0 + r_sph * f * sin(theta[i][j]) * sin(phi[i][j]);
483  z[i][j] = z0 + r_sph * f * cos(theta[i][j]);
484  }
485  }
486 
487  if(_outFile.size()) {
488  FILE *fp = Fopen(_outFile.c_str(), "w");
489  if(fp) {
490  printVector(fp, "phi", phi);
491  printVector(fp, "theta", theta);
492  printVector(fp, "farField", farField);
493 
494  if(_negativeTime) {
495  printVector(fp, "farField1r", farField1r);
496  printVector(fp, "farField2r", farField2r);
497  printVector(fp, "farField3r", farField3r);
498  printVector(fp, "farField1i", farField1i);
499  printVector(fp, "farField2i", farField2i);
500  printVector(fp, "farField3i", farField3i);
501  }
502 
503  printVector(fp, "x", x);
504  printVector(fp, "y", y);
505  printVector(fp, "z", z);
506  fclose(fp);
507  }
508  else
509  Msg::Error("Could not open file '%s'", _outFile.c_str());
510  }
511 
512  for(int i = 0; i < _nbPhi; i++) {
513  for(int j = 0; j < _nbThe; j++) {
514  if(_nbPhi == 1 || _nbThe == 1) {
515  dataFar->NbSP++;
516  dataFar->SP.push_back(x[i][j]);
517  dataFar->SP.push_back(y[i][j]);
518  dataFar->SP.push_back(z[i][j]);
519  dataFar->SP.push_back(farField[i][j]);
520  }
521  else {
522  double P1[3] = {x[i][j], y[i][j], z[i][j]};
523  double P2[3] = {x[i + 1][j], y[i + 1][j], z[i + 1][j]};
524  double P3[3] = {x[i + 1][j + 1], y[i + 1][j + 1], z[i + 1][j + 1]};
525  double P4[3] = {x[i][j + 1], y[i][j + 1], z[i][j + 1]};
526  dataFar->NbSQ++;
527  dataFar->SQ.push_back(P1[0]);
528  dataFar->SQ.push_back(P2[0]);
529  dataFar->SQ.push_back(P3[0]);
530  dataFar->SQ.push_back(P4[0]);
531  dataFar->SQ.push_back(P1[1]);
532  dataFar->SQ.push_back(P2[1]);
533  dataFar->SQ.push_back(P3[1]);
534  dataFar->SQ.push_back(P4[1]);
535  dataFar->SQ.push_back(P1[2]);
536  dataFar->SQ.push_back(P2[2]);
537  dataFar->SQ.push_back(P3[2]);
538  dataFar->SQ.push_back(P4[2]);
539  dataFar->SQ.push_back(farField[i][j]);
540  dataFar->SQ.push_back(farField[i + 1][j]);
541  dataFar->SQ.push_back(farField[i + 1][j + 1]);
542  dataFar->SQ.push_back(farField[i][j + 1]);
543  }
544  }
545  }
546 
547  dataFar->setName("_NearToFarField");
548  dataFar->setFileName("_NearToFarField.pos");
549  dataFar->finalize();
550 
551  return vf;
552 }
StringXString
Definition: Options.h:910
GMSH_NearToFarFieldPlugin::getHelp
std::string getHelp() const
Definition: NearToFarField.cpp:41
element::getXYZ
virtual void getXYZ(int num, double &x, double &y, double &z)
Definition: shapeFunctions.h:46
NearToFarFieldOptions_String
StringXString NearToFarFieldOptions_String[]
Definition: NearToFarField.cpp:30
PView
Definition: PView.h:27
element::integrate
double integrate(double val[], int stride=1)
Definition: shapeFunctions.h:212
GMSH_NearToFarFieldPlugin::getFarFieldJin
double getFarFieldJin(std::vector< element * > &allElems, std::vector< std::vector< double > > &js, std::vector< std::vector< double > > &ms, double k0, double r_far, double theta, double phi)
Definition: NearToFarField.cpp:81
PViewData::skipElement
virtual bool skipElement(int step, int ent, int ele, bool checkVisibility=false, int samplingRate=1)
Definition: PViewData.cpp:90
GMSH_NearToFarFieldPlugin::getOptionStr
StringXString * getOptionStr(int iopt)
Definition: NearToFarField.cpp:73
GMSH_Plugin
Definition: Plugin.h:26
PViewData::getNumTimeSteps
virtual int getNumTimeSteps()=0
OS.h
PViewDataList
Definition: PViewDataList.h:17
Msg::Warning
static void Warning(const char *fmt,...)
Definition: GmshMessage.cpp:543
GMSH_RegisterNearToFarFieldPlugin
GMSH_Plugin * GMSH_RegisterNearToFarFieldPlugin()
Definition: NearToFarField.cpp:35
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::NbSP
int NbSP
Definition: PViewDataList.h:26
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
StringXNumber
Definition: Options.h:918
PViewData::getValue
virtual void getValue(int step, int ent, int ele, int idx, double &val)
Definition: PViewData.h:159
PViewDataList::NbSQ
int NbSQ
Definition: PViewDataList.h:32
SBoundingBox3d::min
SPoint3 min() const
Definition: SBoundingBox3d.h:90
SVector3
Definition: SVector3.h:16
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_NearToFarFieldPlugin::getNbOptionsStr
int getNbOptionsStr() const
Definition: NearToFarField.cpp:63
Fopen
FILE * Fopen(const char *f, const char *mode)
Definition: OS.cpp:273
elementFactory
Definition: shapeFunctions.h:1402
SBoundingBox3d::center
SPoint3 center() const
Definition: SBoundingBox3d.h:92
GMSH_NearToFarFieldPlugin::getNbOptions
int getNbOptions() const
Definition: NearToFarField.cpp:58
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
PViewData::getDimension
virtual int getDimension(int step, int ent, int ele)
Definition: PViewData.h:134
PViewDataList::SP
std::vector< double > SP
Definition: PViewDataList.h:27
PViewData::getBoundingBox
virtual SBoundingBox3d getBoundingBox(int step=-1)=0
GMSH_FULLRC
#define GMSH_FULLRC
Definition: Options.h:20
norm
void norm(const double *vec, double *norm)
Definition: gmshLevelset.cpp:202
Msg::StopProgressMeter
static void StopProgressMeter()
Definition: GmshMessage.cpp:318
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
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
GMSH_NearToFarFieldPlugin
Definition: NearToFarField.h:20
prosca
double prosca(double const a[3], double const b[3])
Definition: Numeric.h:112
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
StringXString::def
std::string def
Definition: Options.h:914
elementFactory::create
element * create(int numNodes, int dimension, double *x, double *y, double *z, bool copy=false)
Definition: shapeFunctions.h:1404
prodve
void prodve(double a[3], double b[3], double c[3])
Definition: Numeric.h:105
element
Definition: shapeFunctions.h:12
element::getNumNodes
virtual int getNumNodes()=0
PViewData
Definition: PViewData.h:29
LegendrePolynomials::df
void df(int n, double u, double *val)
Definition: orthogonalBasis.cpp:103
GMSH_NearToFarFieldPlugin::execute
PView * execute(PView *)
Definition: NearToFarField.cpp:278
PViewData::getNumComponents
virtual int getNumComponents(int step, int ent, int ele)
Definition: PViewData.h:152
z
const double z
Definition: GaussQuadratureQuad.cpp:56
GMSH_PostPlugin::getView
virtual PView * getView(int index, PView *view)
Definition: Plugin.cpp:81
Msg::StartProgressMeter
static void StartProgressMeter(int ntotal)
Definition: GmshMessage.cpp:312
GMSH_NearToFarFieldPlugin::getOption
StringXNumber * getOption(int iopt)
Definition: NearToFarField.cpp:68
normal3points
void normal3points(double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double n[3])
Definition: Numeric.cpp:76
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
PViewData::getNumElements
virtual int getNumElements(int step=-1, int ent=-1)
Definition: PViewData.h:131
printVector
static void printVector(FILE *fp, const std::string &name, std::vector< std::vector< double > > &vec)
Definition: NearToFarField.cpp:268
NearToFarFieldOptions_Number
StringXNumber NearToFarFieldOptions_Number[]
Definition: NearToFarField.cpp:14
normal2points
void normal2points(double x0, double y0, double z0, double x1, double y1, double z1, double n[3])
Definition: Numeric.cpp:85
GMSH_NearToFarFieldPlugin::getFarFieldMonk
double getFarFieldMonk(std::vector< element * > &allElems, std::vector< std::vector< double > > &farfieldvector, std::vector< std::vector< double > > &js, std::vector< std::vector< double > > &ms, double k0, double theta, double phi)
Definition: NearToFarField.cpp:201
SBoundingBox3d::max
SPoint3 max() const
Definition: SBoundingBox3d.h:91
Msg::ProgressMeter
static void ProgressMeter(int n, bool log, const char *fmt,...)
Definition: GmshMessage.cpp:783
PViewDataList::SQ
std::vector< double > SQ
Definition: PViewDataList.h:33
SBoundingBox3d
Definition: SBoundingBox3d.h:21
NearToFarField.h
GMSH_PostPlugin::getDataList
virtual PViewDataList * getDataList(PView *view, bool showError=true)
Definition: Plugin.cpp:107