basis.h
Go to the documentation of this file.
1 /*
2 This file is part of the Ristra portage project.
3 Please see the license file at the root of this repository, or at:
4  https://github.com/laristra/portage/blob/master/LICENSE
5 */
6 #ifndef PORTAGE_SUPPORT_BASIS_H_
7 #define PORTAGE_SUPPORT_BASIS_H_
8 
9 #include <cassert>
10 #include <cmath>
11 #include <array>
12 #include <vector>
13 
14 // portage includes
16 #include "wonton/support/Point.h"
17 
18 namespace Portage { namespace Meshfree { namespace basis {
19 
21 
22 constexpr std::array<size_t, 4> const quadratic_sizes = {0, 3, 6, 10};
23 
25 // Traits
27 
28 template<Type type, int dim>
29 class Traits {};
30 
31 template<int dim>
32 class Traits<Unitary, dim> {
33 public:
34  static constexpr size_t function_size = 1;
35  static constexpr std::array<size_t, 2> jet_size = {1, 1};
36  using array_t = std::array<double, function_size>;
37  using matrix_t = std::array<std::array<double, function_size>, function_size>;
38 };
39 
40 // this definition completes declaration of the static member
41 template<int dim>
42 constexpr std::array<size_t, 2> Traits<Unitary, dim>::jet_size;
43 
44 template<int dim>
45 class Traits<Linear, dim> {
46 public:
47  static constexpr size_t function_size = dim + 1;
48  static constexpr std::array<size_t, 2> jet_size = {dim + 1, dim + 1};
49  using array_t = std::array<double, function_size>;
50  using matrix_t = std::array<std::array<double, function_size>, function_size>;
51 };
52 
53 // this definition completes declaration of the static member
54 template<int dim>
55 constexpr std::array<size_t, 2> Traits<Linear, dim>::jet_size;
56 
57 template<int dim>
58 class Traits<Quadratic, dim> {
59 public:
60  static constexpr size_t function_size = quadratic_sizes[dim];
61  static constexpr std::array<size_t, 2> jet_size = {function_size, function_size};
62  using array_t = std::array<double, function_size>;
63  using matrix_t = std::array<std::array<double, function_size>, function_size>;
64 };
65 
66 // this definition completes declaration of the static member, see e.g.
67 // stackoverflow.com/questions/8016780/undefined-reference-to-static-constexpr-char
68 // this should be revisited after switching to C++17
69 template<int dim>
70 constexpr std::array<size_t, 2> Traits<Quadratic, dim>::jet_size;
71 
72 template<int dim>
73 size_t function_size(Type btype) {
74  switch (btype) {
78  default: return 0;
79  }
80 }
81 
82 template<int dim>
83 std::array<size_t, 2> jet_size(Type btype) {
84  switch (btype) {
85  case Unitary: return Traits<Unitary, dim>::jet_size;
86  case Linear: return Traits<Linear, dim>::jet_size;
87  case Quadratic: return Traits<Quadratic, dim>::jet_size;
88  default: return {0, 0};
89  }
90 }
91 
93 // Templates
95 
96 template<Type type, size_t dim>
98 function(Wonton::Point<dim> x) { return {}; }
99 
100 template<Type type, size_t dim>
101 std::array<
104 >
105 jet(Wonton::Point<dim> x) { return {}; }
106 
107 template<Type type, size_t dim>
108 std::array<
109  std::array<double, Traits<type, dim>::function_size>,
111 >
112 inverse_jet(Wonton::Point<dim> x) { return {}; }
113 
114 template<Type type, size_t dim>
115 std::array<double, Traits<type, dim>::function_size>
116 shift(Wonton::Point<dim> x, Wonton::Point<dim> y) {
117 
118  auto ijet = inverse_jet<type, dim>(x);
119  auto by = function<type, dim>(y);
120  int const n = Traits<type, dim>::function_size;
121  std::array<double, Traits<type, dim>::function_size> r{0.0};
122 
123  for (int i = 0; i < n; i++) {
124  r[i] = 0.;
125  for (int j = 0; j < n; j++) {
126  r[i] += ijet[i][j] * by[j];
127  }
128  }
129  return r;
130 }
131 
132 template<Type type, size_t dim>
133 typename Traits<type, dim>::matrix_t transfactor(const Wonton::Point<dim>& c) {
134  typename Traits<type, dim>::matrix_t result;
135  assert(false);
136  return result;
137 }
138 
139 template<size_t dim>
140 std::vector<double> function(Type type, Wonton::Point<dim> x) {
141  size_t nbasis = function_size<dim>(type);
142  std::vector<double> result(nbasis);
143  switch (type) {
144  case Unitary: {
145  auto resulta = function<Unitary, dim>(x);
146  for (size_t i = 0; i < nbasis; i++)
147  result[i] = resulta[i];
148  break;
149  }
150  case Linear: {
151  auto resulta = function<Linear, dim>(x);
152  for (size_t i = 0; i < nbasis; i++)
153  result[i] = resulta[i];
154  break;
155  }
156  case Quadratic: {
157  auto resulta = function<Quadratic, dim>(x);
158  for (size_t i = 0; i < nbasis; i++)
159  result[i] = resulta[i];
160  break;
161  }
162  default:
163  assert(false);
164  }
165  return result;
166 }
167 
168 template<size_t dim>
169 std::vector<double> shift(Type type, Wonton::Point<dim> x, Wonton::Point<dim> y) {
170  size_t nbasis = function_size<dim>(type);
171  std::vector<double> result(nbasis);
172  switch (type) {
173  case Unitary: {
174  auto resulta = shift<Unitary, dim>(x, y);
175  for (size_t i = 0; i < nbasis; i++)
176  result[i] = resulta[i];
177  break;
178  }
179  case Linear: {
180  auto resulta = shift<Linear, dim>(x, y);
181  for (size_t i = 0; i < nbasis; i++)
182  result[i] = resulta[i];
183  break;
184  }
185  case Quadratic: {
186  auto resulta = shift<Quadratic, dim>(x, y);
187  for (size_t i = 0; i < nbasis; i++)
188  result[i] = resulta[i];
189  break;
190  }
191  default:
192  assert(false);
193  }
194  return result;
195 }
196 
197 template<size_t dim>
198 std::vector<std::vector<double>> jet(Type type, Wonton::Point<dim> x) {
199  auto njet = jet_size<dim>(type);
200  std::vector<std::vector<double>> result(njet[0], std::vector<double>(njet[1], 0.));
201  switch (type) {
202  case Unitary: {
203  auto resulta = jet<Unitary, dim>(x);
204  for (size_t i = 0; i < njet[0]; i++)
205  for (size_t j = 0; j < njet[1]; j++)
206  result[i][j] = resulta[i][j];
207  break;
208  }
209  case Linear: {
210  auto resulta = jet<Linear, dim>(x);
211  for (size_t i = 0; i < njet[0]; i++)
212  for (size_t j = 0; j < njet[1]; j++)
213  result[i][j] = resulta[i][j];
214  break;
215  }
216  case Quadratic: {
217  auto resulta = jet<Quadratic, dim>(x);
218  for (size_t i = 0; i < njet[0]; i++)
219  for (size_t j = 0; j < njet[1]; j++)
220  result[i][j] = resulta[i][j];
221  break;
222  }
223  default:
224  assert(false);
225  }
226  return result;
227 }
228 
229 template<size_t dim>
230 std::vector<std::vector<double>> inverse_jet(Type type, Wonton::Point<dim> x) {
231  auto njet = jet_size<dim>(type);
232  std::vector<std::vector<double>> result(njet[0], std::vector<double>(njet[1], 0.));
233  switch (type) {
234  case Unitary: {
235  auto resulta = inverse_jet<Unitary, dim>(x);
236  for (size_t i = 0; i < njet[0]; i++)
237  for (size_t j = 0; j < njet[1]; j++)
238  result[i][j] = resulta[i][j];
239  break;
240  }
241  case Linear: {
242  auto resulta = inverse_jet<Linear, dim>(x);
243  for (size_t i = 0; i < njet[0]; i++)
244  for (size_t j = 0; j < njet[1]; j++)
245  result[i][j] = resulta[i][j];
246  break;
247  }
248  case Quadratic: {
249  auto resulta = inverse_jet<Quadratic, dim>(x);
250  for (size_t i = 0; i < njet[0]; i++)
251  for (size_t j = 0; j < njet[1]; j++)
252  result[i][j] = resulta[i][j];
253  break;
254  }
255  default:
256  assert(false);
257  }
258  return result;
259 }
260 
261 template<size_t dim>
262 std::vector<std::vector<double>> transfactor(const Type type, const Wonton::Point<dim>& c) {
263  size_t nbasis = function_size<dim>(type);
264  std::vector<std::vector<double>> result(nbasis, std::vector<double>(nbasis, 0.));
265  switch (type) {
266  case Unitary: {
267  auto tf = transfactor<Unitary, dim>(c);
268  for (size_t i = 0; i < nbasis; i++)
269  for (size_t j = 0; j < nbasis; j++)
270  result[i][j] = tf[i][j];
271  break;
272  }
273  case Linear: {
274  auto tf = transfactor<Linear, dim>(c);
275  for (size_t i = 0; i < nbasis; i++)
276  for (size_t j = 0; j < nbasis; j++)
277  result[i][j] = tf[i][j];
278  break;
279  }
280  case Quadratic: {
281  auto tf = transfactor<Quadratic, dim>(c);
282  for (size_t i = 0; i < nbasis; i++)
283  for (size_t j = 0; j < nbasis; j++)
284  result[i][j] = tf[i][j];
285  break;
286  }
287  default:
288  assert(false);
289  }
290  return result;
291 }
292 
294 // Unitary
296 
297 template<>
298 inline
300 function<Unitary, 1>(Wonton::Point<1> x) {
302  r[0] = 1.;
303  return r;
304 }
305 
306 template<>
307 inline
309 function<Unitary, 2>(Wonton::Point<2> x) {
311  r[0] = 1.;
312  return r;
313 }
314 
315 template<>
316 inline
318 function<Unitary, 3>(Wonton::Point<3> x) {
320  r[0] = 1.;
321  return r;
322 }
323 
324 //---------------------------------------------------------------
325 
326 template<>
327 inline
328 std::array<
331 >
332 jet<Unitary, 1>(Wonton::Point<1> x) {
333  std::array<
334  std::array<double, Traits<Unitary, 1>::function_size>,
336  > r{0.0};
337  r[0][0] = 1.;
338  return r;
339 }
340 
341 template<>
342 inline
343 std::array<
346 >
347 jet<Unitary, 2>(Wonton::Point<2> x) {
348  std::array<
349  std::array<double, Traits<Unitary, 2>::function_size>,
351  > r{0.0};
352  r[0][0] = 1.;
353  return r;
354 }
355 
356 template<>
357 inline
358 std::array<
361 >
362 jet<Unitary, 3>(Wonton::Point<3> x) {
363  std::array<
364  std::array<double, Traits<Unitary, 3>::function_size>,
366  > r{0.0};
367  r[0][0] = 1.;
368  return r;
369 }
370 
371 //---------------------------------------------------------------
372 
373 template<>
374 inline
375 std::array<
376  std::array<double, Traits<Unitary, 1>::function_size>,
378 >
379 inverse_jet<Unitary, 1>(Wonton::Point<1> x) {
380  std::array<
381  std::array<double, Traits<Unitary, 1>::function_size>,
383  > r{0.0};
384  r[0][0] = 1.;
385  return r;
386 }
387 
388 template<>
389 inline
390 std::array<
391  std::array<double, Traits<Unitary, 2>::function_size>,
393 >
394 inverse_jet<Unitary, 2>(Wonton::Point<2> x) {
395  std::array<
396  std::array<double, Traits<Unitary, 2>::function_size>,
398  > r{0.0};
399  r[0][0] = 1.;
400  return r;
401 }
402 
403 template<>
404 inline
405 std::array<
406  std::array<double, Traits<Unitary, 3>::function_size>,
408 >
409 inverse_jet<Unitary, 3>(Wonton::Point<3> x) {
410  std::array<
411  std::array<double, Traits<Unitary, 3>::function_size>,
413  > r{0.0};
414  r[0][0] = 1.;
415  return r;
416 }
417 
418 //---------------------------------------------------------------
419 
420 template<>
421 inline
422 std::array<double, Traits<Unitary, 1>::function_size>
423 shift<Unitary, 1>(Wonton::Point<1> x, Wonton::Point<1> y) {
424  std::array<double, Traits<Unitary, 1>::function_size> r{0.0};
425  r[0] = 1.;
426  return r;
427 }
428 
429 template<>
430 inline
431 std::array<double, Traits<Unitary, 2>::function_size>
432 shift<Unitary, 2>(Wonton::Point<2> x, Wonton::Point<2> y) {
433  std::array<double, Traits<Unitary, 2>::function_size> r{0.0};
434  r[0] = 1.;
435  return r;
436 }
437 
438 template<>
439 inline
440 std::array<double, Traits<Unitary, 3>::function_size>
441 shift<Unitary, 3>(Wonton::Point<3> x, Wonton::Point<3> y) {
442  std::array<double, Traits<Unitary, 3>::function_size> r{0.0};
443  r[0] = 1.;
444  return r;
445 }
446 
447 //---------------------------------------------------------------
448 
449 template<>
450 inline
451 typename Traits<Unitary, 1>::matrix_t transfactor<Unitary, 1>(const Wonton::Point<1>& c) {
452  typename Traits<Unitary, 1>::matrix_t tf;
453  tf[0][0] = 1.;
454  return tf;
455 }
456 
457 template<>
458 inline
459 typename Traits<Unitary, 2>::matrix_t transfactor<Unitary, 2>(const Wonton::Point<2>& c) {
460  typename Traits<Unitary, 2>::matrix_t tf;
461  tf[0][0] = 1.;
462  return tf;
463 }
464 
465 template<>
466 inline
467 typename Traits<Unitary, 3>::matrix_t transfactor<Unitary, 3>(const Wonton::Point<3>& c) {
468  typename Traits<Unitary, 3>::matrix_t tf;
469  tf[0][0] = 1.;
470  return tf;
471 }
472 
474 // Linear
476 
477 template<>
478 inline
480 function<Linear, 1>(Wonton::Point<1> x) {
482  r[0] = 1.;
483  r[1] = x[0];
484  return r;
485 }
486 
487 template<>
488 inline
490 function<Linear, 2>(Wonton::Point<2> x) {
492  r[0] = 1.;
493  r[1] = x[0];
494  r[2] = x[1];
495  return r;
496 }
497 
498 template<>
499 inline
501 function<Linear, 3>(Wonton::Point<3> x) {
503  r[0] = 1.;
504  r[1] = x[0];
505  r[2] = x[1];
506  r[3] = x[2];
507  return r;
508 }
509 
510 //---------------------------------------------------------------
511 
512 template<>
513 inline
514 std::array<
517 >
518 jet<Linear, 1>(Wonton::Point<1> x) {
519  std::array<
520  std::array<double, Traits<Linear, 1>::function_size>,
522  > r{0.0};
523  r[0][0] = 1.;
524  r[1][0] = x[0];
525  r[0][1] = 0.;
526  r[1][1] = 1.;
527  return r;
528 }
529 
530 template<>
531 inline
532 std::array<
535 >
536 jet<Linear, 2>(Wonton::Point<2> x) {
537  std::array<
538  std::array<double, Traits<Linear, 2>::function_size>,
540  > r{0.0};
541  r[0][0] = 1.;
542  r[1][0] = x[0];
543  r[2][0] = x[1];
544  r[0][1] = 0.;
545  r[1][1] = 1.;
546  r[2][1] = 0.;
547  r[0][2] = 0.;
548  r[1][2] = 0.;
549  r[2][2] = 1.;
550  return r;
551 }
552 
553 template<>
554 inline
555 std::array<
558 >
559 jet<Linear, 3>(Wonton::Point<3> x) {
560  std::array<
561  std::array<double, Traits<Linear, 3>::function_size>,
563  > r{0.0};
564  r[0][0] = 1.;
565  r[1][0] = x[0];
566  r[2][0] = x[1];
567  r[3][0] = x[2];
568  r[0][1] = 0.;
569  r[1][1] = 1.;
570  r[2][1] = 0.;
571  r[3][1] = 0.;
572  r[0][2] = 0.;
573  r[1][2] = 0.;
574  r[2][2] = 1.;
575  r[3][2] = 0.;
576  r[0][3] = 0.;
577  r[1][3] = 0.;
578  r[2][3] = 0.;
579  r[3][3] = 1.;
580  return r;
581 }
582 
583 //---------------------------------------------------------------
584 
585 template<>
586 inline
587 std::array<
588  std::array<double, Traits<Linear, 1>::function_size>,
590 >
591 inverse_jet<Linear, 1>(Wonton::Point<1> x) {
592  std::array<
593  std::array<double, Traits<Linear, 1>::function_size>,
595  > r{0.0};
596  r[0][0] = 1.;
597  r[1][0] = -x[0];
598  r[0][1] = 0.;
599  r[1][1] = 1.;
600  return r;
601 }
602 
603 template<>
604 inline
605 std::array<
606  std::array<double, Traits<Linear, 2>::function_size>,
608 >
609 inverse_jet<Linear, 2>(Wonton::Point<2> x) {
610  std::array<
611  std::array<double, Traits<Linear, 2>::function_size>,
613  > r{0.0};
614  r[0][0] = 1.;
615  r[1][0] = -x[0];
616  r[2][0] = -x[1];
617  r[0][1] = 0.;
618  r[1][1] = 1.;
619  r[2][1] = 0.;
620  r[0][2] = 0.;
621  r[1][2] = 0.;
622  r[2][2] = 1.;
623  return r;
624 }
625 
626 template<>
627 inline
628 std::array<
629  std::array<double, Traits<Linear, 3>::function_size>,
631 >
632 inverse_jet<Linear, 3>(Wonton::Point<3> x) {
633  std::array<
634  std::array<double, Traits<Linear, 3>::function_size>,
636  > r{0.0};
637  r[0][0] = 1.;
638  r[1][0] = -x[0];
639  r[2][0] = -x[1];
640  r[3][0] = -x[2];
641  r[0][1] = 0.;
642  r[1][1] = 1.;
643  r[2][1] = 0.;
644  r[3][1] = 0.;
645  r[0][2] = 0.;
646  r[1][2] = 0.;
647  r[2][2] = 1.;
648  r[3][2] = 0.;
649  r[0][3] = 0.;
650  r[1][3] = 0.;
651  r[2][3] = 0.;
652  r[3][3] = 1.;
653  return r;
654 }
655 
656 //---------------------------------------------------------------
657 
658 template<>
659 inline
660 std::array<double, Traits<Linear, 1>::function_size>
661 shift<Linear, 1>(Wonton::Point<1> x, Wonton::Point<1> y) {
662  std::array<double, Traits<Linear, 1>::function_size> r{0.0};
663  r[0] = 1.;
664  r[1] = y[0] - x[0];
665  return r;
666 }
667 
668 template<>
669 inline
670 std::array<double, Traits<Linear, 2>::function_size>
671 shift<Linear, 2>(Wonton::Point<2> x, Wonton::Point<2> y) {
672  std::array<double, Traits<Linear, 2>::function_size> r{0.0};
673  r[0] = 1.;
674  r[1] = y[0] - x[0];
675  r[2] = y[1] - x[1];
676  return r;
677 }
678 
679 template<>
680 inline
681 std::array<double, Traits<Linear, 3>::function_size>
682 shift<Linear, 3>(Wonton::Point<3> x, Wonton::Point<3> y) {
683  std::array<double, Traits<Linear, 3>::function_size> r{0.0};
684  r[0] = 1.;
685  r[1] = y[0] - x[0];
686  r[2] = y[1] - x[1];
687  r[3] = y[2] - x[2];
688  return r;
689 }
690 
691 //---------------------------------------------------------------
692 
693 template<>
694 inline
695 typename Traits<Linear, 1>::matrix_t transfactor<Linear, 1>(const Wonton::Point<1>& c) {
696  typename Traits<Linear, 1>::matrix_t tf;
697  tf[0][0] = 1;
698  tf[0][1] = 0;
699  tf[1][0] = c[0];
700  tf[1][1] = 1;
701  return tf;
702 }
703 
704 template<>
705 inline
706 typename Traits<Linear, 2>::matrix_t transfactor<Linear, 2>(const Wonton::Point<2>& c) {
707  typename Traits<Linear, 2>::matrix_t tf;
708  tf[0][0] = 1;
709  tf[0][1] = 0;
710  tf[0][2] = 0;
711  tf[1][0] = c[0];
712  tf[1][1] = 1;
713  tf[1][2] = 0;
714  tf[2][0] = c[1];
715  tf[2][1] = 0;
716  tf[2][2] = 1;
717  return tf;
718 }
719 
720 template<>
721 inline
722 typename Traits<Linear, 3>::matrix_t transfactor<Linear, 3>(const Wonton::Point<3>& c) {
723  typename Traits<Linear, 3>::matrix_t tf;
724  tf[0][0] = 1;
725  tf[0][1] = 0;
726  tf[0][2] = 0;
727  tf[0][3] = 0;
728  tf[1][0] = c[0];
729  tf[1][1] = 1;
730  tf[1][2] = 0;
731  tf[1][3] = 0;
732  tf[2][0] = c[1];
733  tf[2][1] = 0;
734  tf[2][2] = 1;
735  tf[2][3] = 0;
736  tf[3][0] = c[2];
737  tf[3][1] = 0;
738  tf[3][2] = 0;
739  tf[3][3] = 1;
740  return tf;
741 }
742 
744 // Quadratic
746 
747 template<>
748 inline
750 function<Quadratic, 1>(Wonton::Point<1> x) {
752  r[0] = 1.;
753  r[1] = x[0];
754  r[2] = .5 * x[0] * x[0];
755  return r;
756 }
757 
758 template<>
759 inline
761 function<Quadratic, 2>(Wonton::Point<2> x) {
763  r[0] = 1.;
764  r[1] = x[0];
765  r[2] = x[1];
766  r[3] = .5 * x[0] * x[0];
767  r[4] = x[0] * x[1];
768  r[5] = .5 * x[1] * x[1];
769  return r;
770 }
771 
772 template<>
773 inline
775 function<Quadratic, 3>(Wonton::Point<3> x) {
777  r[0] = 1.;
778  r[1] = x[0];
779  r[2] = x[1];
780  r[3] = x[2];
781  r[4] = .5 * x[0] * x[0];
782  r[5] = x[0] * x[1];
783  r[6] = x[0] * x[2];
784  r[7] = .5 * x[1] * x[1];
785  r[8] = x[1] * x[2];
786  r[9] = .5 * x[2] * x[2];
787  return r;
788 }
789 
790 //---------------------------------------------------------------
791 
792 template<>
793 inline
794 std::array<
797 >
798 jet<Quadratic, 1>(Wonton::Point<1> x) {
799  std::array<
800  std::array<double, Traits<Quadratic, 1>::function_size>,
802  > r{0.0};
803  r[0][0] = 1.;
804 
805  r[1][0] = x[0];
806  r[1][1] = 1.;
807 
808  r[2][0] = x[0] * x[0] * .5;
809  r[2][1] = x[0];
810  r[2][2] = 1.;
811  return r;
812 }
813 
814 template<>
815 inline
816 std::array<
819 >
820 jet<Quadratic, 2>(Wonton::Point<2> x) {
821  std::array<
822  std::array<double, Traits<Quadratic, 2>::function_size>,
824  > r{0.0};
825  r[0][0] = 1.;
826  r[1][0] = x[0];
827  r[2][0] = x[1];
828  r[3][0] = .5 * x[0] * x[0];
829  r[4][0] = x[0] * x[1];
830  r[5][0] = .5 * x[1] * x[1];
831 
832  r[1][1] = 1.;
833  r[3][1] = x[0];
834  r[4][1] = x[1];
835 
836  r[2][2] = 1.;
837  r[4][2] = x[0];
838  r[5][2] = x[1];
839 
840  for (size_t i = 3; i < 6; i++)
841  r[i][i] = 1.;
842  return r;
843 }
844 
845 template<>
846 inline
847 std::array<
850 >
851 jet<Quadratic, 3>(Wonton::Point<3> x) {
852  std::array<
853  std::array<double, Traits<Quadratic, 3>::function_size>,
855  > r{0.0};
856  r[0][0] = 1.;
857  r[1][0] = x[0];
858  r[2][0] = x[1];
859  r[3][0] = x[2];
860  r[4][0] = .5 * x[0] * x[0];
861  r[5][0] = x[0] * x[1];
862  r[6][0] = x[0] * x[2];
863  r[7][0] = .5 * x[1] * x[1];
864  r[8][0] = x[1] * x[2];
865  r[9][0] = .5 * x[2] * x[2];
866 
867  r[1][1] = 1.;
868  r[4][1] = x[0];
869  r[5][1] = x[1];
870  r[6][1] = x[2];
871 
872  r[2][2] = 1.;
873  r[5][2] = x[0];
874  r[7][2] = x[1];
875  r[8][2] = x[2];
876 
877  r[3][3] = 1.;
878  r[6][3] = x[0];
879  r[8][3] = x[1];
880  r[9][3] = x[2];
881 
882  for (size_t i = 4; i < 10; i++)
883  r[i][i] = 1.;
884  return r;
885 }
886 
887 //---------------------------------------------------------------
888 
889 template<>
890 inline
891 std::array<
892  std::array<double, Traits<Quadratic, 1>::function_size>,
894 >
895 inverse_jet<Quadratic, 1>(Wonton::Point<1> x) {
896  Wonton::Point<1> mx;
897  for (size_t i = 0; i < 1; i++) mx[i] = -x[i];
898  return jet<Quadratic, 1>(mx);
899 }
900 
901 template<>
902 inline
903 std::array<
904  std::array<double, Traits<Quadratic, 2>::function_size>,
906 >
907 inverse_jet<Quadratic, 2>(Wonton::Point<2> x) {
908  Wonton::Point<2> mx;
909  for (size_t i = 0; i < 2; i++) mx[i] = -x[i];
910  return jet<Quadratic, 2>(mx);
911 }
912 
913 template<>
914 inline
915 std::array<
916  std::array<double, Traits<Quadratic, 3>::function_size>,
918 >
919 inverse_jet<Quadratic, 3>(Wonton::Point<3> x) {
920  Wonton::Point<3> mx;
921  for (size_t i = 0; i < 3; i++) mx[i] = -x[i];
922  return jet<Quadratic, 3>(mx);
923 }
924 
925 //---------------------------------------------------------------
926 
927 template<>
928 inline
929 std::array<double, Traits<Quadratic, 1>::function_size>
930 shift<Quadratic, 1>(Wonton::Point<1> x, Wonton::Point<1> y) {
931  Wonton::Point<1> d;
932  for (size_t i = 0; i < 1; i++) d[i] = y[i] - x[i];
933  return function<Quadratic, 1>(d);
934 }
935 
936 template<>
937 inline
938 std::array<double, Traits<Quadratic, 2>::function_size>
939 shift<Quadratic, 2>(Wonton::Point<2> x, Wonton::Point<2> y) {
940  Wonton::Point<2> d;
941  for (size_t i = 0; i < 2; i++) d[i] = y[i] - x[i];
942  return function<Quadratic, 2>(d);
943 }
944 
945 template<>
946 inline
947 std::array<double, Traits<Quadratic, 3>::function_size>
948 shift<Quadratic, 3>(Wonton::Point<3> x, Wonton::Point<3> y) {
949  Wonton::Point<3> d;
950  for (size_t i = 0; i < 3; i++) d[i] = y[i] - x[i];
951  return function<Quadratic, 3>(d);
952 }
953 
954 //---------------------------------------------------------------
955 
956 template<>
957 inline
958 typename Traits<Quadratic, 1>::matrix_t transfactor<Quadratic, 1>(const Wonton::Point<1>& c) {
959  typename Traits<Quadratic, 1>::matrix_t tf;
960  tf[0] = { 1, 0, 0 };
961  tf[1] = { c[0], 1, 0 };
962  tf[2] = { 0.5 * c[0] * c[0], c[0], 1 };
963  return tf;
964 }
965 
966 template<>
967 inline
968 typename Traits<Quadratic, 2>::matrix_t transfactor<Quadratic, 2>(const Wonton::Point<2>& c) {
969  typename Traits<Quadratic, 2>::matrix_t tf;
970  tf[0] = { 1, 0, 0, 0, 0, 0 };
971  tf[1] = { c[0], 1, 0, 0, 0, 0 };
972  tf[2] = { c[1], 0, 1, 0, 0, 0 };
973  tf[3] = { 0.5 * c[0] * c[0], c[0], 0, 1, 0, 0 };
974  tf[4] = { c[0] * c[1], c[1], c[0], 0, 1, 0 };
975  tf[5] = { 0.5 * c[1] * c[1], 0, c[1], 0, 0, 1 };
976  return tf;
977 }
978 
979 template<>
980 inline
981 typename Traits<Quadratic, 3>::matrix_t transfactor<Quadratic, 3>(const Wonton::Point<3>& c) {
982  typename Traits<Quadratic, 3>::matrix_t tf;
983  tf[0] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
984  tf[1] = { c[0], 1, 0, 0, 0, 0, 0, 0, 0, 0 };
985  tf[2] = { c[1], 0, 1, 0, 0, 0, 0, 0, 0, 0 };
986  tf[3] = { c[2], 0, 0, 1, 0, 0, 0, 0, 0, 0 };
987  tf[4] = { 0.5 * c[0] * c[0], c[0], 0, 0, 1, 0, 0, 0, 0, 0 };
988  tf[5] = { c[0] * c[1], c[1], c[0], 0, 0, 1, 0, 0, 0, 0 };
989  tf[6] = { c[0] * c[2], c[2], 0, c[0], 0, 0, 1, 0, 0, 0 };
990  tf[7] = { 0.5 * c[1] * c[1], 0, c[1], 0, 0, 0, 0, 1, 0, 0 };
991  tf[8] = { c[1] * c[2], 0, c[2], c[1], 0, 0, 0, 0, 1, 0 };
992  tf[9] = { 0.5 * c[2] * c[2], 0, 0, c[2], 0, 0, 0, 0, 0, 1 };
993  return tf;
994 }
995 
996 }}} // namespace Portage::Meshfree::Basis
997 
998 #endif // PORTAGE_SUPPORT_BASIS_H_
std::array< double, Traits< Linear, 2 >::function_size > function< Linear, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:490
std::array< std::array< double, Traits< Linear, 1 >::function_size >, Traits< Linear, 1 >::function_size > jet< Linear, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:518
std::array< double, Traits< Linear, 2 >::function_size > shift< Linear, 2 >(Wonton::Point< 2 > x, Wonton::Point< 2 > y)
Definition: basis.h:671
std::array< std::array< double, Traits< Quadratic, 1 >::function_size >, Traits< Quadratic, 1 >::function_size > jet< Quadratic, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:798
std::array< double, Traits< Linear, 1 >::function_size > shift< Linear, 1 >(Wonton::Point< 1 > x, Wonton::Point< 1 > y)
Definition: basis.h:661
std::array< double, Traits< Quadratic, 2 >::function_size > function< Quadratic, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:761
Definition: basis.h:29
std::array< double, Traits< type, dim >::function_size > shift(Wonton::Point< dim > x, Wonton::Point< dim > y)
Definition: basis.h:116
Traits< Unitary, 3 >::matrix_t transfactor< Unitary, 3 >(const Wonton::Point< 3 > &c)
Definition: basis.h:467
Traits< Linear, 2 >::matrix_t transfactor< Linear, 2 >(const Wonton::Point< 2 > &c)
Definition: basis.h:706
std::array< std::array< double, Traits< Unitary, 3 >::function_size >, Traits< Unitary, 3 >::function_size > inverse_jet< Unitary, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:409
std::array< std::array< double, Traits< Unitary, 2 >::function_size >, Traits< Unitary, 2 >::function_size > jet< Unitary, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:347
std::array< std::array< double, Traits< Unitary, 3 >::function_size >, Traits< Unitary, 3 >::function_size > jet< Unitary, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:362
Traits< Linear, 3 >::matrix_t transfactor< Linear, 3 >(const Wonton::Point< 3 > &c)
Definition: basis.h:722
std::array< std::array< double, Traits< Quadratic, 1 >::function_size >, Traits< Quadratic, 1 >::function_size > inverse_jet< Quadratic, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:895
std::array< double, Traits< Linear, 3 >::function_size > function< Linear, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:501
std::array< double, Traits< Unitary, 3 >::function_size > shift< Unitary, 3 >(Wonton::Point< 3 > x, Wonton::Point< 3 > y)
Definition: basis.h:441
std::array< double, Traits< Linear, 1 >::function_size > function< Linear, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:480
std::array< double, Traits< Unitary, 3 >::function_size > function< Unitary, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:318
std::array< double, function_size > array_t
Definition: basis.h:62
std::array< std::array< double, Traits< Linear, 3 >::function_size >, Traits< Linear, 3 >::function_size > jet< Linear, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:559
std::array< std::array< double, Traits< Linear, 3 >::function_size >, Traits< Linear, 3 >::function_size > inverse_jet< Linear, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:632
std::array< std::array< double, Traits< Linear, 1 >::function_size >, Traits< Linear, 1 >::function_size > inverse_jet< Linear, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:591
Definition: basis.h:20
size_t function_size(Type btype)
Definition: basis.h:73
std::array< std::array< double, Traits< Unitary, 1 >::function_size >, Traits< Unitary, 1 >::function_size > inverse_jet< Unitary, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:379
std::array< size_t, 2 > jet_size(Type btype)
Definition: basis.h:83
Traits< Quadratic, 2 >::matrix_t transfactor< Quadratic, 2 >(const Wonton::Point< 2 > &c)
Definition: basis.h:968
std::array< std::array< double, Traits< Quadratic, 3 >::function_size >, Traits< Quadratic, 3 >::function_size > inverse_jet< Quadratic, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:919
std::array< std::array< double, Traits< Unitary, 1 >::function_size >, Traits< Unitary, 1 >::function_size > jet< Unitary, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:332
Type
Definition: basis.h:20
Definition: basis.h:20
std::array< std::array< double, Traits< Linear, 2 >::function_size >, Traits< Linear, 2 >::function_size > inverse_jet< Linear, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:609
std::array< std::array< double, Traits< Unitary, 2 >::function_size >, Traits< Unitary, 2 >::function_size > inverse_jet< Unitary, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:394
std::array< double, Traits< Unitary, 1 >::function_size > shift< Unitary, 1 >(Wonton::Point< 1 > x, Wonton::Point< 1 > y)
Definition: basis.h:423
std::array< std::array< double, Traits< Linear, 2 >::function_size >, Traits< Linear, 2 >::function_size > jet< Linear, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:536
std::array< double, Traits< Quadratic, 1 >::function_size > function< Quadratic, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:750
Traits< Unitary, 2 >::matrix_t transfactor< Unitary, 2 >(const Wonton::Point< 2 > &c)
Definition: basis.h:459
Traits< type, dim >::matrix_t transfactor(const Wonton::Point< dim > &c)
Definition: basis.h:133
Traits< Quadratic, 3 >::matrix_t transfactor< Quadratic, 3 >(const Wonton::Point< 3 > &c)
Definition: basis.h:981
std::array< std::array< double, function_size >, function_size > matrix_t
Definition: basis.h:63
Definition: coredriver.h:42
std::array< std::array< double, Traits< Quadratic, 2 >::function_size >, Traits< Quadratic, 2 >::function_size > inverse_jet< Quadratic, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:907
std::array< double, Traits< Quadratic, 3 >::function_size > shift< Quadratic, 3 >(Wonton::Point< 3 > x, Wonton::Point< 3 > y)
Definition: basis.h:948
std::array< double, function_size > array_t
Definition: basis.h:36
constexpr std::array< size_t, 4 > const quadratic_sizes
Definition: basis.h:22
std::array< double, Traits< Unitary, 2 >::function_size > function< Unitary, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:309
std::array< double, Traits< Linear, 3 >::function_size > shift< Linear, 3 >(Wonton::Point< 3 > x, Wonton::Point< 3 > y)
Definition: basis.h:682
std::array< std::array< double, function_size >, function_size > matrix_t
Definition: basis.h:37
std::array< std::array< double, Traits< type, dim >::function_size >, Traits< type, dim >::function_size > inverse_jet(Wonton::Point< dim > x)
Definition: basis.h:112
std::array< std::array< double, Traits< Quadratic, 3 >::function_size >, Traits< Quadratic, 3 >::function_size > jet< Quadratic, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:851
std::array< double, Traits< Quadratic, 3 >::function_size > function< Quadratic, 3 >(Wonton::Point< 3 > x)
Definition: basis.h:775
std::array< std::array< double, function_size >, function_size > matrix_t
Definition: basis.h:50
Traits< Linear, 1 >::matrix_t transfactor< Linear, 1 >(const Wonton::Point< 1 > &c)
Definition: basis.h:695
std::array< double, Traits< Quadratic, 1 >::function_size > shift< Quadratic, 1 >(Wonton::Point< 1 > x, Wonton::Point< 1 > y)
Definition: basis.h:930
std::array< std::array< double, Traits< type, dim >::function_size >, Traits< type, dim >::function_size > jet(Wonton::Point< dim > x)
Definition: basis.h:105
std::array< double, Traits< Unitary, 2 >::function_size > shift< Unitary, 2 >(Wonton::Point< 2 > x, Wonton::Point< 2 > y)
Definition: basis.h:432
Traits< Unitary, 1 >::matrix_t transfactor< Unitary, 1 >(const Wonton::Point< 1 > &c)
Definition: basis.h:451
std::array< double, function_size > array_t
Definition: basis.h:49
Traits< Quadratic, 1 >::matrix_t transfactor< Quadratic, 1 >(const Wonton::Point< 1 > &c)
Definition: basis.h:958
std::array< double, Traits< Unitary, 1 >::function_size > function< Unitary, 1 >(Wonton::Point< 1 > x)
Definition: basis.h:300
std::array< std::array< double, Traits< Quadratic, 2 >::function_size >, Traits< Quadratic, 2 >::function_size > jet< Quadratic, 2 >(Wonton::Point< 2 > x)
Definition: basis.h:820
std::array< double, Traits< Quadratic, 2 >::function_size > shift< Quadratic, 2 >(Wonton::Point< 2 > x, Wonton::Point< 2 > y)
Definition: basis.h:939