6 #ifndef PORTAGE_SUPPORT_BASIS_H_ 7 #define PORTAGE_SUPPORT_BASIS_H_ 16 #include "wonton/support/Point.h" 18 namespace Portage {
namespace Meshfree {
namespace basis {
28 template<Type type,
int dim>
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>;
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>;
62 using array_t = std::array<double, function_size>;
63 using matrix_t = std::array<std::array<double, function_size>, function_size>;
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};
96 template<Type type,
size_t dim>
98 function(Wonton::Point<dim> x) {
return {}; }
100 template<Type type,
size_t dim>
105 jet(Wonton::Point<dim> x) {
return {}; }
107 template<Type type,
size_t dim>
109 std::array<double, Traits<type, dim>::function_size>,
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) {
118 auto ijet = inverse_jet<type, dim>(x);
119 auto by = function<type, dim>(y);
121 std::array<double, Traits<type, dim>::function_size> r{0.0};
123 for (
int i = 0; i < n; i++) {
125 for (
int j = 0; j < n; j++) {
126 r[i] += ijet[i][j] * by[j];
132 template<Type type,
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);
145 auto resulta = function<Unitary, dim>(x);
146 for (
size_t i = 0; i < nbasis; i++)
147 result[i] = resulta[i];
151 auto resulta = function<Linear, dim>(x);
152 for (
size_t i = 0; i < nbasis; i++)
153 result[i] = resulta[i];
157 auto resulta = function<Quadratic, dim>(x);
158 for (
size_t i = 0; i < nbasis; i++)
159 result[i] = resulta[i];
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);
174 auto resulta = shift<Unitary, dim>(x, y);
175 for (
size_t i = 0; i < nbasis; i++)
176 result[i] = resulta[i];
180 auto resulta = shift<Linear, dim>(x, y);
181 for (
size_t i = 0; i < nbasis; i++)
182 result[i] = resulta[i];
186 auto resulta = shift<Quadratic, dim>(x, y);
187 for (
size_t i = 0; i < nbasis; i++)
188 result[i] = resulta[i];
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.));
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];
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];
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];
231 auto njet = jet_size<dim>(type);
232 std::vector<std::vector<double>> result(njet[0], std::vector<double>(njet[1], 0.));
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];
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];
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];
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.));
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];
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];
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];
334 std::array<double, Traits<Unitary, 1>::function_size>,
349 std::array<double, Traits<Unitary, 2>::function_size>,
364 std::array<double, Traits<Unitary, 3>::function_size>,
376 std::array<double, Traits<Unitary, 1>::function_size>,
381 std::array<double, Traits<Unitary, 1>::function_size>,
391 std::array<double, Traits<Unitary, 2>::function_size>,
396 std::array<double, Traits<Unitary, 2>::function_size>,
406 std::array<double, Traits<Unitary, 3>::function_size>,
411 std::array<double, Traits<Unitary, 3>::function_size>,
422 std::array<double, Traits<Unitary, 1>::function_size>
424 std::array<double, Traits<Unitary, 1>::function_size> r{0.0};
431 std::array<double, Traits<Unitary, 2>::function_size>
433 std::array<double, Traits<Unitary, 2>::function_size> r{0.0};
440 std::array<double, Traits<Unitary, 3>::function_size>
442 std::array<double, Traits<Unitary, 3>::function_size> r{0.0};
520 std::array<double, Traits<Linear, 1>::function_size>,
538 std::array<double, Traits<Linear, 2>::function_size>,
561 std::array<double, Traits<Linear, 3>::function_size>,
588 std::array<double, Traits<Linear, 1>::function_size>,
593 std::array<double, Traits<Linear, 1>::function_size>,
606 std::array<double, Traits<Linear, 2>::function_size>,
611 std::array<double, Traits<Linear, 2>::function_size>,
629 std::array<double, Traits<Linear, 3>::function_size>,
634 std::array<double, Traits<Linear, 3>::function_size>,
660 std::array<double, Traits<Linear, 1>::function_size>
662 std::array<double, Traits<Linear, 1>::function_size> r{0.0};
670 std::array<double, Traits<Linear, 2>::function_size>
672 std::array<double, Traits<Linear, 2>::function_size> r{0.0};
681 std::array<double, Traits<Linear, 3>::function_size>
683 std::array<double, Traits<Linear, 3>::function_size> r{0.0};
754 r[2] = .5 * x[0] * x[0];
766 r[3] = .5 * x[0] * x[0];
768 r[5] = .5 * x[1] * x[1];
781 r[4] = .5 * x[0] * x[0];
784 r[7] = .5 * x[1] * x[1];
786 r[9] = .5 * x[2] * x[2];
800 std::array<double, Traits<Quadratic, 1>::function_size>,
808 r[2][0] = x[0] * x[0] * .5;
822 std::array<double, Traits<Quadratic, 2>::function_size>,
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];
840 for (
size_t i = 3; i < 6; i++)
853 std::array<double, Traits<Quadratic, 3>::function_size>,
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];
882 for (
size_t i = 4; i < 10; i++)
892 std::array<double, Traits<Quadratic, 1>::function_size>,
897 for (
size_t i = 0; i < 1; i++) mx[i] = -x[i];
904 std::array<double, Traits<Quadratic, 2>::function_size>,
909 for (
size_t i = 0; i < 2; i++) mx[i] = -x[i];
916 std::array<double, Traits<Quadratic, 3>::function_size>,
921 for (
size_t i = 0; i < 3; i++) mx[i] = -x[i];
929 std::array<double, Traits<Quadratic, 1>::function_size>
932 for (
size_t i = 0; i < 1; i++) d[i] = y[i] - x[i];
938 std::array<double, Traits<Quadratic, 2>::function_size>
941 for (
size_t i = 0; i < 2; i++) d[i] = y[i] - x[i];
947 std::array<double, Traits<Quadratic, 3>::function_size>
950 for (
size_t i = 0; i < 3; i++) d[i] = y[i] - x[i];
961 tf[1] = { c[0], 1, 0 };
962 tf[2] = { 0.5 * c[0] * c[0], c[0], 1 };
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 };
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 };
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
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
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
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