gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
MSubElement.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 // Frederic Duboeuf
8 
9 #include "MSubElement.h"
10 #include "Numeric.h"
11 #include "GModel.h"
12 
13 // MSubTetrahedron
14 
16 {
17  if(_pts) delete[] _pts;
18  if(_base) delete _base;
19 }
20 
22 {
24 }
25 
27  bool serendip) const
28 {
29  if(_orig) return _orig->getFunctionSpace(order, serendip);
30  return nullptr;
31 }
32 
34 {
35  if(_orig) return _orig->getJacobianFuncSpace(order);
36  return nullptr;
37 }
38 
39 void MSubTetrahedron::getShapeFunctions(double u, double v, double w,
40  double s[], int order) const
41 {
42  if(_orig) _orig->getShapeFunctions(u, v, w, s, order);
43 }
44 
45 void MSubTetrahedron::getGradShapeFunctions(double u, double v, double w,
46  double s[][3], int order) const
47 {
48  if(_orig) _orig->getGradShapeFunctions(u, v, w, s, order);
49 }
50 
51 void MSubTetrahedron::getHessShapeFunctions(double u, double v, double w,
52  double s[][3][3], int order) const
53 {
54  if(_orig) _orig->getHessShapeFunctions(u, v, w, s, order);
55 }
56 
58  double w,
59  double s[][3][3][3],
60  int order) const
61 {
62  if(_orig) _orig->getThirdDerivativeShapeFunctions(u, v, w, s, order);
63 }
64 
66  double jac[3][3]) const
67 {
68  if(_orig) return _orig->getJacobian(gsf, jac);
69  return 0;
70 }
71 double MSubTetrahedron::getJacobian(const std::vector<SVector3> &gsf,
72  double jac[3][3]) const
73 {
74  if(_orig) return _orig->getJacobian(gsf, jac);
75  return 0;
76 }
77 double MSubTetrahedron::getJacobian(double u, double v, double w,
78  double jac[3][3]) const
79 {
80  if(_orig) return _orig->getJacobian(u, v, w, jac);
81  return 0;
82 }
83 double MSubTetrahedron::getPrimaryJacobian(double u, double v, double w,
84  double jac[3][3]) const
85 {
86  if(_orig) return _orig->getPrimaryJacobian(u, v, w, jac);
87  return 0;
88 }
89 
91 {
92  if(_orig) return _orig->getNumShapeFunctions();
93  return 0;
94 }
95 
97 {
99  return 0;
100 }
101 
103 {
104  if(_orig) return _orig->getShapeFunctionNode(i);
105  return nullptr;
106 }
107 
109 {
110  if(_orig) return _orig->getShapeFunctionNode(i);
111  return nullptr;
112 }
113 
114 void MSubTetrahedron::xyz2uvw(double xyz[3], double uvw[3]) const
115 {
116  if(_orig) _orig->xyz2uvw(xyz, uvw);
117 }
118 
120  double &v,
121  double &w) const
122 {
123  if(!_orig) return;
124  SPoint3 p;
125  _orig->pnt(u, v, w, p);
126  double xyz[3] = {p.x(), p.y(), p.z()};
127  double uvwE[3];
128  getBaseElement()->xyz2uvw(xyz, uvwE);
129  u = uvwE[0];
130  v = uvwE[1];
131  w = uvwE[2];
132 }
133 
135  double &v,
136  double &w) const
137 {
138  if(!_orig) return;
139  SPoint3 p;
140  getBaseElement()->pnt(u, v, w, p);
141  double xyz[3] = {p.x(), p.y(), p.z()};
142  double uvwP[3];
143  _orig->xyz2uvw(xyz, uvwP);
144  u = uvwP[0];
145  v = uvwP[1];
146  w = uvwP[2];
147 }
148 
149 bool MSubTetrahedron::isInside(double u, double v, double w) const
150 {
151  if(!_orig) return false;
152 
153  if(_orig->getDim() != getDim()) { // projection on the base Element
154  SPoint3 p;
155  _orig->pnt(u, v, w, p);
156  double xyz[3] = {p.x(), p.y(), p.z()};
157  double uvwE[3];
158  getBaseElement()->xyz2uvw(xyz, uvwE);
159  SPoint3 pE;
160  getBaseElement()->pnt(uvwE[0], uvwE[1], uvwE[2], pE);
161  double tol = getTolerance();
162  if(fabs(p.x() - pE.x()) > tol) return false;
163  if(fabs(p.y() - pE.y()) > tol) return false;
164  if(fabs(p.z() - pE.z()) > tol) return false;
165  }
166 
168  if(getBaseElement()->isInside(u, v, w)) return true;
169  return false;
170 }
171 
172 void MSubTetrahedron::getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
173 {
174  if(_pts) {
175  if(pOrder == _pOrder) {
176  *npts = _npts;
177  *pts = _pts;
178  return;
179  }
180  else
181  delete[] _pts;
182  }
183 
184  _pOrder = pOrder;
185 
186  if(!_orig) {
188  *npts = _npts;
189  *pts = _pts;
190  return;
191  }
192 
193  // work in the parametric space of the parent element
194  _pts = new IntPt[getNGQTetPts(pOrder)];
195 
196  // (i) get the integration points of the base element in its parametric space
197  IntPt *ptsb;
198  getBaseElement()->getIntegrationPoints(pOrder, &_npts, &ptsb);
199 
200  // (ii) get the coordinates of these points in the parametric space of parent
201  // element
202  double u, v, w;
203  double jac[3][3];
204  double baseJac, origJac;
205  for(int i = 0; i < _npts; ++i) {
206  u = ptsb[i].pt[0];
207  v = ptsb[i].pt[1];
208  w = ptsb[i].pt[2];
209  baseJac = getBaseElement()->getJacobian(u, v, w, jac);
210 
212  origJac = _orig->getJacobian(u, v, w, jac);
213 
214  _pts[i].pt[0] = u;
215  _pts[i].pt[1] = v;
216  _pts[i].pt[2] = w;
217  _pts[i].weight = ptsb[i].weight * baseJac / origJac;
218  }
219  *npts = _npts;
220  *pts = _pts;
221 }
222 
223 // MSubTriangle
224 
226 {
227  if(_pts) delete[] _pts;
228  if(_base) delete _base;
229 }
230 
232 {
234 }
235 
236 const nodalBasis *MSubTriangle::getFunctionSpace(int order, bool serendip) const
237 {
238  if(_orig) return _orig->getFunctionSpace(order, serendip);
239  return nullptr;
240 }
241 
243 {
244  if(_orig) return _orig->getJacobianFuncSpace(order);
245  return nullptr;
246 }
247 
248 void MSubTriangle::getShapeFunctions(double u, double v, double w, double s[],
249  int order) const
250 {
251  if(_orig) _orig->getShapeFunctions(u, v, w, s, order);
252 }
253 
254 void MSubTriangle::getGradShapeFunctions(double u, double v, double w,
255  double s[][3], int order) const
256 {
257  if(!_orig) return;
258 
259  if(_orig->getDim() == getDim())
260  return _orig->getGradShapeFunctions(u, v, w, s, order);
261 
262  std::size_t nsf = getNumShapeFunctions();
263  double gradsuvw[1256][3];
264  _orig->getGradShapeFunctions(u, v, w, gradsuvw, order);
265 
266  // work in the parametric space of the parent element
267  double jac[3][3];
268  double invjac[3][3];
269  _orig->getJacobian(u, v, w, jac);
270  inv3x3(jac, invjac);
271 
272  MEdge edge[2];
273  edge[0] = getBaseElement()->getEdge(0);
274  edge[1] = getBaseElement()->getEdge(1);
275  SVector3 tang[2];
276  tang[0] = edge[0].tangent();
277  tang[1] = edge[1].tangent();
278  SVector3 vect = crossprod(tang[0], tang[1]);
279  tang[1] = crossprod(vect, tang[0]);
280 
281  double gradxyz[3];
282  double projgradxyz[3];
283  for(std::size_t i = 0; i < nsf; ++i) {
284  // (i) get the cartesian coordinates of the gradient
285  gradxyz[0] = invjac[0][0] * gradsuvw[i][0] + invjac[0][1] * gradsuvw[i][1] +
286  invjac[0][2] * gradsuvw[i][2];
287  gradxyz[1] = invjac[1][0] * gradsuvw[i][0] + invjac[1][1] * gradsuvw[i][1] +
288  invjac[1][2] * gradsuvw[i][2];
289  gradxyz[2] = invjac[2][0] * gradsuvw[i][0] + invjac[2][1] * gradsuvw[i][1] +
290  invjac[2][2] * gradsuvw[i][2];
291 
292  // (ii) projection of the gradient on edges in the cartesian space
293  SVector3 grad(&gradxyz[0]);
294  double prodscal[2];
295  prodscal[0] = dot(tang[0], grad);
296  prodscal[1] = dot(tang[1], grad);
297  projgradxyz[0] = prodscal[0] * tang[0].x() + prodscal[1] * tang[1].x();
298  projgradxyz[1] = prodscal[0] * tang[0].y() + prodscal[1] * tang[1].y();
299  projgradxyz[2] = prodscal[0] * tang[0].z() + prodscal[1] * tang[1].z();
300 
301  // (iii) get the parametric coordinates of the projection in the parametric
302  // space of the parent element
303  s[i][0] = jac[0][0] * projgradxyz[0] + jac[0][1] * projgradxyz[1] +
304  jac[0][2] * projgradxyz[2];
305  s[i][1] = jac[1][0] * projgradxyz[0] + jac[1][1] * projgradxyz[1] +
306  jac[1][2] * projgradxyz[2];
307  s[i][2] = jac[2][0] * projgradxyz[0] + jac[2][1] * projgradxyz[1] +
308  jac[2][2] * projgradxyz[2];
309  }
310 }
311 
312 void MSubTriangle::getHessShapeFunctions(double u, double v, double w,
313  double s[][3][3], int order) const
314 {
315  if(_orig) _orig->getHessShapeFunctions(u, v, w, s, order);
316 }
317 
319  double w,
320  double s[][3][3][3],
321  int order) const
322 {
323  if(_orig) _orig->getThirdDerivativeShapeFunctions(u, v, w, s, order);
324 }
325 
327  double jac[3][3]) const
328 {
329  if(_orig) return _orig->getJacobian(gsf, jac);
330  return 0;
331 }
332 double MSubTriangle::getJacobian(const std::vector<SVector3> &gsf,
333  double jac[3][3]) const
334 {
335  if(_orig) return _orig->getJacobian(gsf, jac);
336  return 0;
337 }
338 double MSubTriangle::getJacobian(double u, double v, double w,
339  double jac[3][3]) const
340 {
341  if(_orig) return _orig->getJacobian(u, v, w, jac);
342  return 0;
343 }
344 double MSubTriangle::getPrimaryJacobian(double u, double v, double w,
345  double jac[3][3]) const
346 {
347  if(_orig) return _orig->getPrimaryJacobian(u, v, w, jac);
348  return 0;
349 }
350 
352 {
353  if(_orig) return _orig->getNumShapeFunctions();
354  return 0;
355 }
356 
358 {
360  return 0;
361 }
362 
364 {
365  if(_orig) return _orig->getShapeFunctionNode(i);
366  return nullptr;
367 }
368 
370 {
371  if(_orig) return _orig->getShapeFunctionNode(i);
372  return nullptr;
373 }
374 
375 void MSubTriangle::xyz2uvw(double xyz[3], double uvw[3]) const
376 {
377  if(_orig) _orig->xyz2uvw(xyz, uvw);
378 }
379 
381  double &w) const
382 {
383  if(!_orig) return;
384  SPoint3 p;
385  _orig->pnt(u, v, w, p);
386  double xyz[3] = {p.x(), p.y(), p.z()};
387  double uvwE[3];
388  getBaseElement()->xyz2uvw(xyz, uvwE);
389  u = uvwE[0];
390  v = uvwE[1];
391  w = uvwE[2];
392 }
393 
395  double &w) const
396 {
397  if(!_orig) return;
398  SPoint3 p;
399  getBaseElement()->pnt(u, v, w, p);
400  double xyz[3] = {p.x(), p.y(), p.z()};
401  double uvwP[3];
402  _orig->xyz2uvw(xyz, uvwP);
403  u = uvwP[0];
404  v = uvwP[1];
405  w = uvwP[2];
406 }
407 
408 bool MSubTriangle::isInside(double u, double v, double w) const
409 {
410  if(!_orig) return false;
411 
412  if(_orig->getDim() != getDim()) { // projection on the base Element
413  SPoint3 p;
414  _orig->pnt(u, v, w, p);
415  double xyz[3] = {p.x(), p.y(), p.z()};
416  double uvwE[3];
417  getBaseElement()->xyz2uvw(xyz, uvwE);
418  SPoint3 pE;
419  getBaseElement()->pnt(uvwE[0], uvwE[1], uvwE[2], pE);
420  double tol = getTolerance();
421  if(fabs(p.x() - pE.x()) > tol) return false;
422  if(fabs(p.y() - pE.y()) > tol) return false;
423  if(fabs(p.z() - pE.z()) > tol) return false;
424  }
425 
427  if(getBaseElement()->isInside(u, v, w)) return true;
428  return false;
429 }
430 
431 void MSubTriangle::getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
432 {
433  if(_pts) {
434  if(pOrder == _pOrder) {
435  *npts = _npts;
436  *pts = _pts;
437  return;
438  }
439  else
440  delete[] _pts;
441  }
442 
443  _pOrder = pOrder;
444 
445  if(!_orig) {
447  *npts = _npts;
448  *pts = _pts;
449  return;
450  }
451  // work in the parametric space of the parent element
452  _pts = new IntPt[getNGQTPts(pOrder)];
453 
454  // (i) get the integration points of the base element in its parametric space
455  IntPt *ptsb;
456  getBaseElement()->getIntegrationPoints(pOrder, &_npts, &ptsb);
457 
458  // (ii) get the coordinates of these points in the parametric space of parent
459  // element
460  double u, v, w;
461  double jac[3][3];
462  double baseJac, origJac;
463  for(int i = 0; i < _npts; ++i) {
464  u = ptsb[i].pt[0];
465  v = ptsb[i].pt[1];
466  w = ptsb[i].pt[2];
467  baseJac = getBaseElement()->getJacobian(u, v, w, jac);
468 
470  origJac = _orig->getJacobian(u, v, w, jac);
471 
472  _pts[i].pt[0] = u;
473  _pts[i].pt[1] = v;
474  _pts[i].pt[2] = w;
475  _pts[i].weight = ptsb[i].weight * baseJac / origJac;
476  }
477  *npts = _npts;
478  *pts = _pts;
479 }
480 
481 // MSubLine
482 
484 {
485  if(_pts) delete[] _pts;
486  if(_base) delete _base;
487 }
488 
490 {
492 }
493 
494 const nodalBasis *MSubLine::getFunctionSpace(int order, bool serendip) const
495 {
496  if(_orig) return _orig->getFunctionSpace(order, serendip);
497  return nullptr;
498 }
499 
501 {
502  if(_orig) return _orig->getJacobianFuncSpace(order);
503  return nullptr;
504 }
505 
506 void MSubLine::getShapeFunctions(double u, double v, double w, double s[],
507  int order) const
508 {
509  if(_orig) _orig->getShapeFunctions(u, v, w, s, order);
510 }
511 
512 void MSubLine::getGradShapeFunctions(double u, double v, double w,
513  double s[][3], int order) const
514 {
515  if(!_orig) return;
516 
517  if(_orig->getDim() == getDim())
518  return _orig->getGradShapeFunctions(u, v, w, s, order);
519 
520  std::size_t nsf = _orig->getNumShapeFunctions();
521  double gradsuvw[1256][3];
522  _orig->getGradShapeFunctions(u, v, w, gradsuvw, order);
523 
524  double jac[3][3];
525  double invjac[3][3];
526  _orig->getJacobian(u, v, w, jac);
527  inv3x3(jac, invjac);
528  MEdge edge = getBaseElement()->getEdge(0);
529  SVector3 tang = edge.tangent();
530 
531  double gradxyz[3];
532  double projgradxyz[3];
533  for(std::size_t i = 0; i < nsf; ++i) {
534  // (i) get the cartesian coordinates of the gradient
535  gradxyz[0] = invjac[0][0] * gradsuvw[i][0] + invjac[0][1] * gradsuvw[i][1] +
536  invjac[0][2] * gradsuvw[i][2];
537  gradxyz[1] = invjac[1][0] * gradsuvw[i][0] + invjac[1][1] * gradsuvw[i][1] +
538  invjac[1][2] * gradsuvw[i][2];
539  gradxyz[2] = invjac[2][0] * gradsuvw[i][0] + invjac[2][1] * gradsuvw[i][1] +
540  invjac[2][2] * gradsuvw[i][2];
541 
542  // (ii) projection of the gradient on edges in the cartesian space
543  SVector3 grad(&gradxyz[0]);
544  double prodscal = dot(tang, grad);
545  projgradxyz[0] = prodscal * tang.x();
546  projgradxyz[1] = prodscal * tang.y();
547  projgradxyz[2] = prodscal * tang.z();
548 
549  // (iii) get the parametric coordinates of the projection in the parametric
550  // space of the parent element
551  s[i][0] = jac[0][0] * projgradxyz[0] + jac[0][1] * projgradxyz[1] +
552  jac[0][2] * projgradxyz[2];
553  s[i][1] = jac[1][0] * projgradxyz[0] + jac[1][1] * projgradxyz[1] +
554  jac[1][2] * projgradxyz[2];
555  s[i][2] = jac[2][0] * projgradxyz[0] + jac[2][1] * projgradxyz[1] +
556  jac[2][2] * projgradxyz[2];
557  }
558 }
559 
560 void MSubLine::getHessShapeFunctions(double u, double v, double w,
561  double s[][3][3], int order) const
562 {
563  if(_orig) _orig->getHessShapeFunctions(u, v, w, s, order);
564 }
565 
566 void MSubLine::getThirdDerivativeShapeFunctions(double u, double v, double w,
567  double s[][3][3][3],
568  int order) const
569 {
570  if(_orig) _orig->getThirdDerivativeShapeFunctions(u, v, w, s, order);
571 }
572 
574  double jac[3][3]) const
575 {
576  if(_orig) return _orig->getJacobian(gsf, jac);
577  return 0;
578 }
579 double MSubLine::getJacobian(const std::vector<SVector3> &gsf,
580  double jac[3][3]) const
581 {
582  if(_orig) return _orig->getJacobian(gsf, jac);
583  return 0;
584 }
585 double MSubLine::getJacobian(double u, double v, double w,
586  double jac[3][3]) const
587 {
588  if(_orig) return _orig->getJacobian(u, v, w, jac);
589  return 0;
590 }
591 double MSubLine::getPrimaryJacobian(double u, double v, double w,
592  double jac[3][3]) const
593 {
594  if(_orig) return _orig->getPrimaryJacobian(u, v, w, jac);
595  return 0;
596 }
597 
599 {
600  if(_orig) return _orig->getNumShapeFunctions();
601  return 0;
602 }
603 
605 {
607  return 0;
608 }
609 
611 {
612  if(_orig) return _orig->getShapeFunctionNode(i);
613  return nullptr;
614 }
615 
617 {
618  if(_orig) return _orig->getShapeFunctionNode(i);
619  return nullptr;
620 }
621 
622 void MSubLine::xyz2uvw(double xyz[3], double uvw[3]) const
623 {
624  if(_orig) _orig->xyz2uvw(xyz, uvw);
625 }
626 
628  double &w) const
629 {
630  if(!_orig) return;
631  SPoint3 p;
632  _orig->pnt(u, v, w, p);
633  double xyz[3] = {p.x(), p.y(), p.z()};
634  double uvwE[3];
635  getBaseElement()->xyz2uvw(xyz, uvwE);
636  u = uvwE[0];
637  v = uvwE[1];
638  w = uvwE[2];
639 }
640 
642  double &w) const
643 {
644  if(!_orig) return;
645  SPoint3 p;
646  getBaseElement()->pnt(u, v, w, p);
647  double xyz[3] = {p.x(), p.y(), p.z()};
648  double uvwP[3];
649  _orig->xyz2uvw(xyz, uvwP);
650  u = uvwP[0];
651  v = uvwP[1];
652  w = uvwP[2];
653 }
654 
655 bool MSubLine::isInside(double u, double v, double w) const
656 {
657  if(!_orig) return false;
658 
659  if(_orig->getDim() != getDim()) { // projection on the base Element
660  SPoint3 p;
661  _orig->pnt(u, v, w, p);
662  double xyz[3] = {p.x(), p.y(), p.z()};
663  double uvwE[3];
664  getBaseElement()->xyz2uvw(xyz, uvwE);
665  SPoint3 pE;
666  getBaseElement()->pnt(uvwE[0], uvwE[1], uvwE[2], pE);
667  double tol = getTolerance();
668  if(fabs(p.x() - pE.x()) > tol) return false;
669  if(fabs(p.y() - pE.y()) > tol) return false;
670  if(fabs(p.z() - pE.z()) > tol) return false;
671  }
672 
674  if(getBaseElement()->isInside(u, v, w)) return true;
675  return false;
676 }
677 
678 void MSubLine::getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
679 {
680  if(_pts) {
681  if(pOrder == _pOrder) {
682  *npts = _npts;
683  *pts = _pts;
684  return;
685  }
686  else
687  delete[] _pts;
688  }
689 
690  _pOrder = pOrder;
691 
692  if(!_orig) {
694  *npts = _npts;
695  *pts = _pts;
696  return;
697  }
698 
699  // work in the parametric space of the parent element
700  _pts = new IntPt[getNGQLPts(pOrder)];
701 
702  // (i) get the integration points of the base element in its parametric space
703  IntPt *ptsb;
704  getBaseElement()->getIntegrationPoints(pOrder, &_npts, &ptsb);
705 
706  // (ii) get the coordinates of these points in the parametric space of parent
707  // element
708  double u, v, w;
709  double jac[3][3];
710  double baseJac, origJac;
711  for(int i = 0; i < _npts; ++i) {
712  u = ptsb[i].pt[0];
713  v = ptsb[i].pt[1];
714  w = ptsb[i].pt[2];
715  baseJac = getBaseElement()->getJacobian(u, v, w, jac);
716 
718  origJac = _orig->getJacobian(u, v, w, jac);
719 
720  _pts[i].pt[0] = u;
721  _pts[i].pt[1] = v;
722  _pts[i].pt[2] = w;
723  _pts[i].weight = ptsb[i].weight * baseJac / origJac;
724  }
725  *npts = _npts;
726  *pts = _pts;
727 }
728 
729 // MSubPoint
730 
732 {
733  if(_pts) delete[] _pts;
734  if(_base) delete _base;
735 }
736 
738 {
740 }
741 
742 const nodalBasis *MSubPoint::getFunctionSpace(int order, bool serendip) const
743 {
744  if(_orig) return _orig->getFunctionSpace(order, serendip);
745  return nullptr;
746 }
747 
749 {
750  if(_orig) return _orig->getJacobianFuncSpace(order);
751  return nullptr;
752 }
753 
754 void MSubPoint::getShapeFunctions(double u, double v, double w, double s[],
755  int order) const
756 {
757  if(_orig) _orig->getShapeFunctions(u, v, w, s, order);
758 }
759 
760 void MSubPoint::getGradShapeFunctions(double u, double v, double w,
761  double s[][3], int order) const
762 {
763  if(_orig) _orig->getGradShapeFunctions(u, v, w, s, order);
764 }
765 
766 void MSubPoint::getHessShapeFunctions(double u, double v, double w,
767  double s[][3][3], int order) const
768 {
769  if(_orig) _orig->getHessShapeFunctions(u, v, w, s, order);
770 }
771 
772 void MSubPoint::getThirdDerivativeShapeFunctions(double u, double v, double w,
773  double s[][3][3][3],
774  int order) const
775 {
776  if(_orig) _orig->getThirdDerivativeShapeFunctions(u, v, w, s, order);
777 }
778 
780  double jac[3][3]) const
781 {
782  if(_orig) return _orig->getJacobian(gsf, jac);
783  return 0;
784 }
785 double MSubPoint::getJacobian(const std::vector<SVector3> &gsf,
786  double jac[3][3]) const
787 {
788  if(_orig) return _orig->getJacobian(gsf, jac);
789  return 0;
790 }
791 double MSubPoint::getJacobian(double u, double v, double w,
792  double jac[3][3]) const
793 {
794  if(_orig) return _orig->getJacobian(u, v, w, jac);
795  return 0;
796 }
797 double MSubPoint::getPrimaryJacobian(double u, double v, double w,
798  double jac[3][3]) const
799 {
800  if(_orig) return _orig->getPrimaryJacobian(u, v, w, jac);
801  return 0;
802 }
803 
805 {
806  if(_orig) return _orig->getNumShapeFunctions();
807  return 0;
808 }
809 
811 {
813  return 0;
814 }
815 
817 {
818  if(_orig) return _orig->getShapeFunctionNode(i);
819  return nullptr;
820 }
821 
823 {
824  if(_orig) return _orig->getShapeFunctionNode(i);
825  return nullptr;
826 }
827 
828 void MSubPoint::xyz2uvw(double xyz[3], double uvw[3]) const
829 {
830  if(_orig) _orig->xyz2uvw(xyz, uvw);
831 }
832 
834  double &w) const
835 {
836  if(!_orig) return;
837  SPoint3 p;
838  _orig->pnt(u, v, w, p);
839  double xyz[3] = {p.x(), p.y(), p.z()};
840  double uvwE[3];
841  getBaseElement()->xyz2uvw(xyz, uvwE);
842  u = uvwE[0];
843  v = uvwE[1];
844  w = uvwE[2];
845 }
846 
848  double &w) const
849 {
850  if(!_orig) return;
851  SPoint3 p;
852  getBaseElement()->pnt(u, v, w, p);
853  double xyz[3] = {p.x(), p.y(), p.z()};
854  double uvwP[3];
855  _orig->xyz2uvw(xyz, uvwP);
856  u = uvwP[0];
857  v = uvwP[1];
858  w = uvwP[2];
859 }
860 
861 bool MSubPoint::isInside(double u, double v, double w) const
862 {
863  if(!_orig) return false;
864 
865  if(_orig->getDim() != getDim()) { // projection on the base Element
866  SPoint3 p;
867  _orig->pnt(u, v, w, p);
868  double xyz[3] = {p.x(), p.y(), p.z()};
869  double uvwE[3];
870  getBaseElement()->xyz2uvw(xyz, uvwE);
871  SPoint3 pE;
872  getBaseElement()->pnt(uvwE[0], uvwE[1], uvwE[2], pE);
873  double tol = getTolerance();
874  if(fabs(p.x() - pE.x()) > tol) return false;
875  if(fabs(p.y() - pE.y()) > tol) return false;
876  if(fabs(p.z() - pE.z()) > tol) return false;
877  }
878 
880  if(getBaseElement()->isInside(u, v, w)) return true;
881  return false;
882 }
883 
884 void MSubPoint::getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
885 {
886  // invariable regardless of the order
887  if(!_pts) {
888  if(!_orig) return;
889 
890  _pts = new IntPt[1];
891  // work in the parametric space of the parent element
892  MVertex *vi = getVertex(0);
893  double v_xyz[3] = {vi->x(), vi->y(), vi->z()};
894  double v_uvw[3];
895  _orig->xyz2uvw(v_xyz, v_uvw);
896  double jac[3][3];
897  double origJac = _orig->getJacobian(v_uvw[0], v_uvw[1], v_uvw[2], jac);
898  _pts[0].pt[0] = v_uvw[0];
899  _pts[0].pt[1] = v_uvw[1];
900  _pts[0].pt[2] = v_uvw[2];
901  _pts[0].weight = 1. / origJac;
902  }
903  *npts = 1;
904  *pts = _pts;
905 }
MSubTriangle::getJacobian
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
Definition: MSubElement.cpp:326
MSubTriangle::getShapeFunctions
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
Definition: MSubElement.cpp:248
MSubPoint::getNumPrimaryShapeFunctions
virtual std::size_t getNumPrimaryShapeFunctions() const
Definition: MSubElement.cpp:810
crossprod
SVector3 crossprod(const SVector3 &a, const SVector3 &b)
Definition: SVector3.h:150
MSubTetrahedron::~MSubTetrahedron
~MSubTetrahedron()
Definition: MSubElement.cpp:15
MLine::getDim
virtual int getDim() const
Definition: MLine.h:43
MSubTetrahedron::getJacobianFuncSpace
virtual const JacobianBasis * getJacobianFuncSpace(int order=-1) const
Definition: MSubElement.cpp:33
MSubPoint::getJacobian
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
Definition: MSubElement.cpp:779
MElement::xyz2uvw
virtual void xyz2uvw(double xyz[3], double uvw[3]) const
Definition: MElement.cpp:1128
MSubPoint::movePointFromElementSpaceToParentSpace
virtual void movePointFromElementSpaceToParentSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:847
inv3x3
double inv3x3(double mat[3][3], double inv[3][3])
Definition: Numeric.cpp:232
MElement::getPrimaryJacobian
virtual double getPrimaryJacobian(double u, double v, double w, double jac[3][3]) const
Definition: MElement.cpp:939
MSubPoint::getBaseElement
virtual const MElement * getBaseElement() const
Definition: MSubElement.h:439
MSubPoint::_orig
MElement * _orig
Definition: MSubElement.h:352
MEdge
Definition: MEdge.h:14
MSubPoint::getJacobianFuncSpace
virtual const JacobianBasis * getJacobianFuncSpace(int order=-1) const
Definition: MSubElement.cpp:748
MSubPoint::_orig_N
int _orig_N
Definition: MSubElement.h:353
MSubTriangle::getNumShapeFunctions
virtual std::size_t getNumShapeFunctions() const
Definition: MSubElement.cpp:351
dot
double dot(const SVector3 &a, const SMetric3 &m, const SVector3 &b)
Definition: STensor3.h:71
MSubTriangle::getThirdDerivativeShapeFunctions
virtual void getThirdDerivativeShapeFunctions(double u, double v, double w, double s[][3][3][3], int order=-1) const
Definition: MSubElement.cpp:318
MSubLine::getNumPrimaryShapeFunctions
virtual std::size_t getNumPrimaryShapeFunctions() const
Definition: MSubElement.cpp:604
MElement::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MElement.h:436
MSubPoint::movePointFromParentSpaceToElementSpace
virtual void movePointFromParentSpaceToElementSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:833
MSubPoint::_base
MElement * _base
Definition: MSubElement.h:356
MSubTriangle::movePointFromParentSpaceToElementSpace
virtual void movePointFromParentSpaceToElementSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:380
MVertex
Definition: MVertex.h:24
MElement::getDim
virtual int getDim() const =0
MVertex::z
double z() const
Definition: MVertex.h:62
MSubTetrahedron::movePointFromParentSpaceToElementSpace
virtual void movePointFromParentSpaceToElementSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:119
MSubLine::updateParent
virtual void updateParent(GModel *gm)
Definition: MSubElement.cpp:489
MSubTriangle::getShapeFunctionNode
virtual const MVertex * getShapeFunctionNode(int i) const
Definition: MSubElement.cpp:363
MSubLine::getJacobian
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
Definition: MSubElement.cpp:573
SPoint3
Definition: SPoint3.h:14
MSubTriangle::_npts
int _npts
Definition: MSubElement.h:144
MElement::getThirdDerivativeShapeFunctions
virtual void getThirdDerivativeShapeFunctions(double u, double v, double w, double s[][3][3][3], int order=-1) const
Definition: MElement.cpp:488
MElement::getShapeFunctionNode
virtual const MVertex * getShapeFunctionNode(int i) const
Definition: MElement.h:392
SVector3
Definition: SVector3.h:16
MSubPoint::updateParent
virtual void updateParent(GModel *gm)
Definition: MSubElement.cpp:737
MSubLine::_pOrder
int _pOrder
Definition: MSubElement.h:251
MSubLine::_npts
int _npts
Definition: MSubElement.h:252
MSubTetrahedron::getNumPrimaryShapeFunctions
virtual std::size_t getNumPrimaryShapeFunctions() const
Definition: MSubElement.cpp:96
MSubTriangle::getGradShapeFunctions
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
Definition: MSubElement.cpp:254
MSubTriangle::getBaseElement
virtual const MElement * getBaseElement() const
Definition: MSubElement.h:225
MSubPoint::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MSubElement.cpp:742
MEdge::tangent
SVector3 tangent() const
Definition: MEdge.h:69
MSubTriangle::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MSubElement.cpp:431
MSubTetrahedron::getShapeFunctions
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
Definition: MSubElement.cpp:39
MSubPoint::getShapeFunctions
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
Definition: MSubElement.cpp:754
MSubLine::getNumShapeFunctions
virtual std::size_t getNumShapeFunctions() const
Definition: MSubElement.cpp:598
MSubTetrahedron::_npts
int _npts
Definition: MSubElement.h:34
MElement::getHessShapeFunctions
virtual void getHessShapeFunctions(double u, double v, double w, double s[][3][3], int order=-1) const
Definition: MElement.cpp:478
IntPt::pt
double pt[3]
Definition: GaussIntegration.h:13
MSubPoint::xyz2uvw
virtual void xyz2uvw(double xyz[3], double uvw[3]) const
Definition: MSubElement.cpp:828
MSubTriangle::xyz2uvw
virtual void xyz2uvw(double xyz[3], double uvw[3]) const
Definition: MSubElement.cpp:375
MSubPoint::getGradShapeFunctions
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
Definition: MSubElement.cpp:760
getNGQLPts
int getNGQLPts(int order)
Definition: GaussQuadratureLin.cpp:33
MSubTetrahedron::_pts
IntPt * _pts
Definition: MSubElement.h:35
MSubLine::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MSubElement.cpp:494
MSubPoint::_pts
IntPt * _pts
Definition: MSubElement.h:360
MSubTriangle::movePointFromElementSpaceToParentSpace
virtual void movePointFromElementSpaceToParentSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:394
MTriangle::getDim
virtual int getDim() const
Definition: MTriangle.h:55
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
fullMatrix< double >
MSubLine::getShapeFunctionNode
virtual const MVertex * getShapeFunctionNode(int i) const
Definition: MSubElement.cpp:610
MSubPoint::~MSubPoint
~MSubPoint()
Definition: MSubElement.cpp:731
MElement::getEdge
virtual MEdge getEdge(int num) const =0
MSubElement.h
MSubTetrahedron::getPrimaryJacobian
virtual double getPrimaryJacobian(double u, double v, double w, double jac[3][3]) const
Definition: MSubElement.cpp:83
IntPt::weight
double weight
Definition: GaussIntegration.h:14
getNGQTPts
int getNGQTPts(int order, bool forceTensorRule=false)
Definition: GaussQuadratureTri.cpp:904
MSubTetrahedron::getGradShapeFunctions
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
Definition: MSubElement.cpp:45
MSubTriangle::getJacobianFuncSpace
virtual const JacobianBasis * getJacobianFuncSpace(int order=-1) const
Definition: MSubElement.cpp:242
MSubLine::getGradShapeFunctions
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
Definition: MSubElement.cpp:512
MSubLine::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MSubElement.cpp:678
MSubPoint::isInside
virtual bool isInside(double u, double v, double w) const
Definition: MSubElement.cpp:861
MSubLine::xyz2uvw
virtual void xyz2uvw(double xyz[3], double uvw[3]) const
Definition: MSubElement.cpp:622
MSubTriangle::getNumPrimaryShapeFunctions
virtual std::size_t getNumPrimaryShapeFunctions() const
Definition: MSubElement.cpp:357
MSubTriangle::isInside
virtual bool isInside(double u, double v, double w) const
Definition: MSubElement.cpp:408
MSubTetrahedron::isInside
virtual bool isInside(double u, double v, double w) const
Definition: MSubElement.cpp:149
MSubTriangle::_pts
IntPt * _pts
Definition: MSubElement.h:145
MSubPoint::getThirdDerivativeShapeFunctions
virtual void getThirdDerivativeShapeFunctions(double u, double v, double w, double s[][3][3][3], int order=-1) const
Definition: MSubElement.cpp:772
getNGQTetPts
int getNGQTetPts(int order, bool forceTensorRule=false)
Definition: GaussQuadratureTet.cpp:3362
Numeric.h
GModel
Definition: GModel.h:44
MSubTetrahedron::getHessShapeFunctions
virtual void getHessShapeFunctions(double u, double v, double w, double s[][3][3], int order=-1) const
Definition: MSubElement.cpp:51
MElement::getNumShapeFunctions
virtual std::size_t getNumShapeFunctions() const
Definition: MElement.h:387
MSubTetrahedron::_orig_N
int _orig_N
Definition: MSubElement.h:28
MSubLine::_base
MElement * _base
Definition: MSubElement.h:249
MSubLine::_orig_N
int _orig_N
Definition: MSubElement.h:246
MSubLine::movePointFromElementSpaceToParentSpace
virtual void movePointFromElementSpaceToParentSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:641
MElement::getNumPrimaryShapeFunctions
virtual std::size_t getNumPrimaryShapeFunctions() const
Definition: MElement.h:388
MSubTetrahedron::_orig
MElement * _orig
Definition: MSubElement.h:27
MSubTriangle::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MSubElement.cpp:236
MSubTetrahedron::movePointFromElementSpaceToParentSpace
virtual void movePointFromElementSpaceToParentSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:134
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
MSubTetrahedron::_pOrder
int _pOrder
Definition: MSubElement.h:33
MSubLine::_orig
MElement * _orig
Definition: MSubElement.h:245
MSubTetrahedron::getThirdDerivativeShapeFunctions
virtual void getThirdDerivativeShapeFunctions(double u, double v, double w, double s[][3][3][3], int order=-1) const
Definition: MSubElement.cpp:57
GModel::getMeshElementByTag
MElement * getMeshElementByTag(int n)
Definition: GModel.h:538
MSubPoint::getHessShapeFunctions
virtual void getHessShapeFunctions(double u, double v, double w, double s[][3][3], int order=-1) const
Definition: MSubElement.cpp:766
SVector3::x
double x(void) const
Definition: SVector3.h:30
MSubTetrahedron::updateParent
virtual void updateParent(GModel *gm)
Definition: MSubElement.cpp:21
MSubLine::movePointFromParentSpaceToElementSpace
virtual void movePointFromParentSpaceToElementSpace(double &u, double &v, double &w) const
Definition: MSubElement.cpp:627
MSubLine::getThirdDerivativeShapeFunctions
virtual void getThirdDerivativeShapeFunctions(double u, double v, double w, double s[][3][3][3], int order=-1) const
Definition: MSubElement.cpp:566
MSubTetrahedron::_base
MElement * _base
Definition: MSubElement.h:31
MElement::getTolerance
double getTolerance() const
Definition: MElement.cpp:61
MSubLine::getJacobianFuncSpace
virtual const JacobianBasis * getJacobianFuncSpace(int order=-1) const
Definition: MSubElement.cpp:500
MSubLine::getPrimaryJacobian
virtual double getPrimaryJacobian(double u, double v, double w, double jac[3][3]) const
Definition: MSubElement.cpp:591
MSubLine::getHessShapeFunctions
virtual void getHessShapeFunctions(double u, double v, double w, double s[][3][3], int order=-1) const
Definition: MSubElement.cpp:560
MElement::pnt
virtual void pnt(double u, double v, double w, SPoint3 &p) const
Definition: MElement.cpp:1072
MSubPoint::getPrimaryJacobian
virtual double getPrimaryJacobian(double u, double v, double w, double jac[3][3]) const
Definition: MSubElement.cpp:797
MSubLine::isInside
virtual bool isInside(double u, double v, double w) const
Definition: MSubElement.cpp:655
MSubTetrahedron::getBaseElement
virtual const MElement * getBaseElement() const
Definition: MSubElement.h:117
nodalBasis
Definition: nodalBasis.h:12
IntPt
Definition: GaussIntegration.h:12
MSubTriangle::_pOrder
int _pOrder
Definition: MSubElement.h:143
SVector3::y
double y(void) const
Definition: SVector3.h:31
JacobianBasis
Definition: JacobianBasis.h:60
MTetrahedron::getDim
virtual int getDim() const
Definition: MTetrahedron.h:65
MSubTriangle::getPrimaryJacobian
virtual double getPrimaryJacobian(double u, double v, double w, double jac[3][3]) const
Definition: MSubElement.cpp:344
MSubTriangle::getHessShapeFunctions
virtual void getHessShapeFunctions(double u, double v, double w, double s[][3][3], int order=-1) const
Definition: MSubElement.cpp:312
SVector3::z
double z(void) const
Definition: SVector3.h:32
MElement::getJacobianFuncSpace
virtual const JacobianBasis * getJacobianFuncSpace(int orderElement=-1) const
Definition: MElement.cpp:679
MElement::getShapeFunctions
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
Definition: MElement.cpp:458
MSubLine::~MSubLine
~MSubLine()
Definition: MSubElement.cpp:483
MSubTetrahedron::getShapeFunctionNode
virtual const MVertex * getShapeFunctionNode(int i) const
Definition: MSubElement.cpp:102
MSubPoint::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MSubElement.cpp:884
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
MSubTetrahedron::xyz2uvw
virtual void xyz2uvw(double xyz[3], double uvw[3]) const
Definition: MSubElement.cpp:114
MSubLine::_pts
IntPt * _pts
Definition: MSubElement.h:253
MElement::getJacobian
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
Definition: MElement.cpp:868
MSubTetrahedron::getJacobian
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
Definition: MSubElement.cpp:65
GModel.h
MPoint::getVertex
virtual MVertex * getVertex(int num)
Definition: MPoint.h:33
MSubPoint::getNumShapeFunctions
virtual std::size_t getNumShapeFunctions() const
Definition: MSubElement.cpp:804
MSubTetrahedron::getNumShapeFunctions
virtual std::size_t getNumShapeFunctions() const
Definition: MSubElement.cpp:90
MVertex::y
double y() const
Definition: MVertex.h:61
MElement::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MElement.cpp:666
MSubTriangle::_orig_N
int _orig_N
Definition: MSubElement.h:138
MPoint::getDim
virtual int getDim() const
Definition: MPoint.h:31
MSubTriangle::_base
MElement * _base
Definition: MSubElement.h:141
MSubTriangle::_orig
MElement * _orig
Definition: MSubElement.h:137
MSubLine::getBaseElement
virtual const MElement * getBaseElement() const
Definition: MSubElement.h:332
MSubPoint::getShapeFunctionNode
virtual const MVertex * getShapeFunctionNode(int i) const
Definition: MSubElement.cpp:816
MSubTetrahedron::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MSubElement.cpp:26
MSubTetrahedron::getIntegrationPoints
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MSubElement.cpp:172
MSubTriangle::updateParent
virtual void updateParent(GModel *gm)
Definition: MSubElement.cpp:231
MVertex::x
double x() const
Definition: MVertex.h:60
MSubTriangle::~MSubTriangle
~MSubTriangle()
Definition: MSubElement.cpp:225
MElement::getGradShapeFunctions
virtual void getGradShapeFunctions(double u, double v, double w, double s[][3], int order=-1) const
Definition: MElement.cpp:468
MSubLine::getShapeFunctions
virtual void getShapeFunctions(double u, double v, double w, double s[], int order=-1) const
Definition: MSubElement.cpp:506