gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
PViewDataList.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 <algorithm>
7 #include "PView.h"
8 #include "PViewDataList.h"
9 #include "GmshMessage.h"
10 #include "GmshDefines.h"
11 #include "BasisFactory.h"
12 #include "Numeric.h"
13 #include "SmoothData.h"
14 #include "Context.h"
15 #include "polynomialBasis.h"
16 
18  : PViewData(), NbTimeStep(0), Min(VAL_INF), Max(-VAL_INF), NbSP(0), NbVP(0),
19  NbTP(0), NbSL(0), NbVL(0), NbTL(0), NbST(0), NbVT(0), NbTT(0), NbSQ(0),
20  NbVQ(0), NbTQ(0), NbSG(0), NbVG(0), NbTG(0), NbSS(0), NbVS(0), NbTS(0),
21  NbSH(0), NbVH(0), NbTH(0), NbSI(0), NbVI(0), NbTI(0), NbSY(0), NbVY(0),
22  NbTY(0), NbSR(0), NbVR(0), NbTR(0), NbSD(0), NbVD(0), NbTD(0), NbT2(0),
23  NbT3(0), _lastElement(-1), _lastDimension(-1), _lastNumNodes(-1),
24  _lastNumComponents(-1), _lastNumValues(-1), _lastNumEdges(-1),
25  _lastType(-1), _lastXYZ(nullptr), _lastVal(nullptr), _isAdapted(isAdapted)
26 {
27  for(int i = 0; i < 33; i++) _index[i] = 0;
28  polyTotNumNodes[0] = 0.;
29  polyTotNumNodes[1] = 0.;
30  polyAgNumNodes[0].push_back(0.);
31  polyAgNumNodes[1].push_back(0.);
32 }
33 
34 void PViewDataList::setXY(std::vector<double> &x, std::vector<double> &y)
35 {
36  NbSP = 0;
37  SP.clear();
38  for(std::size_t i = 0; i < std::min(x.size(), y.size()); i++) {
39  SP.push_back(x[i]);
40  SP.push_back(0.);
41  SP.push_back(0.);
42  SP.push_back(y[i]);
43  NbSP++;
44  }
45  finalize();
46 }
47 
48 void PViewDataList::setXYZV(std::vector<double> &x, std::vector<double> &y,
49  std::vector<double> &z, std::vector<double> &v)
50 {
51  NbSP = 0;
52  SP.clear();
53  int n = std::min(std::min(std::min(x.size(), y.size()), z.size()), v.size());
54  for(int i = 0; i < n; i++) {
55  SP.push_back(x[i]);
56  SP.push_back(y[i]);
57  SP.push_back(z[i]);
58  SP.push_back(v[i]);
59  NbSP++;
60  }
61  finalize();
62 }
63 
64 void PViewDataList::addStep(std::vector<double> &y)
65 {
66  if(NbSP != (int)y.size()) {
67  Msg::Error("Wrong number of values while adding step in list-based view");
68  return;
69  }
70  // This is not very efficient, but well... ;-)
71  std::vector<double> tmp;
72  int stride = SP.size() / NbSP;
73  for(int i = 0; i < NbSP; i++) {
74  for(int j = 0; j < stride; j++) tmp.push_back(SP[i * stride + j]);
75  tmp.push_back(y[i]);
76  }
77  SP = tmp;
78  finalize();
79 }
80 
81 bool PViewDataList::finalize(bool computeMinMax,
82  const std::string &interpolationScheme)
83 {
84  BBox.reset();
85  Min = VAL_INF;
86  Max = -VAL_INF;
87 
88  // finalize text strings first, to get the max value of NbTimeStep
89  // for strings-only views (strings are designed to degrade
90  // gracefully when some have fewer time steps than others). If there
91  // are any elements in the view, this value will be replaced by the
92  // minimum number of time steps common to all elements.
93  _stat(T2D, T2C, 4);
94  _stat(T3D, T3C, 5);
95 
96  // compute min/max and other statistics for all element lists
97  _stat(SP, 1, NbSP, 1, TYPE_PNT);
98  _stat(VP, 3, NbVP, 1, TYPE_PNT);
99  _stat(TP, 9, NbTP, 1, TYPE_PNT);
100  _stat(SL, 1, NbSL, 2, TYPE_LIN);
101  _stat(VL, 3, NbVL, 2, TYPE_LIN);
102  _stat(TL, 9, NbTL, 2, TYPE_LIN);
103  _stat(ST, 1, NbST, 3, TYPE_TRI);
104  _stat(VT, 3, NbVT, 3, TYPE_TRI);
105  _stat(TT, 9, NbTT, 3, TYPE_TRI);
106  _stat(SQ, 1, NbSQ, 4, TYPE_QUA);
107  _stat(VQ, 3, NbVQ, 4, TYPE_QUA);
108  _stat(TQ, 9, NbTQ, 4, TYPE_QUA);
109  _stat(SS, 1, NbSS, 4, TYPE_TET);
110  _stat(VS, 3, NbVS, 4, TYPE_TET);
111  _stat(TS, 9, NbTS, 4, TYPE_TET);
112  _stat(SH, 1, NbSH, 8, TYPE_HEX);
113  _stat(VH, 3, NbVH, 8, TYPE_HEX);
114  _stat(TH, 9, NbTH, 8, TYPE_HEX);
115  _stat(SI, 1, NbSI, 6, TYPE_PRI);
116  _stat(VI, 3, NbVI, 6, TYPE_PRI);
117  _stat(TI, 9, NbTI, 6, TYPE_PRI);
118  _stat(SY, 1, NbSY, 5, TYPE_PYR);
119  _stat(VY, 3, NbVY, 5, TYPE_PYR);
120  _stat(TY, 9, NbTY, 5, TYPE_PYR);
121  _stat(SY, 1, NbSR, 4, TYPE_TRIH);
122  _stat(VY, 3, NbVR, 4, TYPE_TRIH);
123  _stat(TY, 9, NbTR, 4, TYPE_TRIH);
124  _stat(SG, 1, NbSG, 3, TYPE_POLYG);
125  _stat(VG, 3, NbVG, 3, TYPE_POLYG);
126  _stat(TG, 9, NbTG, 3, TYPE_POLYG);
127  _stat(SD, 1, NbSD, 4, TYPE_POLYH);
128  _stat(VD, 3, NbVD, 4, TYPE_POLYH);
129  _stat(TD, 9, NbTD, 4, TYPE_POLYH);
130 
131  // add dummy time values if none (or too few) time values are
132  // provided (e.g. using the old parsed format)
133  if((int)Time.size() < NbTimeStep) {
134  for(int i = Time.size(); i < NbTimeStep; i++) Time.push_back(i);
135  }
136 
137  // compute starting element indices
138  int nb[33] = {NbSP, NbVP, NbTP, NbSL, NbVL, NbTL, NbST, NbVT, NbTT,
139  NbSQ, NbVQ, NbTQ, NbSS, NbVS, NbTS, NbSH, NbVH, NbTH,
140  NbSI, NbVI, NbTI, NbSY, NbVY, NbTY, NbSR, NbVR, NbTR,
141  NbSG, NbVG, NbTG, NbSD, NbVD, NbTD};
142  for(int i = 0; i < 33; i++) {
143  _index[i] = 0;
144  for(int j = 0; j <= i; j++) _index[i] += nb[j];
145  }
146 
147  if(CTX::instance()->post.smooth) smooth();
148 
149  return PViewData::finalize();
150 }
151 
153 {
154  return NbSP + NbSL + NbST + NbSQ + NbSS + NbSH + NbSI + NbSY + NbSR + NbSG +
155  NbSD;
156 }
157 
159 {
160  return NbVP + NbVL + NbVT + NbVQ + NbVS + NbVH + NbVI + NbVY + NbVR + NbVG +
161  NbVD;
162 }
163 
165 {
166  return NbTP + NbTL + NbTT + NbTQ + NbTS + NbTH + NbTI + NbTY + NbTR + NbTG +
167  NbTD;
168 }
169 
170 int PViewDataList::getNumElements(int step, int ent)
171 {
172  return getNumScalars() + getNumVectors() + getNumTensors();
173 }
174 
175 double PViewDataList::getTime(int step)
176 {
177  if(step < 0 || step >= (int)Time.size()) return 0.;
178  return Time[step];
179 }
180 
181 double PViewDataList::getMin(int step, bool onlyVisible, int tensorRep,
182  int forceNumComponents, int componentMap[9])
183 {
184  if(step >= (int)TimeStepMin.size()) return Min;
185 
186  if(forceNumComponents || tensorRep) {
187  double vmin = VAL_INF;
188  for(int ent = 0; ent < getNumEntities(step); ent++) {
189  for(int ele = 0; ele < getNumElements(step, ent); ele++) {
190  for(int nod = 0; nod < getNumNodes(step, ent, ele); nod++) {
191  double val;
192  getScalarValue(step, ent, ele, nod, val, tensorRep,
193  forceNumComponents, componentMap);
194  vmin = std::min(vmin, val);
195  }
196  }
197  }
198  return vmin;
199  }
200 
201  if(step < 0) return Min;
202  return TimeStepMin[step];
203 }
204 
205 double PViewDataList::getMax(int step, bool onlyVisible, int tensorRep,
206  int forceNumComponents, int componentMap[9])
207 {
208  if(step >= (int)TimeStepMax.size()) return Max;
209 
210  if(forceNumComponents || tensorRep) {
211  double vmax = -VAL_INF;
212  for(int ent = 0; ent < getNumEntities(step); ent++) {
213  for(int ele = 0; ele < getNumElements(step, ent); ele++) {
214  for(int nod = 0; nod < getNumNodes(step, ent, ele); nod++) {
215  double val;
216  getScalarValue(step, ent, ele, nod, val, tensorRep,
217  forceNumComponents, componentMap);
218  vmax = std::max(vmax, val);
219  }
220  }
221  }
222  return vmax;
223  }
224 
225  if(step < 0) return Max;
226  return TimeStepMax[step];
227 }
228 
229 void PViewDataList::_stat(std::vector<double> &D, std::vector<char> &C, int nb)
230 {
231  // compute statistics for text lists
232  for(std::size_t i = 0; i < D.size(); i += nb) {
233  double beg = D[i + nb - 1];
234  double end;
235  if(i + 2 * nb > D.size())
236  end = C.size();
237  else
238  end = D[i + nb + nb - 1];
239  char *c = &C[(int)beg];
240  int nbtime = 0;
241  for(int j = 0; j < (int)(end - beg); j++)
242  if(c[j] == '\0') nbtime++;
243  if(nbtime > NbTimeStep) NbTimeStep = nbtime;
244  }
245  if(nb == 5) {
246  for(std::size_t i = 0; i < D.size(); i += nb)
247  BBox += SPoint3(D[i], D[i + 1], D[i + 2]);
248  }
249 }
250 
251 void PViewDataList::_stat(std::vector<double> &list, int nbcomp, int nbelm,
252  int nbnod, int type)
253 {
254  // compute statistics for element lists
255  if(!nbelm) return;
256 
257  int nbval = nbcomp * nbnod;
258 
260  std::vector<fullMatrix<double> *> im;
261  int nim = getInterpolationMatrices(type, im);
262  if(nim == 4) nbnod = im[2]->size1();
263  if(nim) nbval = nbcomp * im[0]->size1();
264  }
265 
266  int nb = list.size() / nbelm;
267  for(int ele = 0; ele < nbelm; ele++) {
268  int i = ele * nb;
269  if(type == TYPE_POLYG || type == TYPE_POLYH) {
270  int t = (type == TYPE_POLYG) ? 0 : 1;
271  nbnod = polyNumNodes[t][ele];
272  nb = list.size() / polyTotNumNodes[t] * nbnod;
273  i = polyAgNumNodes[t][ele] * nb / nbnod;
274  nbval = nbcomp * nbnod;
275  }
276  int N = nb - 3 * nbnod;
277  double *X = &list[i];
278  double *Y = &list[i + 1 * nbnod];
279  double *Z = &list[i + 2 * nbnod];
280  double *V = &list[i + 3 * nbnod];
281 
282  // update bounding box
283  for(int j = 0; j < nbnod; j++) BBox += SPoint3(X[j], Y[j], Z[j]);
284 
285  // update num time steps
286  if(Min == VAL_INF || Max == -VAL_INF) {
287  NbTimeStep = N / nbval;
288  TimeStepMin.clear();
289  TimeStepMax.clear();
290  for(int j = 0; j < NbTimeStep; j++) {
291  TimeStepMin.push_back(VAL_INF);
292  TimeStepMax.push_back(-VAL_INF);
293  }
294  }
295  else if(N / nbval < NbTimeStep) {
296  // if some elts have less steps, reduce the total number!
297  NbTimeStep = N / nbval;
298  }
299 
300  // update min/max
301  int tensorRep = 0; // Von-Mises: we could/should be able to choose this
302  for(int j = 0; j < N; j += nbcomp) {
303  double l0 = ComputeScalarRep(nbcomp, &V[j], tensorRep);
304  Min = std::min(l0, Min);
305  Max = std::max(l0, Max);
306  int ts = j / nbval;
307  if(ts < NbTimeStep) { // security
308  TimeStepMin[ts] = std::min(l0, TimeStepMin[ts]);
309  TimeStepMax[ts] = std::max(l0, TimeStepMax[ts]);
310  }
311  }
312  }
313 }
314 
315 void PViewDataList::_setLast(int ele, int dim, int nbnod, int nbcomp, int nbedg,
316  int type, std::vector<double> &list, int nblist)
317 {
319  std::vector<fullMatrix<double> *> im;
320  if(getInterpolationMatrices(type, im) == 4) nbnod = im[2]->size1();
321  }
322 
323  _lastDimension = dim;
324  _lastNumNodes = nbnod;
325  _lastNumComponents = nbcomp;
326  _lastNumEdges = nbedg;
327  _lastType = type;
328  int nb = list.size() / nblist; // number of coords and values for the element
329  int nbAg =
330  ele * nb; // number of coords and values before the ones of the element
331  if(type == TYPE_POLYG || type == TYPE_POLYH) {
332  int t = (type == TYPE_POLYG) ? 0 : 1;
333  nb = list.size() / polyTotNumNodes[t] * nbnod;
334  nbAg = polyAgNumNodes[t][ele] * nb / nbnod;
335  }
336  _lastNumValues = (nb - 3 * nbnod) / NbTimeStep;
337  _lastXYZ = &list[nbAg];
338  _lastVal = &list[nbAg + 3 * _lastNumNodes];
339 }
340 
342 {
343  _lastElement = ele;
344  if(ele < _index[2]) { // points
345  if(ele < _index[0])
346  _setLast(ele, 0, 1, 1, 0, TYPE_PNT, SP, NbSP);
347  else if(ele < _index[1])
348  _setLast(ele - _index[0], 0, 1, 3, 0, TYPE_PNT, VP, NbVP);
349  else
350  _setLast(ele - _index[1], 0, 1, 9, 0, TYPE_PNT, TP, NbTP);
351  }
352  else if(ele < _index[5]) { // lines
353  if(ele < _index[3])
354  _setLast(ele - _index[2], 1, 2, 1, 1, TYPE_LIN, SL, NbSL);
355  else if(ele < _index[4])
356  _setLast(ele - _index[3], 1, 2, 3, 1, TYPE_LIN, VL, NbVL);
357  else
358  _setLast(ele - _index[4], 1, 2, 9, 1, TYPE_LIN, TL, NbTL);
359  }
360  else if(ele < _index[8]) { // triangles
361  if(ele < _index[6])
362  _setLast(ele - _index[5], 2, 3, 1, 3, TYPE_TRI, ST, NbST);
363  else if(ele < _index[7])
364  _setLast(ele - _index[6], 2, 3, 3, 3, TYPE_TRI, VT, NbVT);
365  else
366  _setLast(ele - _index[7], 2, 3, 9, 3, TYPE_TRI, TT, NbTT);
367  }
368  else if(ele < _index[11]) { // quadrangles
369  if(ele < _index[9])
370  _setLast(ele - _index[8], 2, 4, 1, 4, TYPE_QUA, SQ, NbSQ);
371  else if(ele < _index[10])
372  _setLast(ele - _index[9], 2, 4, 3, 4, TYPE_QUA, VQ, NbVQ);
373  else
374  _setLast(ele - _index[10], 2, 4, 9, 4, TYPE_QUA, TQ, NbTQ);
375  }
376  else if(ele < _index[14]) { // tetrahedra
377  if(ele < _index[12])
378  _setLast(ele - _index[11], 3, 4, 1, 6, TYPE_TET, SS, NbSS);
379  else if(ele < _index[13])
380  _setLast(ele - _index[12], 3, 4, 3, 6, TYPE_TET, VS, NbVS);
381  else
382  _setLast(ele - _index[13], 3, 4, 9, 6, TYPE_TET, TS, NbTS);
383  }
384  else if(ele < _index[17]) { // hexahedra
385  if(ele < _index[15])
386  _setLast(ele - _index[14], 3, 8, 1, 12, TYPE_HEX, SH, NbSH);
387  else if(ele < _index[16])
388  _setLast(ele - _index[15], 3, 8, 3, 12, TYPE_HEX, VH, NbVH);
389  else
390  _setLast(ele - _index[16], 3, 8, 9, 12, TYPE_HEX, TH, NbTH);
391  }
392  else if(ele < _index[20]) { // prisms
393  if(ele < _index[18])
394  _setLast(ele - _index[17], 3, 6, 1, 9, TYPE_PRI, SI, NbSI);
395  else if(ele < _index[19])
396  _setLast(ele - _index[18], 3, 6, 3, 9, TYPE_PRI, VI, NbVI);
397  else
398  _setLast(ele - _index[19], 3, 6, 9, 9, TYPE_PRI, TI, NbTI);
399  }
400  else if(ele < _index[23]) { // pyramids
401  if(ele < _index[21])
402  _setLast(ele - _index[20], 3, 5, 1, 8, TYPE_PYR, SY, NbSY);
403  else if(ele < _index[22])
404  _setLast(ele - _index[21], 3, 5, 3, 8, TYPE_PYR, VY, NbVY);
405  else
406  _setLast(ele - _index[22], 3, 5, 9, 8, TYPE_PYR, TY, NbTY);
407  }
408  else if(ele < _index[26]) { // trihedra
409  if(ele < _index[24])
410  _setLast(ele - _index[23], 3, 4, 1, 5, TYPE_TRIH, SR, NbSR);
411  else if(ele < _index[25])
412  _setLast(ele - _index[24], 3, 4, 3, 5, TYPE_TRIH, VR, NbVR);
413  else
414  _setLast(ele - _index[25], 3, 4, 9, 5, TYPE_TRIH, TR, NbTR);
415  }
416  else if(ele < _index[29]) { // polygons
417  int nN = polyNumNodes[0][ele - _index[26]];
418  if(ele < _index[27])
419  _setLast(ele - _index[26], 2, nN, 1, nN, TYPE_POLYG, SG, NbSG);
420  else if(ele < _index[28])
421  _setLast(ele - _index[27], 2, nN, 3, nN, TYPE_POLYG, VG, NbVG);
422  else
423  _setLast(ele - _index[28], 2, nN, 9, nN, TYPE_POLYG, TG, NbTG);
424  }
425  else if(ele < _index[32]) { // polyhedra
426  int nN = polyNumNodes[1][ele - _index[29]];
427  if(ele < _index[30])
428  _setLast(ele - _index[29], 3, nN, 1, nN * 1.5, TYPE_POLYH, SD, NbSD);
429  else if(ele < _index[32])
430  _setLast(ele - _index[30], 3, nN, 3, nN * 1.5, TYPE_POLYH, VD, NbVD);
431  else
432  _setLast(ele - _index[31], 3, nN, 9, nN * 1.5, TYPE_POLYH, TD, NbTD);
433  }
434 }
435 
436 int PViewDataList::getDimension(int step, int ent, int ele)
437 {
438  if(ele != _lastElement) _setLast(ele);
439  return _lastDimension;
440 }
441 
442 int PViewDataList::getNumNodes(int step, int ent, int ele)
443 {
444  if(ele != _lastElement) _setLast(ele);
445  return _lastNumNodes;
446 }
447 
448 int PViewDataList::getNode(int step, int ent, int ele, int nod, double &x,
449  double &y, double &z)
450 {
451  if(ele != _lastElement) _setLast(ele);
452  x = _lastXYZ[nod];
453  y = _lastXYZ[_lastNumNodes + nod];
454  z = _lastXYZ[2 * _lastNumNodes + nod];
455  return 0;
456 }
457 
458 void PViewDataList::setNode(int step, int ent, int ele, int nod, double x,
459  double y, double z)
460 {
461  if(step) return;
462  if(ele != _lastElement) _setLast(ele);
463  _lastXYZ[nod] = x;
464  _lastXYZ[_lastNumNodes + nod] = y;
465  _lastXYZ[2 * _lastNumNodes + nod] = z;
466 }
467 
468 int PViewDataList::getNumComponents(int step, int ent, int ele)
469 {
470  if(ele != _lastElement) _setLast(ele);
471  return _lastNumComponents;
472 }
473 
474 int PViewDataList::getNumValues(int step, int ent, int ele)
475 {
476  if(ele != _lastElement) _setLast(ele);
477  return _lastNumValues;
478 }
479 
480 void PViewDataList::getValue(int step, int ent, int ele, int idx, double &val)
481 {
482  if(ele != _lastElement) _setLast(ele);
483  if(step >= NbTimeStep) step = 0;
484  val = _lastVal[step * _lastNumValues + idx];
485 }
486 
487 void PViewDataList::getValue(int step, int ent, int ele, int nod, int comp,
488  double &val)
489 {
490  if(ele != _lastElement) _setLast(ele);
491  if(step >= NbTimeStep) step = 0;
492  val = _lastVal[step * _lastNumNodes * _lastNumComponents +
493  nod * _lastNumComponents + comp];
494 }
495 
496 void PViewDataList::setValue(int step, int ent, int ele, int nod, int comp,
497  double val)
498 {
499  if(ele != _lastElement) _setLast(ele);
500  if(step >= NbTimeStep) step = 0;
502  nod * _lastNumComponents + comp] = val;
503 }
504 
505 int PViewDataList::getNumEdges(int step, int ent, int ele)
506 {
507  if(ele != _lastElement) _setLast(ele);
508  return _lastNumEdges;
509 }
510 
511 int PViewDataList::getType(int step, int ent, int ele)
512 {
513  if(ele != _lastElement) _setLast(ele);
514  return _lastType;
515 }
516 
517 void PViewDataList::_getString(int dim, int i, int step, std::string &str,
518  double &x, double &y, double &z, double &style)
519 {
520  // 3D: T3D is a list of double: x,y,z,style,index,x,y,z,style,index,...
521  // T3C is a list of chars: string\0,string\0,string\0,string\0,...
522  // Parser format is: T3(x,y,z,style){"str","str",...};
523  // 2D: T2D is a list of double: x,y,style,index,x,y,style,index,...
524  // T2C is a list of chars: string\0,string\0,string\0,string\0,...
525  // Parser format is: T2(x,y,style){"str","str",...};
526 
527  std::vector<double> &td = (dim == 2) ? T2D : T3D;
528  std::vector<char> &tc = (dim == 2) ? T2C : T3C;
529  int nbd = (dim == 2) ? 4 : 5;
530 
531  int index, nbchar;
532  double *d1 = &td[i * nbd];
533  double *d2 = ((i + 1) * nbd < (int)td.size()) ? &td[(i + 1) * nbd] : nullptr;
534 
535  if(dim == 2) {
536  x = d1[0];
537  y = d1[1];
538  z = 0.;
539  style = d1[2];
540  index = (int)d1[3];
541  if(d2)
542  nbchar = (int)d2[3] - index;
543  else
544  nbchar = tc.size() - index;
545  }
546  else {
547  x = d1[0];
548  y = d1[1];
549  z = d1[2];
550  style = d1[3];
551  index = (int)d1[4];
552  if(d2)
553  nbchar = (int)d2[4] - index;
554  else
555  nbchar = tc.size() - index;
556  }
557 
558  char *c = &tc[index];
559  int k = 0, l = 0;
560  while(k < nbchar && l != step) {
561  if(c[k++] == '\0') l++;
562  }
563  if(k < nbchar && l == step)
564  str = std::string(&c[k]);
565  else
566  str = std::string(c);
567 }
568 
569 void PViewDataList::getString2D(int i, int step, std::string &str, double &x,
570  double &y, double &style)
571 {
572  double z;
573  _getString(2, i, step, str, x, y, z, style);
574 }
575 
576 void PViewDataList::getString3D(int i, int step, std::string &str, double &x,
577  double &y, double &z, double &style)
578 {
579  _getString(3, i, step, str, x, y, z, style);
580 }
581 
582 void PViewDataList::reverseElement(int step, int ent, int ele)
583 {
584  if(step) return;
585  if(ele != _lastElement) _setLast(ele);
586 
587  // copy data
588  std::vector<double> XYZ(3 * _lastNumNodes);
589  for(std::size_t i = 0; i < XYZ.size(); i++) XYZ[i] = _lastXYZ[i];
590 
591  std::vector<double> V(_lastNumNodes * _lastNumComponents * getNumTimeSteps());
592  for(std::size_t i = 0; i < V.size(); i++) V[i] = _lastVal[i];
593 
594  // reverse node order
595  for(int i = 0; i < _lastNumNodes; i++) {
596  _lastXYZ[i] = XYZ[_lastNumNodes - i - 1];
597  _lastXYZ[_lastNumNodes + i] = XYZ[2 * _lastNumNodes - i - 1];
598  _lastXYZ[2 * _lastNumNodes + i] = XYZ[3 * _lastNumNodes - i - 1];
599  }
600 
601  for(int step = 0; step < getNumTimeSteps(); step++)
602  for(int i = 0; i < _lastNumNodes; i++)
603  for(int k = 0; k < _lastNumComponents; k++)
605  _lastNumComponents * i + k] =
606  V[_lastNumComponents * _lastNumNodes * step +
607  _lastNumComponents * (_lastNumNodes - i - 1) + k];
608 }
609 
610 static void generateConnectivities(std::vector<double> &list, int nbList,
611  int nbTimeStep, int nbVert, int nbComp,
612  smooth_data &data)
613 {
614  if(!nbList) return;
615  double *vals = new double[nbTimeStep * nbComp];
616  int nb = list.size() / nbList;
617  for(std::size_t i = 0; i < list.size(); i += nb) {
618  double *x = &list[i];
619  double *y = &list[i + nbVert];
620  double *z = &list[i + 2 * nbVert];
621  double *v = &list[i + 3 * nbVert];
622  for(int j = 0; j < nbVert; j++) {
623  for(int ts = 0; ts < nbTimeStep; ts++)
624  for(int k = 0; k < nbComp; k++)
625  vals[nbComp * ts + k] = v[nbVert * nbComp * ts + nbComp * j + k];
626  data.add(x[j], y[j], z[j], nbTimeStep * nbComp, vals);
627  }
628  }
629  delete[] vals;
630 }
631 
632 static void smoothList(std::vector<double> &list, int nbList, int nbTimeStep,
633  int nbVert, int nbComp, smooth_data &data)
634 {
635  if(!nbList) return;
636  double *vals = new double[nbTimeStep * nbComp];
637  int nb = list.size() / nbList;
638  for(std::size_t i = 0; i < list.size(); i += nb) {
639  double *x = &list[i];
640  double *y = &list[i + nbVert];
641  double *z = &list[i + 2 * nbVert];
642  double *v = &list[i + 3 * nbVert];
643  for(int j = 0; j < nbVert; j++) {
644  if(data.get(x[j], y[j], z[j], nbTimeStep * nbComp, vals)) {
645  for(int ts = 0; ts < nbTimeStep; ts++)
646  for(int k = 0; k < nbComp; k++)
647  v[nbVert * nbComp * ts + nbComp * j + k] = vals[nbComp * ts + k];
648  }
649  }
650  }
651  delete[] vals;
652 }
653 
655 {
656  double old_eps = xyzv::eps;
657  xyzv::eps = CTX::instance()->lc * 1.e-8;
658  smooth_data data;
659 
660  std::vector<double> *list = nullptr;
661  int *nbe = nullptr, nbc, nbn;
662  for(int i = 0; i < 27; i++) {
663  _getRawData(i, &list, &nbe, &nbc, &nbn);
664  if(nbn > 1) generateConnectivities(*list, *nbe, NbTimeStep, nbn, nbc, data);
665  }
666  for(int i = 0; i < 27; i++) {
667  _getRawData(i, &list, &nbe, &nbc, &nbn);
668  if(nbn > 1) smoothList(*list, *nbe, NbTimeStep, nbn, nbc, data);
669  }
670  xyzv::eps = old_eps;
671  finalize();
672 }
673 
675 {
676  double b = 0.;
677  b += (TimeStepMin.size() + TimeStepMax.size() + Time.size()) * sizeof(double);
678  b += (SP.size() + VP.size() + TP.size()) * sizeof(double);
679  b += (SL.size() + VL.size() + TL.size()) * sizeof(double);
680  b += (ST.size() + VT.size() + TT.size()) * sizeof(double);
681  b += (SQ.size() + VQ.size() + TQ.size()) * sizeof(double);
682  b += (SG.size() + VG.size() + TG.size()) * sizeof(double);
683  b += (SS.size() + VS.size() + TS.size()) * sizeof(double);
684  b += (SH.size() + VH.size() + TH.size()) * sizeof(double);
685  b += (SI.size() + VI.size() + TI.size()) * sizeof(double);
686  b += (SY.size() + VY.size() + TY.size()) * sizeof(double);
687  b += (SR.size() + VR.size() + TR.size()) * sizeof(double);
688  b += (SD.size() + VD.size() + TD.size()) * sizeof(double);
689  b += (T2D.size() + T3D.size()) * sizeof(double);
690  return b / 1024. / 1024.;
691 }
692 
693 static void dVecMerge(std::vector<double> &v, std::vector<double> &dest)
694 {
695  for(std::size_t i = 0; i < v.size(); i++) dest.push_back(v[i]);
696 }
697 
699 {
700  // sanity checks
701  if(nd.data.size() < 2) return false;
702  int ts = nd.data[0]->getNumTimeSteps();
703  for(std::size_t i = 1; i < nd.data.size(); i++) {
704  if(!nd.data[i]->empty() && nd.data[i]->getNumTimeSteps() != ts) {
705  Msg::Error("Cannot combine views having different number of time steps");
706  return false;
707  }
708  }
709 
710  for(std::size_t i = 0; i < nd.data.size(); i++) {
711  PViewDataList *l = dynamic_cast<PViewDataList *>(nd.data[i]);
712  if(!l) {
713  Msg::Error("Cannot combine hybrid data");
714  return false;
715  }
716 
717  // copy interpolation matrices
718  for(auto it = l->_interpolation.begin(); it != l->_interpolation.end();
719  it++)
720  if(_interpolation[it->first].empty())
721  for(std::size_t i = 0; i < it->second.size(); i++)
722  _interpolation[it->first].push_back(
723  new fullMatrix<double>(*it->second[i]));
724 
725  // copy time values
726 
727  if(!i) Time = l->Time;
728 
729  // merge elememts
730  dVecMerge(l->SP, SP);
731  NbSP += l->NbSP;
732  dVecMerge(l->VP, VP);
733  NbVP += l->NbVP;
734  dVecMerge(l->TP, TP);
735  NbTP += l->NbTP;
736  dVecMerge(l->SL, SL);
737  NbSL += l->NbSL;
738  dVecMerge(l->VL, VL);
739  NbVL += l->NbVL;
740  dVecMerge(l->TL, TL);
741  NbTL += l->NbTL;
742  dVecMerge(l->ST, ST);
743  NbST += l->NbST;
744  dVecMerge(l->VT, VT);
745  NbVT += l->NbVT;
746  dVecMerge(l->TT, TT);
747  NbTT += l->NbTT;
748  dVecMerge(l->SQ, SQ);
749  NbSQ += l->NbSQ;
750  dVecMerge(l->VQ, VQ);
751  NbVQ += l->NbVQ;
752  dVecMerge(l->TQ, TQ);
753  NbTQ += l->NbTQ;
754  dVecMerge(l->SS, SS);
755  NbSS += l->NbSS;
756  dVecMerge(l->VS, VS);
757  NbVS += l->NbVS;
758  dVecMerge(l->TS, TS);
759  NbTS += l->NbTS;
760  dVecMerge(l->SH, SH);
761  NbSH += l->NbSH;
762  dVecMerge(l->VH, VH);
763  NbVH += l->NbVH;
764  dVecMerge(l->TH, TH);
765  NbTH += l->NbTH;
766  dVecMerge(l->SI, SI);
767  NbSI += l->NbSI;
768  dVecMerge(l->VI, VI);
769  NbVI += l->NbVI;
770  dVecMerge(l->TI, TI);
771  NbTI += l->NbTI;
772  dVecMerge(l->SY, SY);
773  NbSY += l->NbSY;
774  dVecMerge(l->VY, VY);
775  NbVY += l->NbVY;
776  dVecMerge(l->TY, TY);
777  NbTY += l->NbTY;
778  dVecMerge(l->VR, VR);
779  NbVR += l->NbVR;
780  dVecMerge(l->TR, TR);
781  NbTR += l->NbTR;
782 
783  // merge strings
784  for(std::size_t i = 0; i < l->T2D.size(); i += 4) {
785  T2D.push_back(l->T2D[i]);
786  T2D.push_back(l->T2D[i + 1]);
787  T2D.push_back(l->T2D[i + 2]);
788  T2D.push_back(T2C.size());
789  double beg = l->T2D[i + 3];
790  double end;
791  if(i > l->T2D.size() - 8)
792  end = l->T2C.size();
793  else
794  end = l->T2D[i + 3 + 4];
795  char *c = &l->T2C[(int)beg];
796  for(int j = 0; j < (int)(end - beg); j++) T2C.push_back(c[j]);
797  NbT2++;
798  }
799  for(std::size_t i = 0; i < l->T3D.size(); i += 5) {
800  T3D.push_back(l->T3D[i]);
801  T3D.push_back(l->T3D[i + 1]);
802  T3D.push_back(l->T3D[i + 2]);
803  T3D.push_back(l->T3D[i + 3]);
804  T3D.push_back(T3C.size());
805  double beg = l->T3D[i + 4];
806  double end;
807  if(i > l->T3D.size() - 10)
808  end = l->T3C.size();
809  else
810  end = l->T3D[i + 4 + 5];
811  char *c = &l->T3C[(int)beg];
812  for(int j = 0; j < (int)(end - beg); j++) T3C.push_back(c[j]);
813  NbT3++;
814  }
815  }
816 
817  std::string tmp;
818  if(nd.name == "__all__")
819  tmp = "all";
820  else if(nd.name == "__vis__")
821  tmp = "visible";
822  else
823  tmp = nd.name;
824  char name[256];
825  sprintf(name, "%s_Combine", tmp.c_str());
826  setName(name);
827  setFileName(std::string(name) + ".pos");
828 
829  return finalize();
830 }
831 
833 {
834  // sanity checks
835  if(nd.data.size() < 2) return false;
836  std::vector<PViewDataList *> data(nd.data.size());
837  for(std::size_t i = 0; i < nd.data.size(); i++) {
838  data[i] = dynamic_cast<PViewDataList *>(nd.data[i]);
839  if(!data[i]) {
840  Msg::Error("Cannot combine hybrid data");
841  return false;
842  }
843  }
844 
845  int *nbe = nullptr, *nbe2 = nullptr, nbn, nbn2, nbc, nbc2;
846  std::vector<double> *list = nullptr, *list2 = nullptr;
847 
848  // use the first data set as the reference
849  for(int i = 0; i < 27; i++) {
850  _getRawData(i, &list, &nbe, &nbc, &nbn);
851  data[0]->_getRawData(i, &list2, &nbe2, &nbc2, &nbn2);
852  *nbe = *nbe2;
853  }
854  NbT2 = data[0]->NbT2;
855  NbT3 = data[0]->NbT3;
856  for(auto it = data[0]->_interpolation.begin();
857  it != data[0]->_interpolation.end(); it++)
858  if(_interpolation[it->first].empty())
859  for(std::size_t i = 0; i < it->second.size(); i++)
860  _interpolation[it->first].push_back(
861  new fullMatrix<double>(*it->second[i]));
862 
863  // merge values for all element types
864  for(int i = 0; i < 27; i++) {
865  _getRawData(i, &list, &nbe, &nbc, &nbn);
866  for(int j = 0; j < *nbe; j++) {
867  for(std::size_t k = 0; k < data.size(); k++) {
868  data[k]->_getRawData(i, &list2, &nbe2, &nbc2, &nbn2);
869  if(*nbe && *nbe == *nbe2) {
870  int nb2 = list2->size() / *nbe2;
871  if(!k) {
872  // copy coordinates of elm j (we are always here as
873  // expected, since the ref view is the first one)
874  for(int l = 0; l < 3 * nbn2; l++)
875  list->push_back((*list2)[j * nb2 + l]);
876  }
877  // copy values of elm j
878  for(int l = 0; l < nb2 - 3 * nbn2; l++)
879  list->push_back((*list2)[j * nb2 + 3 * nbn2 + l]);
880  }
881  }
882  }
883  }
884 
885  // merge 2d strings
886  for(int j = 0; j < NbT2; j++) {
887  for(std::size_t k = 0; k < data.size(); k++) {
888  if(NbT2 == data[k]->NbT2) {
889  if(!k) {
890  // copy coordinates
891  T2D.push_back(data[k]->T2D[j * 4]);
892  T2D.push_back(data[k]->T2D[j * 4 + 1]);
893  T2D.push_back(data[k]->T2D[j * 4 + 2]);
894  // index
895  T2D.push_back(T2C.size());
896  }
897  // copy char values
898  double beg = data[k]->T2D[j * 4 + 3];
899  double end;
900  if(j == NbT2 - 1)
901  end = data[k]->T2C.size();
902  else
903  end = data[k]->T2D[j * 4 + 4 + 3];
904  char *c = &data[k]->T2C[(int)beg];
905  for(int l = 0; l < (int)(end - beg); l++) T2C.push_back(c[l]);
906  }
907  }
908  }
909 
910  // merge 3d strings
911  for(int j = 0; j < NbT3; j++) {
912  for(std::size_t k = 0; k < data.size(); k++) {
913  if(NbT3 == data[k]->NbT3) {
914  if(!k) {
915  // copy coordinates
916  T3D.push_back(data[k]->T3D[j * 5]);
917  T3D.push_back(data[k]->T3D[j * 5 + 1]);
918  T3D.push_back(data[k]->T3D[j * 5 + 2]);
919  T3D.push_back(data[k]->T3D[j * 5 + 3]);
920  // index
921  T3D.push_back(T3C.size());
922  }
923  // copy char values
924  double beg = data[k]->T3D[j * 5 + 4];
925  double end;
926  if(j == NbT3 - 1)
927  end = data[k]->T3C.size();
928  else
929  end = data[k]->T3D[j * 5 + 5 + 4];
930  char *c = &data[k]->T3C[(int)beg];
931  for(int l = 0; l < (int)(end - beg); l++) T3C.push_back(c[l]);
932  }
933  }
934  }
935 
936  // create the time data
937  for(std::size_t i = 0; i < data.size(); i++) dVecMerge(data[i]->Time, Time);
938 
939  // if all the time values are the same, it probably means that the
940  // original views didn't have any time data: then we'll just use
941  // time step values
942  if(Time.size()) {
943  double t0 = Time[0], ti;
944  bool allTheSame = true;
945  for(std::size_t i = 1; i < Time.size(); i++) {
946  ti = Time[i];
947  if(ti != t0) {
948  allTheSame = false;
949  break;
950  }
951  }
952  if(allTheSame) Time.clear();
953  }
954 
955  std::string tmp;
956  if(nd.name == "__all__")
957  tmp = "all";
958  else if(nd.name == "__vis__")
959  tmp = "visible";
960  else
961  tmp = nd.name;
962  char name[256];
963  sprintf(name, "%s_Combine", tmp.c_str());
964 
965  setName(name);
966  setFileName(std::string(name) + ".pos");
967  return finalize();
968 }
969 
970 int PViewDataList::_getRawData(int idxtype, std::vector<double> **l, int **ne,
971  int *nc, int *nn)
972 {
973  int type = 0;
974  // No constant nn for polygons!
975  if(idxtype > 26 && idxtype < 33)
976  Msg::Warning("No constant number of nodes for polygons and polyhedra");
977  switch(idxtype) {
978  case 0:
979  *l = &SP;
980  *ne = &NbSP;
981  *nc = 1;
982  *nn = 1;
983  type = TYPE_PNT;
984  break;
985  case 1:
986  *l = &VP;
987  *ne = &NbVP;
988  *nc = 3;
989  *nn = 1;
990  type = TYPE_PNT;
991  break;
992  case 2:
993  *l = &TP;
994  *ne = &NbTP;
995  *nc = 9;
996  *nn = 1;
997  type = TYPE_PNT;
998  break;
999  case 3:
1000  *l = &SL;
1001  *ne = &NbSL;
1002  *nc = 1;
1003  *nn = 2;
1004  type = TYPE_LIN;
1005  break;
1006  case 4:
1007  *l = &VL;
1008  *ne = &NbVL;
1009  *nc = 3;
1010  *nn = 2;
1011  type = TYPE_LIN;
1012  break;
1013  case 5:
1014  *l = &TL;
1015  *ne = &NbTL;
1016  *nc = 9;
1017  *nn = 2;
1018  type = TYPE_LIN;
1019  break;
1020  case 6:
1021  *l = &ST;
1022  *ne = &NbST;
1023  *nc = 1;
1024  *nn = 3;
1025  type = TYPE_TRI;
1026  break;
1027  case 7:
1028  *l = &VT;
1029  *ne = &NbVT;
1030  *nc = 3;
1031  *nn = 3;
1032  type = TYPE_TRI;
1033  break;
1034  case 8:
1035  *l = &TT;
1036  *ne = &NbTT;
1037  *nc = 9;
1038  *nn = 3;
1039  type = TYPE_TRI;
1040  break;
1041  case 9:
1042  *l = &SQ;
1043  *ne = &NbSQ;
1044  *nc = 1;
1045  *nn = 4;
1046  type = TYPE_QUA;
1047  break;
1048  case 10:
1049  *l = &VQ;
1050  *ne = &NbVQ;
1051  *nc = 3;
1052  *nn = 4;
1053  type = TYPE_QUA;
1054  break;
1055  case 11:
1056  *l = &TQ;
1057  *ne = &NbTQ;
1058  *nc = 9;
1059  *nn = 4;
1060  type = TYPE_QUA;
1061  break;
1062  case 12:
1063  *l = &SS;
1064  *ne = &NbSS;
1065  *nc = 1;
1066  *nn = 4;
1067  type = TYPE_TET;
1068  break;
1069  case 13:
1070  *l = &VS;
1071  *ne = &NbVS;
1072  *nc = 3;
1073  *nn = 4;
1074  type = TYPE_TET;
1075  break;
1076  case 14:
1077  *l = &TS;
1078  *ne = &NbTS;
1079  *nc = 9;
1080  *nn = 4;
1081  type = TYPE_TET;
1082  break;
1083  case 15:
1084  *l = &SH;
1085  *ne = &NbSH;
1086  *nc = 1;
1087  *nn = 8;
1088  type = TYPE_HEX;
1089  break;
1090  case 16:
1091  *l = &VH;
1092  *ne = &NbVH;
1093  *nc = 3;
1094  *nn = 8;
1095  type = TYPE_HEX;
1096  break;
1097  case 17:
1098  *l = &TH;
1099  *ne = &NbTH;
1100  *nc = 9;
1101  *nn = 8;
1102  type = TYPE_HEX;
1103  break;
1104  case 18:
1105  *l = &SI;
1106  *ne = &NbSI;
1107  *nc = 1;
1108  *nn = 6;
1109  type = TYPE_PRI;
1110  break;
1111  case 19:
1112  *l = &VI;
1113  *ne = &NbVI;
1114  *nc = 3;
1115  *nn = 6;
1116  type = TYPE_PRI;
1117  break;
1118  case 20:
1119  *l = &TI;
1120  *ne = &NbTI;
1121  *nc = 9;
1122  *nn = 6;
1123  type = TYPE_PRI;
1124  break;
1125  case 21:
1126  *l = &SY;
1127  *ne = &NbSY;
1128  *nc = 1;
1129  *nn = 5;
1130  type = TYPE_PYR;
1131  break;
1132  case 22:
1133  *l = &VY;
1134  *ne = &NbVY;
1135  *nc = 3;
1136  *nn = 5;
1137  type = TYPE_PYR;
1138  break;
1139  case 23:
1140  *l = &TY;
1141  *ne = &NbTY;
1142  *nc = 9;
1143  *nn = 5;
1144  type = TYPE_PYR;
1145  break;
1146  case 24:
1147  *l = &SR;
1148  *ne = &NbSR;
1149  *nc = 1;
1150  *nn = 4;
1151  type = TYPE_TRIH;
1152  break;
1153  case 25:
1154  *l = &VR;
1155  *ne = &NbVR;
1156  *nc = 3;
1157  *nn = 4;
1158  type = TYPE_TRIH;
1159  break;
1160  case 26:
1161  *l = &TR;
1162  *ne = &NbTR;
1163  *nc = 9;
1164  *nn = 4;
1165  type = TYPE_TRIH;
1166  break;
1167  case 27:
1168  *l = &SG;
1169  *ne = &NbSG;
1170  *nc = 1;
1171  *nn = 3;
1172  type = TYPE_POLYG;
1173  break;
1174  case 28:
1175  *l = &VG;
1176  *ne = &NbVG;
1177  *nc = 3;
1178  *nn = 3;
1179  type = TYPE_POLYG;
1180  break;
1181  case 29:
1182  *l = &TG;
1183  *ne = &NbTG;
1184  *nc = 9;
1185  *nn = 3;
1186  type = TYPE_POLYG;
1187  break;
1188  case 30:
1189  *l = &SD;
1190  *ne = &NbSD;
1191  *nc = 1;
1192  *nn = 4;
1193  type = TYPE_POLYH;
1194  break;
1195  case 31:
1196  *l = &VD;
1197  *ne = &NbVD;
1198  *nc = 3;
1199  *nn = 4;
1200  type = TYPE_POLYH;
1201  break;
1202  case 32:
1203  *l = &TD;
1204  *ne = &NbTD;
1205  *nc = 9;
1206  *nn = 4;
1207  type = TYPE_POLYH;
1208  break;
1209  default: Msg::Error("Wrong type in PViewDataList"); break;
1210  }
1211 
1213  std::vector<fullMatrix<double> *> im;
1214  int nim = getInterpolationMatrices(type, im);
1215  if(nim == 4) *nn = im[2]->size1();
1216  }
1217  return type;
1218 }
1219 
1221 {
1222  int typeMSH = 0;
1223  switch(type) {
1224  case TYPE_LIN: typeMSH = MSH_LIN_3; break;
1225  case TYPE_TRI: typeMSH = MSH_TRI_6; break;
1226  case TYPE_QUA: typeMSH = MSH_QUA_9; break;
1227  case TYPE_TET: typeMSH = MSH_TET_10; break;
1228  case TYPE_HEX: typeMSH = MSH_HEX_27; break;
1229  case TYPE_PRI: typeMSH = MSH_PRI_18; break;
1230  case TYPE_PYR: typeMSH = MSH_PYR_14; break;
1231  }
1232  const polynomialBasis *fs =
1234  if(!fs) {
1235  Msg::Error("Could not find polynomial function space for element type %d",
1236  typeMSH);
1237  return;
1238  }
1240  fs->coefficients, fs->monomials);
1241 }
1242 
1243 std::vector<double> *PViewDataList::incrementList(int numComp, int type,
1244  int numNodes)
1245 {
1246  int nb;
1247  switch(type) {
1248  case TYPE_PNT:
1249  if(numComp == 1) {
1250  NbSP++;
1251  return &SP;
1252  }
1253  else if(numComp == 3) {
1254  NbVP++;
1255  return &VP;
1256  }
1257  else if(numComp == 9) {
1258  NbTP++;
1259  return &TP;
1260  }
1261  break;
1262  case TYPE_LIN:
1263  if(numComp == 1) {
1264  NbSL++;
1265  return &SL;
1266  }
1267  else if(numComp == 3) {
1268  NbVL++;
1269  return &VL;
1270  }
1271  else if(numComp == 9) {
1272  NbTL++;
1273  return &TL;
1274  }
1275  break;
1276  case TYPE_TRI:
1277  if(numComp == 1) {
1278  NbST++;
1279  return &ST;
1280  }
1281  else if(numComp == 3) {
1282  NbVT++;
1283  return &VT;
1284  }
1285  else if(numComp == 9) {
1286  NbTT++;
1287  return &TT;
1288  }
1289  break;
1290  case TYPE_QUA:
1291  if(numComp == 1) {
1292  NbSQ++;
1293  return &SQ;
1294  }
1295  else if(numComp == 3) {
1296  NbVQ++;
1297  return &VQ;
1298  }
1299  else if(numComp == 9) {
1300  NbTQ++;
1301  return &TQ;
1302  }
1303  break;
1304  case TYPE_TET:
1305  if(numComp == 1) {
1306  NbSS++;
1307  return &SS;
1308  }
1309  else if(numComp == 3) {
1310  NbVS++;
1311  return &VS;
1312  }
1313  else if(numComp == 9) {
1314  NbTS++;
1315  return &TS;
1316  }
1317  break;
1318  case TYPE_HEX:
1319  if(numComp == 1) {
1320  NbSH++;
1321  return &SH;
1322  }
1323  else if(numComp == 3) {
1324  NbVH++;
1325  return &VH;
1326  }
1327  else if(numComp == 9) {
1328  NbTH++;
1329  return &TH;
1330  }
1331  break;
1332  case TYPE_PRI:
1333  if(numComp == 1) {
1334  NbSI++;
1335  return &SI;
1336  }
1337  else if(numComp == 3) {
1338  NbVI++;
1339  return &VI;
1340  }
1341  else if(numComp == 9) {
1342  NbTI++;
1343  return &TI;
1344  }
1345  break;
1346  case TYPE_PYR:
1347  if(numComp == 1) {
1348  NbSY++;
1349  return &SY;
1350  }
1351  else if(numComp == 3) {
1352  NbVY++;
1353  return &VY;
1354  }
1355  else if(numComp == 9) {
1356  NbTY++;
1357  return &TY;
1358  }
1359  break;
1360  case TYPE_TRIH:
1361  if(numComp == 1) {
1362  NbSR++;
1363  return &SR;
1364  }
1365  else if(numComp == 3) {
1366  NbVR++;
1367  return &VR;
1368  }
1369  else if(numComp == 9) {
1370  NbTR++;
1371  return &TR;
1372  }
1373  break;
1374  case TYPE_POLYG:
1375  polyNumNodes[0].push_back(numNodes);
1376  nb = (polyAgNumNodes[0].size()) ? polyAgNumNodes[0].back() : 0;
1377  polyAgNumNodes[0].push_back(numNodes + nb);
1378  polyTotNumNodes[0] += numNodes;
1379  if(numComp == 1) {
1380  NbSG++;
1381  return &SG;
1382  }
1383  else if(numComp == 3) {
1384  NbVG++;
1385  return &VG;
1386  }
1387  else if(numComp == 9) {
1388  NbTG++;
1389  return &TG;
1390  }
1391  break;
1392  case TYPE_POLYH:
1393  polyNumNodes[1].push_back(numNodes);
1394  nb = (polyAgNumNodes[1].size()) ? polyAgNumNodes[1].back() : 0;
1395  polyAgNumNodes[1].push_back(numNodes + nb);
1396  polyTotNumNodes[1] += numNodes;
1397  if(numComp == 1) {
1398  NbSD++;
1399  return &SD;
1400  }
1401  else if(numComp == 3) {
1402  NbVD++;
1403  return &VD;
1404  }
1405  else if(numComp == 9) {
1406  NbTD++;
1407  return &TD;
1408  }
1409  break;
1410  }
1411  return nullptr;
1412 }
PViewDataList::getNumEntities
int getNumEntities(int step=-1)
Definition: PViewDataList.h:103
smoothList
static void smoothList(std::vector< double > &list, int nbList, int nbTimeStep, int nbVert, int nbComp, smooth_data &data)
Definition: PViewDataList.cpp:632
PViewDataList::_lastType
int _lastType
Definition: PViewDataList.h:59
PViewDataList::getMemoryInMb
double getMemoryInMb()
Definition: PViewDataList.cpp:674
PViewDataList::_lastNumNodes
int _lastNumNodes
Definition: PViewDataList.h:58
D
#define D
Definition: DefaultOptions.h:24
PViewDataList::VQ
std::vector< double > VQ
Definition: PViewDataList.h:33
MSH_TRI_6
#define MSH_TRI_6
Definition: GmshDefines.h:88
PViewDataList::TS
std::vector< double > TS
Definition: PViewDataList.h:37
PViewDataList::BBox
SBoundingBox3d BBox
Definition: PViewDataList.h:24
PViewDataList::NbVY
int NbVY
Definition: PViewDataList.h:42
PViewDataList::NbVR
int NbVR
Definition: PViewDataList.h:44
PViewDataList::TQ
std::vector< double > TQ
Definition: PViewDataList.h:33
PViewDataList::NbT3
int NbT3
Definition: PViewDataList.h:48
PViewDataList::reverseElement
void reverseElement(int step, int ent, int ele)
Definition: PViewDataList.cpp:582
PViewDataList::Min
double Min
Definition: PViewDataList.h:22
PViewDataList::smooth
void smooth()
Definition: PViewDataList.cpp:654
generateConnectivities
static void generateConnectivities(std::vector< double > &list, int nbList, int nbTimeStep, int nbVert, int nbComp, smooth_data &data)
Definition: PViewDataList.cpp:610
PViewDataList::T2C
std::vector< char > T2C
Definition: PViewDataList.h:50
PViewDataList::getNumTensors
int getNumTensors(int step=-1)
Definition: PViewDataList.cpp:164
polynomialBasis::monomials
fullMatrix< double > monomials
Definition: polynomialBasis.h:20
dVecMerge
static void dVecMerge(std::vector< double > &v, std::vector< double > &dest)
Definition: PViewDataList.cpp:693
PViewDataList::NbTL
int NbTL
Definition: PViewDataList.h:28
PViewDataList::getNumNodes
int getNumNodes(int step, int ent, int ele)
Definition: PViewDataList.cpp:442
PViewDataList::SS
std::vector< double > SS
Definition: PViewDataList.h:37
PViewDataList::polyNumNodes
std::vector< int > polyNumNodes[2]
Definition: PViewDataList.h:51
PViewDataList::NbSG
int NbSG
Definition: PViewDataList.h:34
TYPE_LIN
#define TYPE_LIN
Definition: GmshDefines.h:65
PViewDataList::T3D
std::vector< double > T3D
Definition: PViewDataList.h:49
PViewDataList::TL
std::vector< double > TL
Definition: PViewDataList.h:29
PViewDataList::NbTP
int NbTP
Definition: PViewDataList.h:26
PViewDataList::NbTT
int NbTT
Definition: PViewDataList.h:30
nameData::name
std::string name
Definition: PView.h:171
MSH_PYR_14
#define MSH_PYR_14
Definition: GmshDefines.h:93
PViewDataList::Max
double Max
Definition: PViewDataList.h:22
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
PViewDataList
Definition: PViewDataList.h:17
PViewDataList::_getRawData
int _getRawData(int idxtype, std::vector< double > **l, int **ne, int *nc, int *nn)
Definition: PViewDataList.cpp:970
Msg::Warning
static void Warning(const char *fmt,...)
Definition: GmshMessage.cpp:543
PViewDataList::TimeStepMin
std::vector< double > TimeStepMin
Definition: PViewDataList.h:23
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
PViewDataList::NbSP
int NbSP
Definition: PViewDataList.h:26
PViewData::getInterpolationMatrices
int getInterpolationMatrices(int type, std::vector< fullMatrix< double > * > &p)
Definition: PViewData.cpp:176
PViewDataList::incrementList
std::vector< double > * incrementList(int numComp, int type, int numNodes=0)
Definition: PViewDataList.cpp:1243
PViewDataList::_index
int _index[33]
Definition: PViewDataList.h:56
PViewDataList::NbTimeStep
int NbTimeStep
Definition: PViewDataList.h:21
SPoint3
Definition: SPoint3.h:14
PViewDataList::getDimension
int getDimension(int step, int ent, int ele)
Definition: PViewDataList.cpp:436
PViewDataList::TI
std::vector< double > TI
Definition: PViewDataList.h:41
PViewDataList::NbSQ
int NbSQ
Definition: PViewDataList.h:32
nameData
Definition: PView.h:169
smooth_data::get
bool get(double x, double y, double z, int n, double *vals) const
Definition: SmoothData.cpp:112
TYPE_PNT
#define TYPE_PNT
Definition: GmshDefines.h:64
smooth_data::add
void add(double x, double y, double z, int n, double *vals)
Definition: SmoothData.cpp:79
PViewDataList::SY
std::vector< double > SY
Definition: PViewDataList.h:43
VAL_INF
#define VAL_INF
Definition: PViewData.h:16
PViewDataList::NbSH
int NbSH
Definition: PViewDataList.h:38
TYPE_TRI
#define TYPE_TRI
Definition: GmshDefines.h:66
PViewDataList::VL
std::vector< double > VL
Definition: PViewDataList.h:29
PView.h
PViewDataList::SD
std::vector< double > SD
Definition: PViewDataList.h:47
PViewDataList::VR
std::vector< double > VR
Definition: PViewDataList.h:45
PViewDataList::SR
std::vector< double > SR
Definition: PViewDataList.h:45
PViewData::_interpolation
interpolationMatrices _interpolation
Definition: PViewData.h:51
PViewDataList::VY
std::vector< double > VY
Definition: PViewDataList.h:43
GmshMessage.h
PViewDataList::getType
int getType(int step, int ent, int ele)
Definition: PViewDataList.cpp:511
PViewData::haveInterpolationMatrices
bool haveInterpolationMatrices(int type=0)
Definition: PViewData.cpp:186
TYPE_PRI
#define TYPE_PRI
Definition: GmshDefines.h:70
PViewDataList::NbVH
int NbVH
Definition: PViewDataList.h:38
PViewData::setFileName
virtual void setFileName(const std::string &val)
Definition: PViewData.h:75
PViewDataList::TimeStepMax
std::vector< double > TimeStepMax
Definition: PViewDataList.h:23
PViewDataList::VH
std::vector< double > VH
Definition: PViewDataList.h:39
PViewDataList::NbVG
int NbVG
Definition: PViewDataList.h:34
PViewDataList::getMax
double getMax(int step=-1, bool onlyVisible=false, int tensorRep=0, int forceNumComponents=0, int componentMap[9]=nullptr)
Definition: PViewDataList.cpp:205
CTX::smooth
int smooth
Definition: Context.h:317
PViewDataList::getString2D
void getString2D(int i, int step, std::string &str, double &x, double &y, double &style)
Definition: PViewDataList.cpp:569
PViewDataList::polyAgNumNodes
std::vector< int > polyAgNumNodes[2]
Definition: PViewDataList.h:52
CTX::instance
static CTX * instance()
Definition: Context.cpp:122
fullMatrix< double >
PViewDataList::addStep
void addStep(std::vector< double > &y)
Definition: PViewDataList.cpp:64
PViewDataList::TY
std::vector< double > TY
Definition: PViewDataList.h:43
PViewDataList::TP
std::vector< double > TP
Definition: PViewDataList.h:27
PViewDataList::getNumTimeSteps
int getNumTimeSteps()
Definition: PViewDataList.h:79
PViewData::setInterpolationMatrices
void setInterpolationMatrices(int type, const fullMatrix< double > &coefVal, const fullMatrix< double > &expVal)
Definition: PViewData.cpp:154
PViewDataList::_setLast
void _setLast(int ele)
Definition: PViewDataList.cpp:341
PViewDataList::SG
std::vector< double > SG
Definition: PViewDataList.h:35
BasisFactory::getNodalBasis
static const nodalBasis * getNodalBasis(int tag)
Definition: BasisFactory.cpp:23
PViewDataList::_lastDimension
int _lastDimension
Definition: PViewDataList.h:57
PViewDataList::getMin
double getMin(int step=-1, bool onlyVisible=false, int tensorRep=0, int forceNumComponents=0, int componentMap[9]=nullptr)
Definition: PViewDataList.cpp:181
PViewDataList::TR
std::vector< double > TR
Definition: PViewDataList.h:45
PViewDataList::_lastNumEdges
int _lastNumEdges
Definition: PViewDataList.h:58
PViewDataList::VP
std::vector< double > VP
Definition: PViewDataList.h:27
PViewDataList::NbTH
int NbTH
Definition: PViewDataList.h:38
MSH_LIN_3
#define MSH_LIN_3
Definition: GmshDefines.h:87
PViewDataList::SP
std::vector< double > SP
Definition: PViewDataList.h:27
nameData::data
std::vector< PViewData * > data
Definition: PView.h:173
CTX::lc
double lc
Definition: Context.h:234
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
PViewDataList::T3C
std::vector< char > T3C
Definition: PViewDataList.h:50
PViewDataList::getTime
double getTime(int step)
Definition: PViewDataList.cpp:175
Numeric.h
PViewDataList::SL
std::vector< double > SL
Definition: PViewDataList.h:29
PViewDataList::polyTotNumNodes
int polyTotNumNodes[2]
Definition: PViewDataList.h:53
PViewDataList::setValue
void setValue(int step, int ent, int ele, int nod, int comp, double val)
Definition: PViewDataList.cpp:496
PViewDataList.h
PViewDataList::getNumScalars
int getNumScalars(int step=-1)
Definition: PViewDataList.cpp:152
PViewDataList::NbVS
int NbVS
Definition: PViewDataList.h:36
PViewDataList::_lastVal
double * _lastVal
Definition: PViewDataList.h:60
GmshDefines.h
PViewDataList::_lastNumComponents
int _lastNumComponents
Definition: PViewDataList.h:58
PViewDataList::getString3D
void getString3D(int i, int step, std::string &str, double &x, double &y, double &z, double &style)
Definition: PViewDataList.cpp:576
PViewDataList::getNumVectors
int getNumVectors(int step=-1)
Definition: PViewDataList.cpp:158
polynomialBasis::coefficients
fullMatrix< double > coefficients
Definition: polynomialBasis.h:21
PViewDataList::_stat
void _stat(std::vector< double > &D, std::vector< char > &C, int nb)
Definition: PViewDataList.cpp:229
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
smooth_data
Definition: SmoothData.h:53
PViewDataList::NbVD
int NbVD
Definition: PViewDataList.h:46
PViewDataList::getNumComponents
int getNumComponents(int step, int ent, int ele)
Definition: PViewDataList.cpp:468
PViewDataList::setOrder2
void setOrder2(int type)
Definition: PViewDataList.cpp:1220
PViewDataList::ST
std::vector< double > ST
Definition: PViewDataList.h:31
MSH_TET_10
#define MSH_TET_10
Definition: GmshDefines.h:90
PViewDataList::TT
std::vector< double > TT
Definition: PViewDataList.h:31
PViewDataList::NbVP
int NbVP
Definition: PViewDataList.h:26
PViewDataList::NbTS
int NbTS
Definition: PViewDataList.h:36
PViewDataList::VD
std::vector< double > VD
Definition: PViewDataList.h:47
PViewData
Definition: PViewData.h:29
PViewDataList::_getString
void _getString(int dim, int i, int timestep, std::string &str, double &x, double &y, double &z, double &style)
Definition: PViewDataList.cpp:517
TYPE_PYR
#define TYPE_PYR
Definition: GmshDefines.h:69
PViewDataList::TG
std::vector< double > TG
Definition: PViewDataList.h:35
MSH_QUA_9
#define MSH_QUA_9
Definition: GmshDefines.h:89
PViewDataList::NbT2
int NbT2
Definition: PViewDataList.h:48
PViewDataList::NbSL
int NbSL
Definition: PViewDataList.h:28
TYPE_QUA
#define TYPE_QUA
Definition: GmshDefines.h:67
PViewDataList::getNumElements
int getNumElements(int step=-1, int ent=-1)
Definition: PViewDataList.cpp:170
PViewDataList::setXY
void setXY(std::vector< double > &x, std::vector< double > &y)
Definition: PViewDataList.cpp:34
TYPE_POLYG
#define TYPE_POLYG
Definition: GmshDefines.h:72
PViewDataList::TH
std::vector< double > TH
Definition: PViewDataList.h:39
PViewDataList::SH
std::vector< double > SH
Definition: PViewDataList.h:39
MSH_PRI_18
#define MSH_PRI_18
Definition: GmshDefines.h:92
PViewDataList::NbTI
int NbTI
Definition: PViewDataList.h:40
polynomialBasis.h
Context.h
SBoundingBox3d::reset
void reset()
Definition: SBoundingBox3d.h:43
PViewDataList::NbSS
int NbSS
Definition: PViewDataList.h:36
PViewDataList::setNode
void setNode(int step, int ent, int ele, int nod, double x, double y, double z)
Definition: PViewDataList.cpp:458
PViewDataList::NbTY
int NbTY
Definition: PViewDataList.h:42
PViewDataList::T2D
std::vector< double > T2D
Definition: PViewDataList.h:49
PViewDataList::NbVL
int NbVL
Definition: PViewDataList.h:28
PViewDataList::PViewDataList
PViewDataList(bool isAdapted=false)
Definition: PViewDataList.cpp:17
z
const double z
Definition: GaussQuadratureQuad.cpp:56
PViewDataList::NbSD
int NbSD
Definition: PViewDataList.h:46
MSH_HEX_27
#define MSH_HEX_27
Definition: GmshDefines.h:91
PViewDataList::getNumValues
int getNumValues(int step, int ent, int ele)
Definition: PViewDataList.cpp:474
PViewDataList::VG
std::vector< double > VG
Definition: PViewDataList.h:35
PViewDataList::TD
std::vector< double > TD
Definition: PViewDataList.h:47
PViewDataList::NbTR
int NbTR
Definition: PViewDataList.h:44
PViewDataList::NbSI
int NbSI
Definition: PViewDataList.h:40
xyzv::eps
static double eps
Definition: SmoothData.h:23
PViewDataList::Time
std::vector< double > Time
Definition: PViewDataList.h:25
PViewDataList::getValue
void getValue(int step, int ent, int ele, int idx, double &val)
Definition: PViewDataList.cpp:480
PViewDataList::VS
std::vector< double > VS
Definition: PViewDataList.h:37
TYPE_HEX
#define TYPE_HEX
Definition: GmshDefines.h:71
PViewDataList::setXYZV
void setXYZV(std::vector< double > &x, std::vector< double > &y, std::vector< double > &z, std::vector< double > &v)
Definition: PViewDataList.cpp:48
PViewDataList::NbSR
int NbSR
Definition: PViewDataList.h:44
TYPE_TET
#define TYPE_TET
Definition: GmshDefines.h:68
XYZ
Definition: Camera.h:13
PViewDataList::_lastNumValues
int _lastNumValues
Definition: PViewDataList.h:58
PViewDataList::NbTQ
int NbTQ
Definition: PViewDataList.h:32
polynomialBasis
Definition: polynomialBasis.h:16
TYPE_TRIH
#define TYPE_TRIH
Definition: GmshDefines.h:76
PViewDataList::NbVI
int NbVI
Definition: PViewDataList.h:40
PViewDataList::SI
std::vector< double > SI
Definition: PViewDataList.h:41
PViewDataList::_lastXYZ
double * _lastXYZ
Definition: PViewDataList.h:60
PViewDataList::NbVT
int NbVT
Definition: PViewDataList.h:30
PViewDataList::_lastElement
int _lastElement
Definition: PViewDataList.h:57
PViewDataList::getNode
int getNode(int step, int ent, int ele, int nod, double &x, double &y, double &z)
Definition: PViewDataList.cpp:448
PViewDataList::getNumEdges
int getNumEdges(int step, int ent, int ele)
Definition: PViewDataList.cpp:505
PViewDataList::combineTime
bool combineTime(nameData &nd)
Definition: PViewDataList.cpp:832
PViewDataList::NbVQ
int NbVQ
Definition: PViewDataList.h:32
PViewDataList::VI
std::vector< double > VI
Definition: PViewDataList.h:41
PViewDataList::VT
std::vector< double > VT
Definition: PViewDataList.h:31
PViewDataList::SQ
std::vector< double > SQ
Definition: PViewDataList.h:33
PViewDataList::combineSpace
bool combineSpace(nameData &nd)
Definition: PViewDataList.cpp:698
TYPE_POLYH
#define TYPE_POLYH
Definition: GmshDefines.h:73
PViewDataList::NbTD
int NbTD
Definition: PViewDataList.h:46
PViewData::finalize
virtual bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="")
Definition: PViewData.cpp:30
PViewDataList::NbST
int NbST
Definition: PViewDataList.h:30
PViewDataList::NbSY
int NbSY
Definition: PViewDataList.h:42
SmoothData.h
ComputeScalarRep
double ComputeScalarRep(int numComp, double *val, int tensorRep)
Definition: Numeric.cpp:506
BasisFactory.h
PViewDataList::NbTG
int NbTG
Definition: PViewDataList.h:34