1 #ifndef _COMPADRE_GMLS_DIVFREE_BASIS_HPP_ 
    2 #define _COMPADRE_GMLS_DIVFREE_BASIS_HPP_ 
   20 namespace DivergenceFreePolynomialBasis {
 
   26     KOKKOS_INLINE_FUNCTION
 
   27     int getSize(
const int degree, 
const int dimension) {
 
   46     KOKKOS_INLINE_FUNCTION
 
   47     void evaluate(
const member_type& teamMember, 
double* delta, 
double* workspace, 
const int dimension, 
const int max_degree, 
const int component, 
const double h, 
const double x, 
const double y, 
const double z, 
const int starting_order = 0, 
const double weight_of_original_value = 0.0, 
const double weight_of_new_value = 1.0) {
 
   48         Kokkos::single(Kokkos::PerThread(teamMember), [&] () {
 
   49             const double factorial[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200};
 
   57                 for (
int i=1; i<=max_degree; ++i) {
 
   58                     x_over_h_to_i[i] = x_over_h_to_i[i-1]*(x/h);
 
   59                     y_over_h_to_i[i] = y_over_h_to_i[i-1]*(y/h);
 
   60                     z_over_h_to_i[i] = z_over_h_to_i[i-1]*(z/h);
 
   63                 for (
int d=0; 
d<dimension; ++
d) {
 
   64                     if ((
d+1)==dimension) {
 
   70                             for (
int n = starting_order; n <= max_degree; n++){
 
   71                                 for (alphay = 0; alphay <= n; alphay++){
 
   73                                     alphaf = factorial[alphax]*factorial[alphay];
 
   74                                     *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * x_over_h_to_i[alphax]*y_over_h_to_i[alphay]/alphaf;
 
   80                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
   88                             int alphax, alphay, alphaz;
 
   91                             for (
int n = starting_order; n <= max_degree; n++){
 
   92                                 for (alphaz = 0; alphaz <= n; alphaz++){
 
   94                                     for (alphay = 0; alphay <= s; alphay++){
 
   96                                         alphaf = factorial[alphax]*factorial[alphay]*factorial[alphaz];
 
   97                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * x_over_h_to_i[alphax]*y_over_h_to_i[alphay]*z_over_h_to_i[alphaz]/alphaf;
 
  102                         } 
else if (component==(
d+1)%3) {
 
  104                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  109                             int alphax, alphay, alphaz;
 
  112                             for (
int n = starting_order; n <= max_degree; n++){
 
  113                                 for (alphaz = 0; alphaz <= n; alphaz++){
 
  115                                     for (alphay = 0; alphay <= s; alphay++){
 
  118                                         int var_pow[3] = {(
d == 0) ? alphax-1 : alphax, (
d == 1) ? alphay-1 : alphay, (
d == 2) ? alphaz-1 : alphaz};
 
  120                                         if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  121                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  123                                             var_pow[component]++;
 
  124                                             alphaf = factorial[var_pow[0]]*factorial[var_pow[1]]*factorial[var_pow[2]];
 
  125                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * -1 * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]*z_over_h_to_i[var_pow[2]]/alphaf;
 
  134             } 
else if (dimension==2) {
 
  137                 x_over_h_to_i[0] = 1;
 
  138                 y_over_h_to_i[0] = 1;
 
  139                 for (
int i=1; i<=max_degree; ++i) {
 
  140                     x_over_h_to_i[i] = x_over_h_to_i[i-1]*(x/h);
 
  141                     y_over_h_to_i[i] = y_over_h_to_i[i-1]*(y/h);
 
  144                 for (
int d=0; 
d<dimension; ++
d) {
 
  145                     if ((
d+1)==dimension) {
 
  149                             for (
int j=starting_order; j<=max_degree; ++j) {
 
  150                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * x_over_h_to_i[j]/factorial[j];
 
  155                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  165                             for (
int n = starting_order; n <= max_degree; n++){
 
  166                                 for (alphay = 0; alphay <= n; alphay++){
 
  168                                     alphaf = factorial[alphax]*factorial[alphay];
 
  169                                     *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * x_over_h_to_i[alphax]*y_over_h_to_i[alphay]/alphaf;
 
  177                             for (
int n = starting_order; n <= max_degree; n++){
 
  178                                 for (alphay = 0; alphay <= n; alphay++){
 
  181                                     int var_pow[2] = {(
d == 0) ? alphax-1 : alphax, (
d == 1) ? alphay-1 : alphay};
 
  183                                     if (var_pow[0]<0 || var_pow[1]<0) {
 
  184                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  186                                         var_pow[component]++;
 
  187                                         alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  188                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * -1 * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  218     KOKKOS_INLINE_FUNCTION
 
  219     void evaluatePartialDerivative(
const member_type& teamMember, 
double* delta, 
double* workspace, 
const int dimension, 
const int max_degree, 
const int component, 
const int partial_direction, 
const double h, 
const double x, 
const double y, 
const double z, 
const int starting_order = 0, 
const double weight_of_original_value = 0.0, 
const double weight_of_new_value = 1.0) {
 
  220         Kokkos::single(Kokkos::PerThread(teamMember), [&] () {
 
  221             const double factorial[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200};
 
  226                 x_over_h_to_i[0] = 1;
 
  227                 y_over_h_to_i[0] = 1;
 
  228                 z_over_h_to_i[0] = 1;
 
  229                 for (
int i=1; i<=max_degree; ++i) {
 
  230                     x_over_h_to_i[i] = x_over_h_to_i[i-1]*(x/h);
 
  231                     y_over_h_to_i[i] = y_over_h_to_i[i-1]*(y/h);
 
  232                     z_over_h_to_i[i] = z_over_h_to_i[i-1]*(z/h);
 
  235                 for (
int d=0; 
d<dimension; ++
d) {
 
  236                     if ((
d+1)==dimension) {
 
  242                             for (
int n = starting_order; n <= max_degree; n++){
 
  243                                 for (alphay = 0; alphay <= n; alphay++){
 
  246                                     int var_pow[3] = {alphax, alphay, 0};
 
  247                                     var_pow[partial_direction]--;
 
  249                                     if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  250                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  252                                         alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  253                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  260                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  268                             int alphax, alphay, alphaz;
 
  271                             for (
int n = starting_order; n <= max_degree; n++){
 
  272                                 for (alphaz = 0; alphaz <= n; alphaz++){
 
  274                                     for (alphay = 0; alphay <= s; alphay++){
 
  277                                         int var_pow[3] = {alphax, alphay, alphaz};
 
  278                                         var_pow[partial_direction]--;
 
  280                                         if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  281                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  283                                             alphaf = factorial[var_pow[0]]*factorial[var_pow[1]]*factorial[var_pow[2]];
 
  284                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]*z_over_h_to_i[var_pow[2]]/alphaf;
 
  290                         } 
else if (component==(
d+1)%3) {
 
  292                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  297                             int alphax, alphay, alphaz;
 
  300                             for (
int n = starting_order; n <= max_degree; n++){
 
  301                                 for (alphaz = 0; alphaz <= n; alphaz++){
 
  303                                     for (alphay = 0; alphay <= s; alphay++){
 
  306                                         int var_pow[3] = {alphax, alphay, alphaz};
 
  309                                         if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  310                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  312                                             var_pow[component]++;
 
  313                                             var_pow[partial_direction]--;
 
  314                                             if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  315                                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  317                                                 alphaf = factorial[var_pow[0]]*factorial[var_pow[1]]*factorial[var_pow[2]];
 
  318                                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * -1.0/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]*z_over_h_to_i[var_pow[2]]/alphaf;
 
  328             } 
else if (dimension==2) {
 
  331                 x_over_h_to_i[0] = 1;
 
  332                 y_over_h_to_i[0] = 1;
 
  333                 for (
int i=1; i<=max_degree; ++i) {
 
  334                     x_over_h_to_i[i] = x_over_h_to_i[i-1]*(x/h);
 
  335                     y_over_h_to_i[i] = y_over_h_to_i[i-1]*(y/h);
 
  338                 for (
int d=0; 
d<dimension; ++
d) {
 
  339                     if ((
d+1)==dimension) {
 
  344                             for (
int n = starting_order; n <= max_degree; n++){
 
  347                                 int var_pow[2] = {alphax, 0};
 
  348                                 var_pow[partial_direction]--;
 
  350                                 if (var_pow[0]<0 || var_pow[1]<0) {
 
  351                                     *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  353                                     alphaf = factorial[var_pow[0]];
 
  354                                     *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h * x_over_h_to_i[var_pow[0]]/alphaf;
 
  360                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  369                             for (
int n = starting_order; n <= max_degree; n++){
 
  370                                 for (alphay = 0; alphay <= n; alphay++){
 
  373                                     int var_pow[2] = {alphax, alphay};
 
  374                                     var_pow[partial_direction]--;
 
  376                                     if (var_pow[0]<0 || var_pow[1]<0) {
 
  377                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  379                                         alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  380                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  389                             for (
int n = starting_order; n <= max_degree; n++){
 
  390                                 for (alphay = 0; alphay <= n; alphay++){
 
  393                                     int var_pow[2] = {alphax, alphay};
 
  396                                     if (var_pow[0]<0 || var_pow[1]<0) {
 
  397                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  399                                         var_pow[component]++;
 
  400                                         var_pow[partial_direction]--;
 
  401                                         if (var_pow[0]<0 || var_pow[1]<0) {
 
  402                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  404                                             alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  405                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * -1.0/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  437     KOKKOS_INLINE_FUNCTION
 
  438     void evaluateSecondPartialDerivative(
const member_type& teamMember, 
double* delta, 
double* workspace, 
const int dimension, 
const int max_degree, 
const int component, 
const int partial_direction_1, 
const int partial_direction_2, 
const double h, 
const double x, 
const double y, 
const double z, 
const int starting_order = 0, 
const double weight_of_original_value = 0.0, 
const double weight_of_new_value = 1.0) {
 
  439         Kokkos::single(Kokkos::PerThread(teamMember), [&] () {
 
  440             const double factorial[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200};
 
  445                 x_over_h_to_i[0] = 1;
 
  446                 y_over_h_to_i[0] = 1;
 
  447                 z_over_h_to_i[0] = 1;
 
  448                 for (
int i=1; i<=max_degree; ++i) {
 
  449                     x_over_h_to_i[i] = x_over_h_to_i[i-1]*(x/h);
 
  450                     y_over_h_to_i[i] = y_over_h_to_i[i-1]*(y/h);
 
  451                     z_over_h_to_i[i] = z_over_h_to_i[i-1]*(z/h);
 
  454                 for (
int d=0; 
d<dimension; ++
d) {
 
  455                     if ((
d+1)==dimension) {
 
  461                             for (
int n = starting_order; n <= max_degree; n++){
 
  462                                 for (alphay = 0; alphay <= n; alphay++){
 
  465                                     int var_pow[3] = {alphax, alphay, 0};
 
  466                                     var_pow[partial_direction_1]--;
 
  467                                     var_pow[partial_direction_2]--;
 
  469                                     if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  470                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  472                                         alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  473                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  480                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  488                             int alphax, alphay, alphaz;
 
  491                             for (
int n = starting_order; n <= max_degree; n++){
 
  492                                 for (alphaz = 0; alphaz <= n; alphaz++){
 
  494                                     for (alphay = 0; alphay <= s; alphay++){
 
  497                                         int var_pow[3] = {alphax, alphay, alphaz};
 
  498                                         var_pow[partial_direction_1]--;
 
  499                                         var_pow[partial_direction_2]--;
 
  501                                         if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  502                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  504                                             alphaf = factorial[var_pow[0]]*factorial[var_pow[1]]*factorial[var_pow[2]];
 
  505                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]*z_over_h_to_i[var_pow[2]]/alphaf;
 
  511                         } 
else if (component==(
d+1)%3) {
 
  513                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  518                             int alphax, alphay, alphaz;
 
  521                             for (
int n = starting_order; n <= max_degree; n++){
 
  522                                 for (alphaz = 0; alphaz <= n; alphaz++){
 
  524                                     for (alphay = 0; alphay <= s; alphay++){
 
  527                                         int var_pow[3] = {alphax, alphay, alphaz};
 
  530                                         if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  531                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  533                                             var_pow[component]++;
 
  534                                             var_pow[partial_direction_1]--;
 
  535                                             var_pow[partial_direction_2]--;
 
  536                                             if (var_pow[0]<0 || var_pow[1]<0 || var_pow[2]<0) {
 
  537                                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  539                                                 alphaf = factorial[var_pow[0]]*factorial[var_pow[1]]*factorial[var_pow[2]];
 
  540                                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * -1.0/h/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]*z_over_h_to_i[var_pow[2]]/alphaf;
 
  550             } 
else if (dimension==2) {
 
  553                 x_over_h_to_i[0] = 1;
 
  554                 y_over_h_to_i[0] = 1;
 
  555                 for (
int i=1; i<=max_degree; ++i) {
 
  556                     x_over_h_to_i[i] = x_over_h_to_i[i-1]*(x/h);
 
  557                     y_over_h_to_i[i] = y_over_h_to_i[i-1]*(y/h);
 
  560                 for (
int d=0; 
d<dimension; ++
d) {
 
  561                     if ((
d+1)==dimension) {
 
  566                             for (
int n = starting_order; n <= max_degree; n++){
 
  569                                 int var_pow[2] = {alphax, 0};
 
  570                                 var_pow[partial_direction_1]--;
 
  571                                 var_pow[partial_direction_2]--;
 
  573                                 if (var_pow[0]<0 || var_pow[1]<0) {
 
  574                                     *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  576                                     alphaf = factorial[var_pow[0]];
 
  577                                     *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h/h * x_over_h_to_i[var_pow[0]]/alphaf;
 
  583                                 *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0;
 
  592                             for (
int n = starting_order; n <= max_degree; n++){
 
  593                                 for (alphay = 0; alphay <= n; alphay++){
 
  596                                     int var_pow[2] = {alphax, alphay};
 
  597                                     var_pow[partial_direction_1]--;
 
  598                                     var_pow[partial_direction_2]--;
 
  600                                     if (var_pow[0]<0 || var_pow[1]<0) {
 
  601                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  603                                         alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  604                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 1./h/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  613                             for (
int n = starting_order; n <= max_degree; n++){
 
  614                                 for (alphay = 0; alphay <= n; alphay++){
 
  617                                     int var_pow[2] = {alphax, alphay};
 
  620                                     if (var_pow[0]<0 || var_pow[1]<0) {
 
  621                                         *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  623                                         var_pow[component]++;
 
  624                                         var_pow[partial_direction_1]--;
 
  625                                         var_pow[partial_direction_2]--;
 
  626                                         if (var_pow[0]<0 || var_pow[1]<0) {
 
  627                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * 0.0;
 
  629                                             alphaf = factorial[var_pow[0]]*factorial[var_pow[1]];
 
  630                                             *(delta+i) = weight_of_original_value * *(delta+i) + weight_of_new_value * -1.0/h/h * x_over_h_to_i[var_pow[0]]*y_over_h_to_i[var_pow[1]]/alphaf;
 
  655     KOKKOS_INLINE_FUNCTION
 
  656     XYZ evaluate(
int np, 
const double sx, 
const double sy, 
const double sz) {
 
  658         const double th = 1./3.;
 
  662             case 0: 
return XYZ(1.0,0.0,0.0);
 
  663             case 1: 
return XYZ(0.0,1.0,0.0);
 
  664             case 2: 
return XYZ(0.0,0.0,1.0);
 
  667             case 3 : 
return XYZ( sy,  0,  0);
 
  668             case 4 : 
return XYZ( sz,  0,  0);
 
  669             case 5 : 
return XYZ(  0, sx,  0);
 
  670             case 6 : 
return XYZ(  0, sz,  0);
 
  671             case 7 : 
return XYZ(  0,  0, sx);
 
  672             case 8 : 
return XYZ(  0,  0, sy);
 
  673             case 9 : 
return XYZ( sx,-sy,  0);
 
  674             case 10: 
return XYZ( sx,  0,-sz);
 
  677             case 11: 
return XYZ(     sy*sy,          0,         0);
 
  678             case 12: 
return XYZ(     sz*sz,          0,         0);
 
  679             case 13: 
return XYZ(     sy*sz,          0,         0);
 
  680             case 14: 
return XYZ(         0,      sx*sx,         0);
 
  681             case 15: 
return XYZ(         0,      sz*sz,         0);
 
  682             case 16: 
return XYZ(         0,      sx*sz,         0);
 
  683             case 17: 
return XYZ(         0,          0,     sx*sx);
 
  684             case 18: 
return XYZ(         0,          0,     sy*sy);
 
  685             case 19: 
return XYZ(         0,          0,     sx*sy);
 
  687             case 20: 
return XYZ(     sx*sx, -2.0*sx*sy,         0);
 
  688             case 21: 
return XYZ(     sx*sy,          0,-1.0*sy*sz);
 
  689             case 22: 
return XYZ(     sx*sz, -1.0*sy*sz,         0);
 
  690             case 23: 
return XYZ(-2.0*sx*sy,      sy*sy,          0);
 
  691             case 24: 
return XYZ(         0,      sx*sy, -1.0*sx*sz);
 
  692             case 25: 
return XYZ(-2.0*sx*sz,          0,      sz*sz);
 
  695             case 26: 
return XYZ(sy*sy*sy   ,            0,             0);
 
  696             case 27: 
return XYZ(sy*sy*sz   ,            0,             0);
 
  697             case 28: 
return XYZ(sy*sz*sz   ,            0,             0);
 
  698             case 29: 
return XYZ(sz*sz*sz   ,            0,             0);
 
  699             case 30: 
return XYZ(          0,  sx*sx*sx   ,             0);
 
  700             case 31: 
return XYZ(          0,  sx*sx*sz   ,             0);
 
  701             case 32: 
return XYZ(          0,  sx*sz*sz   ,             0);
 
  702             case 33: 
return XYZ(          0,  sz*sz*sz   ,             0);
 
  703             case 34: 
return XYZ(          0,            0,  sx*sx*sx    );
 
  704             case 35: 
return XYZ(          0,            0,  sx*sx*sy    );
 
  705             case 36: 
return XYZ(          0,            0,  sx*sy*sy    );
 
  706             case 37: 
return XYZ(          0,            0,  sy*sy*sy    );
 
  708             case 38: 
return XYZ( sx*sx*sx  ,-3.0*sx*sx*sy,            0);
 
  709             case 39: 
return XYZ( sx*sx*sx  ,            0,-3.0*sx*sx*sz);
 
  710             case 40: 
return XYZ( sx*sx*sy  ,-1.0*sx*sy*sy,            0);
 
  711             case 41: 
return XYZ( sx*sx*sy  ,            0,-2.0*sx*sy*sz);
 
  712             case 42: 
return XYZ( sx*sx*sz  ,-2.0*sx*sy*sz,            0);
 
  713             case 43: 
return XYZ( sx*sx*sz  ,            0,-1.0*sx*sz*sz);
 
  714             case 44: 
return XYZ( sx*sy*sy  ,- th*sy*sy*sy,            0);
 
  715             case 45: 
return XYZ( sx*sy*sy  ,            0,-1.0*sy*sy*sz);
 
  716             case 46: 
return XYZ( sx*sy*sz  ,-0.5*sy*sy*sz,            0);
 
  717             case 47: 
return XYZ( sx*sy*sz  ,            0,-0.5*sy*sz*sz);
 
  718             case 48: 
return XYZ( sx*sz*sz  ,-1.0*sy*sz*sz,            0);
 
  719             case 49: 
return XYZ( sx*sz*sz  ,            0,- th*sz*sz*sz);
 
  722             case 50: 
return XYZ(sy*sy*sy*sy         ,                   0,                   0);
 
  723             case 51: 
return XYZ(sy*sy*sy*sz         ,                   0,                   0);
 
  724             case 52: 
return XYZ(sy*sy*sz*sz         ,                   0,                   0);
 
  725             case 53: 
return XYZ(sy*sz*sz*sz         ,                   0,                   0);
 
  726             case 54: 
return XYZ(sz*sz*sz*sz         ,                   0,                   0);
 
  727             case 55: 
return XYZ(                   0, sx*sx*sx*sx        ,                   0);
 
  728             case 56: 
return XYZ(                   0, sx*sx*sx*sz        ,                   0);
 
  729             case 57: 
return XYZ(                   0, sx*sx*sz*sz        ,                   0);
 
  730             case 58: 
return XYZ(                   0, sx*sz*sz*sz        ,                   0);
 
  731             case 59: 
return XYZ(                   0, sz*sz*sz*sz        ,                   0);
 
  732             case 60: 
return XYZ(                   0,                   0, sx*sx*sx*sx        );
 
  733             case 61: 
return XYZ(                   0,                   0, sx*sx*sx*sy        );
 
  734             case 62: 
return XYZ(                   0,                   0, sx*sx*sy*sy        );
 
  735             case 63: 
return XYZ(                   0,                   0, sx*sy*sy*sy        );
 
  736             case 64: 
return XYZ(                   0,                   0, sy*sy*sy*sy        );
 
  738             case 65: 
return XYZ(sx*sx*sx*sx         ,-4.0*sx*sx*sx*sy    ,                   0);
 
  739             case 66: 
return XYZ(sx*sx*sx*sx         ,                   0, -4.0*sx*sx*sx*sz   );
 
  740             case 67: 
return XYZ(sx*sx*sx*sy         ,-1.5*sx*sx*sy*sy    ,                   0);
 
  741             case 68: 
return XYZ(sx*sx*sx*sy         ,                   0, -3.0*sx*sx*sy*sz   );
 
  742             case 69: 
return XYZ(sx*sx*sx*sz         ,-3.0*sx*sx*sy*sz    ,                   0);
 
  743             case 70: 
return XYZ(sx*sx*sx*sz         ,                   0, -1.5*sx*sx*sz*sz   );
 
  745             case 71: 
return XYZ(sx*sx*sy*sy         , -2.0*th*sx*sy*sy*sy,                   0);
 
  746             case 72: 
return XYZ(sx*sx*sy*sy         ,                   0, -2.0*sx*sy*sy*sz   );
 
  747             case 73: 
return XYZ(sx*sx*sy*sz         , -sx*sy*sy*sz       ,                   0);
 
  748             case 74: 
return XYZ(sx*sx*sy*sz         ,                   0, -sx*sy*sz*sz       );
 
  749             case 75: 
return XYZ(sx*sx*sz*sz         , -2.0*sx*sy*sz*sz   ,                   0);
 
  750             case 76: 
return XYZ(sx*sx*sz*sz         ,                   0, -2.0*th*sx*sz*sz*sz);
 
  751             case 77: 
return XYZ(sx*sy*sy*sy         , -0.25*sy*sy*sy*sy  ,                   0);
 
  752             case 78: 
return XYZ(sx*sy*sy*sy         ,                   0, -sy*sy*sy*sz       );
 
  753             case 79: 
return XYZ(sx*sy*sy*sz         , -th*sy*sy*sy*sz    ,                   0);
 
  754             case 80: 
return XYZ(sx*sy*sy*sz         ,                   0, -0.5*sy*sy*sz*sz   );
 
  755             case 81: 
return XYZ(sx*sy*sz*sz         , -0.5*sy*sy*sz*sz   ,                   0);
 
  756             case 82: 
return XYZ(sx*sy*sz*sz         ,                   0, -th*sy*sz*sz*sz    );
 
  757             case 83: 
return XYZ(sx*sz*sz*sz         , -sy*sz*sz*sz       ,                   0);
 
  758             case 84: 
return XYZ(sx*sz*sz*sz         ,                   0,-0.25*sz*sz*sz*sz   );
 
  762 ports up to 4th-order polynomials for now.");
 
  775     KOKKOS_INLINE_FUNCTION
 
  781             case 0: 
return XYZ(1.0,0.0,0.0);
 
  782             case 1: 
return XYZ(0.0,1.0,0.0);
 
  785             case 2: 
return XYZ(sy,  0, 0);
 
  786             case 3: 
return XYZ( 0, sx, 0);
 
  787             case 4: 
return XYZ(sx,-sy, 0);
 
  790             case 5: 
return XYZ(      sy*sy,          0, 0);
 
  791             case 6: 
return XYZ(          0,      sx*sx, 0);
 
  793             case 7: 
return XYZ(      sx*sx, -2.0*sx*sy, 0);
 
  794             case 8: 
return XYZ( -2.0*sx*sy,      sy*sy, 0);
 
  797             case 9 : 
return XYZ(     sy*sy*sy,             0, 0);
 
  798             case 10: 
return XYZ(            0,      sx*sx*sx, 0);
 
  800             case 11: 
return XYZ(     sx*sx*sx, -3.0*sx*sx*sy, 0);
 
  801             case 12: 
return XYZ(     sx*sx*sy, -1.0*sx*sy*sy, 0);
 
  802             case 13: 
return XYZ(-3.0*sx*sy*sy,      sy*sy*sy, 0);
 
  805             case 14: 
return XYZ(     sy*sy*sy*sy,                0, 0);
 
  806             case 15: 
return XYZ(               0,      sx*sx*sx*sx, 0);
 
  808             case 16: 
return XYZ(     sx*sx*sx*sx, -4.0*sx*sx*sx*sy, 0);
 
  809             case 17: 
return XYZ( 2.0*sx*sx*sx*sy, -3.0*sx*sx*sy*sy, 0);
 
  810             case 18: 
return XYZ(-3.0*sx*sx*sy*sy,  2.0*sx*sy*sy*sy, 0);
 
  811             case 19: 
return XYZ(-4.0*sx*sy*sy*sy,      sy*sy*sy*sy, 0);
 
  815 ports up to 4th-order polynomials for now.");
 
  830     KOKKOS_INLINE_FUNCTION
 
  833         const double th = 1./3.;
 
  835         if (partial_direction==0) {
 
  838                 case 0: 
return XYZ(0.0,0.0,0.0);
 
  839                 case 1: 
return XYZ(0.0,0.0,0.0);
 
  840                 case 2: 
return XYZ(0.0,0.0,0.0);
 
  843                 case 3 : 
return XYZ(      0,      0,      0);
 
  844                 case 4 : 
return XYZ(      0,      0,      0);
 
  845                 case 5 : 
return XYZ(      0,  1.0/h,      0);
 
  846                 case 6 : 
return XYZ(      0,      0,      0);
 
  847                 case 7 : 
return XYZ(      0,      0,  1.0/h);
 
  848                 case 8 : 
return XYZ(      0,      0,      0);
 
  849                 case 9 : 
return XYZ(  1.0/h,      0,      0);
 
  850                 case 10: 
return XYZ(  1.0/h,      0,      0);
 
  853                 case 11: 
return XYZ(         0,          0,         0);
 
  854                 case 12: 
return XYZ(         0,          0,         0);
 
  855                 case 13: 
return XYZ(         0,          0,         0);
 
  856                 case 14: 
return XYZ(         0,     2*sx/h,         0);
 
  857                 case 15: 
return XYZ(         0,          0,         0);
 
  858                 case 16: 
return XYZ(         0,       sz/h,         0);
 
  859                 case 17: 
return XYZ(         0,          0,    2*sx/h);
 
  860                 case 18: 
return XYZ(         0,          0,         0);
 
  861                 case 19: 
return XYZ(         0,          0,      sy/h);
 
  863                 case 20: 
return XYZ(    2*sx/h,  -2.0*sy/h,         0);
 
  864                 case 21: 
return XYZ(      sy/h,          0,         0);
 
  865                 case 22: 
return XYZ(      sz/h,          0,         0);
 
  866                 case 23: 
return XYZ( -2.0*sy/h,          0,         0);
 
  867                 case 24: 
return XYZ(         0,       sy/h, -1.0*sz/h);
 
  868                 case 25: 
return XYZ( -2.0*sz/h,          0,         0);
 
  871                 case 26: 
return XYZ(          0,            0,             0);
 
  872                 case 27: 
return XYZ(          0,            0,             0);
 
  873                 case 28: 
return XYZ(          0,            0,             0);
 
  874                 case 29: 
return XYZ(          0,            0,             0);
 
  875                 case 30: 
return XYZ(          0,    3*sx*sx/h,             0);
 
  876                 case 31: 
return XYZ(          0,    2*sx*sz/h,             0);
 
  877                 case 32: 
return XYZ(          0,      sz*sz/h,             0);
 
  878                 case 33: 
return XYZ(          0,            0,             0);
 
  879                 case 34: 
return XYZ(          0,            0,     3*sx*sx/h);
 
  880                 case 35: 
return XYZ(          0,            0,     2*sx*sy/h);
 
  881                 case 36: 
return XYZ(          0,            0,       sy*sy/h);
 
  882                 case 37: 
return XYZ(          0,            0,             0);
 
  884                 case 38: 
return XYZ(  3*sx*sx/h, -6.0*sx*sy/h,            0);
 
  885                 case 39: 
return XYZ(  3*sx*sx/h,            0, -6.0*sx*sz/h);
 
  886                 case 40: 
return XYZ(  2*sx*sy/h, -1.0*sy*sy/h,            0);
 
  887                 case 41: 
return XYZ(  2*sx*sy/h,            0, -2.0*sy*sz/h);
 
  888                 case 42: 
return XYZ(  2*sx*sz/h, -2.0*sy*sz/h,            0);
 
  889                 case 43: 
return XYZ(  2*sx*sz/h,            0, -1.0*sz*sz/h);
 
  890                 case 44: 
return XYZ(    sy*sy/h,            0,            0);
 
  891                 case 45: 
return XYZ(    sy*sy/h,            0,            0);
 
  892                 case 46: 
return XYZ(    sy*sz/h,            0,            0);
 
  893                 case 47: 
return XYZ(    sy*sz/h,            0,            0);
 
  894                 case 48: 
return XYZ(    sz*sz/h,            0,            0);
 
  895                 case 49: 
return XYZ(    sz*sz/h,            0,            0);
 
  898                 case 50: 
return XYZ(                   0,                   0,                   0);
 
  899                 case 51: 
return XYZ(                   0,                   0,                   0);
 
  900                 case 52: 
return XYZ(                   0,                   0,                   0);
 
  901                 case 53: 
return XYZ(                   0,                   0,                   0);
 
  902                 case 54: 
return XYZ(                   0,                   0,                   0);
 
  903                 case 55: 
return XYZ(                   0,        4*sx*sx*sx/h,                   0);
 
  904                 case 56: 
return XYZ(                   0,        3*sx*sx*sz/h,                   0);
 
  905                 case 57: 
return XYZ(                   0,        2*sx*sz*sz/h,                   0);
 
  906                 case 58: 
return XYZ(                   0,          sz*sz*sz/h,                   0);
 
  907                 case 59: 
return XYZ(                   0,                   0,                   0);
 
  908                 case 60: 
return XYZ(                   0,                   0,        4*sx*sx*sx/h);
 
  909                 case 61: 
return XYZ(                   0,                   0,        3*sx*sx*sy/h);
 
  910                 case 62: 
return XYZ(                   0,                   0,        2*sx*sy*sy/h);
 
  911                 case 63: 
return XYZ(                   0,                   0,          sy*sy*sy/h);
 
  912                 case 64: 
return XYZ(                   0,                   0,                   0);
 
  914                 case 65: 
return XYZ( 4*sx*sx*sx/h       ,-12.0*sx*sx*sy/h    ,                   0);
 
  915                 case 66: 
return XYZ( 4*sx*sx*sx/h       ,                   0, -12.0*sx*sx*sz/h   );
 
  916                 case 67: 
return XYZ( 3*sx*sx*sy/h       ,-3.0*sx*sy*sy/h    ,                   0);
 
  917                 case 68: 
return XYZ( 3*sx*sx*sy/h       ,                   0, -6.0*sx*sy*sz/h   );
 
  918                 case 69: 
return XYZ( 3*sx*sx*sz/h       ,-6.0*sx*sy*sz/h    ,                   0);
 
  919                 case 70: 
return XYZ( 3*sx*sx*sz/h       ,                   0, -3.0*sx*sz*sz/h   );
 
  920                 case 71: 
return XYZ( 2*sx*sy*sy/h       , -2.0*th*sy*sy*sy/h,                   0);
 
  921                 case 72: 
return XYZ( 2*sx*sy*sy/h       ,                   0, -2.0*sy*sy*sz/h   );
 
  922                 case 73: 
return XYZ( 2*sx*sy*sz/h       , -sy*sy*sz/h       ,                   0);
 
  923                 case 74: 
return XYZ( 2*sx*sy*sz/h       ,                   0, -sy*sz*sz/h       );
 
  924                 case 75: 
return XYZ( 2*sx*sz*sz/h       , -2.0*sy*sz*sz/h   ,                   0);
 
  925                 case 76: 
return XYZ( 2*sx*sz*sz/h       ,                   0, -2.0*th*sz*sz*sz/h);
 
  926                 case 77: 
return XYZ(   sy*sy*sy/h       ,                   0,                   0);
 
  927                 case 78: 
return XYZ(   sy*sy*sy/h       ,                   0,                   0);
 
  928                 case 79: 
return XYZ(   sy*sy*sz/h       ,                   0,                   0);
 
  929                 case 80: 
return XYZ(   sy*sy*sz/h       ,                   0,                   0);
 
  930                 case 81: 
return XYZ(   sy*sz*sz/h       ,                   0,                   0);
 
  931                 case 82: 
return XYZ(   sy*sz*sz/h       ,                   0,                   0);
 
  932                 case 83: 
return XYZ(   sz*sz*sz/h       ,                   0,                   0);
 
  933                 case 84: 
return XYZ(   sz*sz*sz/h       ,                   0,                   0);
 
  937 ports up     to 4th-order polynomials for now.");
 
  940         } 
else if (partial_direction==1) {
 
  943                 case 0: 
return XYZ(0.0,0.0,0.0);
 
  944                 case 1: 
return XYZ(0.0,0.0,0.0);
 
  945                 case 2: 
return XYZ(0.0,0.0,0.0);
 
  948                 case 3 : 
return XYZ( 1.0/h,      0,     0);
 
  949                 case 4 : 
return XYZ(     0,      0,     0);
 
  950                 case 5 : 
return XYZ(     0,      0,     0);
 
  951                 case 6 : 
return XYZ(     0,      0,     0);
 
  952                 case 7 : 
return XYZ(     0,      0,     0);
 
  953                 case 8 : 
return XYZ(     0,      0, 1.0/h);
 
  954                 case 9 : 
return XYZ(     0, -1.0/h,     0);
 
  955                 case 10: 
return XYZ(     0,      0,     0);
 
  958                 case 11: 
return XYZ(    2*sy/h,          0,          0);
 
  959                 case 12: 
return XYZ(         0,          0,          0);
 
  960                 case 13: 
return XYZ(      sz/h,          0,          0);
 
  961                 case 14: 
return XYZ(         0,          0,          0);
 
  962                 case 15: 
return XYZ(         0,          0,          0);
 
  963                 case 16: 
return XYZ(         0,          0,          0);
 
  964                 case 17: 
return XYZ(         0,          0,          0);
 
  965                 case 18: 
return XYZ(         0,          0,     2*sy/h);
 
  966                 case 19: 
return XYZ(         0,          0,       sx/h);
 
  968                 case 20: 
return XYZ(         0,  -2.0*sx/h,          0);
 
  969                 case 21: 
return XYZ(      sx/h,          0,  -1.0*sz/h);
 
  970                 case 22: 
return XYZ(         0,  -1.0*sz/h,          0);
 
  971                 case 23: 
return XYZ( -2.0*sx/h,     2*sy/h,          0);
 
  972                 case 24: 
return XYZ(         0,       sx/h,          0);
 
  973                 case 25: 
return XYZ(         0,          0,          0);
 
  976                 case 26: 
return XYZ(  3*sy*sy/h,            0,             0);
 
  977                 case 27: 
return XYZ(  2*sy*sz/h,            0,             0);
 
  978                 case 28: 
return XYZ(    sz*sz/h,            0,             0);
 
  979                 case 29: 
return XYZ(          0,            0,             0);
 
  980                 case 30: 
return XYZ(          0,            0,             0);
 
  981                 case 31: 
return XYZ(          0,            0,             0);
 
  982                 case 32: 
return XYZ(          0,            0,             0);
 
  983                 case 33: 
return XYZ(          0,            0,             0);
 
  984                 case 34: 
return XYZ(          0,            0,             0);
 
  985                 case 35: 
return XYZ(          0,            0,       sx*sx/h);
 
  986                 case 36: 
return XYZ(          0,            0,     2*sx*sy/h);
 
  987                 case 37: 
return XYZ(          0,            0,     3*sy*sy/h);
 
  989                 case 38: 
return XYZ(          0, -3.0*sx*sx/h,            0);
 
  990                 case 39: 
return XYZ(          0,            0,            0);
 
  991                 case 40: 
return XYZ(    sx*sx/h, -2.0*sx*sy/h,            0);
 
  992                 case 41: 
return XYZ(    sx*sx/h,            0, -2.0*sx*sz/h);
 
  993                 case 42: 
return XYZ(          0, -2.0*sx*sz/h,            0);
 
  994                 case 43: 
return XYZ(          0,            0,            0);
 
  995                 case 44: 
return XYZ(  2*sx*sy/h,-3*th*sy*sy/h,            0);
 
  996                 case 45: 
return XYZ(  2*sx*sy/h,            0, -2.0*sy*sz/h);
 
  997                 case 46: 
return XYZ(    sx*sz/h, -1.0*sy*sz/h,            0);
 
  998                 case 47: 
return XYZ(    sx*sz/h,            0, -0.5*sz*sz/h);
 
  999                 case 48: 
return XYZ(          0, -1.0*sz*sz/h,            0);
 
 1000                 case 49: 
return XYZ(          0,            0,            0);
 
 1003                 case 50: 
return XYZ(        4*sy*sy*sy/h,                   0,                   0);
 
 1004                 case 51: 
return XYZ(        3*sy*sy*sz/h,                   0,                   0);
 
 1005                 case 52: 
return XYZ(        2*sy*sz*sz/h,                   0,                   0);
 
 1006                 case 53: 
return XYZ(          sz*sz*sz/h,                   0,                   0);
 
 1007                 case 54: 
return XYZ(                   0,                   0,                   0);
 
 1008                 case 55: 
return XYZ(                   0,                   0,                   0);
 
 1009                 case 56: 
return XYZ(                   0,                   0,                   0);
 
 1010                 case 57: 
return XYZ(                   0,                   0,                   0);
 
 1011                 case 58: 
return XYZ(                   0,                   0,                   0);
 
 1012                 case 59: 
return XYZ(                   0,                   0,                   0);
 
 1013                 case 60: 
return XYZ(                   0,                   0,                   0);
 
 1014                 case 61: 
return XYZ(                   0,                   0,         sx*sx*sx/h);
 
 1015                 case 62: 
return XYZ(                   0,                   0,         2*sx*sx*sy/h);
 
 1016                 case 63: 
return XYZ(                   0,                   0,         3*sx*sy*sy/h);
 
 1017                 case 64: 
return XYZ(                   0,                   0,         4*sy*sy*sy/h);
 
 1019                 case 65: 
return XYZ(                   0,     -4.0*sx*sx*sx/h,                   0);
 
 1020                 case 66: 
return XYZ(                   0,                   0,                   0);
 
 1021                 case 67: 
return XYZ(          sx*sx*sx/h,     -3.0*sx*sx*sy/h,                   0);
 
 1022                 case 68: 
return XYZ(          sx*sx*sx/h,                   0,     -3.0*sx*sx*sz/h);
 
 1023                 case 69: 
return XYZ(                   0,     -3.0*sx*sx*sz/h,                   0);
 
 1024                 case 70: 
return XYZ(                   0,                   0,                   0);
 
 1025                 case 71: 
return XYZ(        2*sx*sx*sy/h,  -6.0*th*sx*sy*sy/h,                   0);
 
 1026                 case 72: 
return XYZ(        2*sx*sx*sy/h,                   0,     -4.0*sx*sy*sz/h);
 
 1027                 case 73: 
return XYZ(          sx*sx*sz/h,         -2*sx*sy*sz,                   0);
 
 1028                 case 74: 
return XYZ(          sx*sx*sz/h,                   0,         -sx*sz*sz/h);
 
 1029                 case 75: 
return XYZ(                   0,     -2.0*sx*sz*sz/h,                   0);
 
 1030                 case 76: 
return XYZ(                   0,                   0,                   0);
 
 1031                 case 77: 
return XYZ(        3*sx*sy*sy/h,     -1.0*sy*sy*sy/h,                   0);
 
 1032                 case 78: 
return XYZ(        3*sx*sy*sy/h,                   0,       -3*sy*sy*sz/h);
 
 1033                 case 79: 
return XYZ(        2*sx*sy*sz/h,    -3*th*sy*sy*sz/h,                   0);
 
 1034                 case 80: 
return XYZ(        2*sx*sy*sz/h,                   0,     -1.0*sy*sz*sz/h);
 
 1035                 case 81: 
return XYZ(          sx*sz*sz/h,     -1.0*sy*sz*sz/h,                   0);
 
 1036                 case 82: 
return XYZ(          sx*sz*sz/h,                   0,      -th*sz*sz*sz/h);
 
 1037                 case 83: 
return XYZ(                   0,         -sz*sz*sz/h,                   0);
 
 1038                 case 84: 
return XYZ(                   0,                   0,                   0);
 
 1042 ports up     to 4th-order polynomials for now.");
 
 1048                 case 0: 
return XYZ(0.0,0.0,0.0);
 
 1049                 case 1: 
return XYZ(0.0,0.0,0.0);
 
 1050                 case 2: 
return XYZ(0.0,0.0,0.0);
 
 1053                 case 3 : 
return XYZ(   0,   0,   0);
 
 1054                 case 4 : 
return XYZ( 1/h,   0,   0);
 
 1055                 case 5 : 
return XYZ(   0,   0,   0);
 
 1056                 case 6 : 
return XYZ(   0, 1/h,   0);
 
 1057                 case 7 : 
return XYZ(   0,   0,   0);
 
 1058                 case 8 : 
return XYZ(   0,   0,   0);
 
 1059                 case 9 : 
return XYZ(   0,   0,   0);
 
 1060                 case 10: 
return XYZ(   0,   0,-1/h);
 
 1063                 case 11: 
return XYZ(         0,          0,         0);
 
 1064                 case 12: 
return XYZ(    2*sz/h,          0,         0);
 
 1065                 case 13: 
return XYZ(      sy/h,          0,         0);
 
 1066                 case 14: 
return XYZ(         0,          0,         0);
 
 1067                 case 15: 
return XYZ(         0,     2*sz/h,         0);
 
 1068                 case 16: 
return XYZ(         0,       sx/h,         0);
 
 1069                 case 17: 
return XYZ(         0,          0,         0);
 
 1070                 case 18: 
return XYZ(         0,          0,         0);
 
 1071                 case 19: 
return XYZ(         0,          0,         0);
 
 1073                 case 20: 
return XYZ(         0,          0,         0);
 
 1074                 case 21: 
return XYZ(         0,          0, -1.0*sy/h);
 
 1075                 case 22: 
return XYZ(      sx/h,  -1.0*sy/h,         0);
 
 1076                 case 23: 
return XYZ(         0,          0,         0);
 
 1077                 case 24: 
return XYZ(         0,          0, -1.0*sx/h);
 
 1078                 case 25: 
return XYZ( -2.0*sx/h,          0,    2*sz/h);
 
 1081                 case 26: 
return XYZ(          0,            0,             0);
 
 1082                 case 27: 
return XYZ(    sy*sy/h,            0,             0);
 
 1083                 case 28: 
return XYZ(  2*sy*sz/h,            0,             0);
 
 1084                 case 29: 
return XYZ(  3*sz*sz/h,            0,             0);
 
 1085                 case 30: 
return XYZ(          0,            0,             0);
 
 1086                 case 31: 
return XYZ(          0,      sx*sx/h,             0);
 
 1087                 case 32: 
return XYZ(          0,    2*sx*sz/h,             0);
 
 1088                 case 33: 
return XYZ(          0,    3*sz*sz/h,             0);
 
 1089                 case 34: 
return XYZ(          0,            0,             0);
 
 1090                 case 35: 
return XYZ(          0,            0,             0);
 
 1091                 case 36: 
return XYZ(          0,            0,             0);
 
 1092                 case 37: 
return XYZ(          0,            0,             0);
 
 1094                 case 38: 
return XYZ(          0,            0,            0);
 
 1095                 case 39: 
return XYZ(          0,            0, -3.0*sx*sx/h);
 
 1096                 case 40: 
return XYZ(          0,            0,            0);
 
 1097                 case 41: 
return XYZ(          0,            0, -2.0*sx*sy/h);
 
 1098                 case 42: 
return XYZ(    sx*sx/h, -2.0*sx*sy/h,            0);
 
 1099                 case 43: 
return XYZ(    sx*sx/h,            0, -2.0*sx*sz/h);
 
 1100                 case 44: 
return XYZ(          0,            0,            0);
 
 1101                 case 45: 
return XYZ(          0,            0, -1.0*sy*sy/h);
 
 1102                 case 46: 
return XYZ(    sx*sy/h, -0.5*sy*sy/h,            0);
 
 1103                 case 47: 
return XYZ(    sx*sy/h,            0, -1.0*sy*sz/h);
 
 1104                 case 48: 
return XYZ(  2*sx*sz/h, -2.0*sy*sz/h,            0);
 
 1105                 case 49: 
return XYZ(  2*sx*sz/h,            0,-3*th*sz*sz/h);
 
 1108                 case 50: 
return XYZ(                   0,                   0,                   0);
 
 1109                 case 51: 
return XYZ(          sy*sy*sy/h,                   0,                   0);
 
 1110                 case 52: 
return XYZ(        2*sy*sy*sz/h,                   0,                   0);
 
 1111                 case 53: 
return XYZ(        3*sy*sz*sz/h,                   0,                   0);
 
 1112                 case 54: 
return XYZ(        4*sz*sz*sz/h,                   0,                   0);
 
 1113                 case 55: 
return XYZ(                   0,                   0,                   0);
 
 1114                 case 56: 
return XYZ(                   0,          sx*sx*sx/h,                   0);
 
 1115                 case 57: 
return XYZ(                   0,        2*sx*sx*sz/h,                   0);
 
 1116                 case 58: 
return XYZ(                   0,        3*sx*sz*sz/h,                   0);
 
 1117                 case 59: 
return XYZ(                   0,        4*sz*sz*sz/h,                   0);
 
 1118                 case 60: 
return XYZ(                   0,                   0,                   0);
 
 1119                 case 61: 
return XYZ(                   0,                   0,                   0);
 
 1120                 case 62: 
return XYZ(                   0,                   0,                   0);
 
 1121                 case 63: 
return XYZ(                   0,                   0,                   0);
 
 1122                 case 64: 
return XYZ(                   0,                   0,                   0);
 
 1124                 case 65: 
return XYZ(                   0,                   0,                   0);
 
 1125                 case 66: 
return XYZ(                   0,                   0,     -4.0*sx*sx*sx/h);
 
 1126                 case 67: 
return XYZ(                   0,                   0,                   0);
 
 1127                 case 68: 
return XYZ(                   0,                   0,     -3.0*sx*sx*sy/h);
 
 1128                 case 69: 
return XYZ(          sx*sx*sx/h,     -3.0*sx*sx*sy/h,                   0);
 
 1129                 case 70: 
return XYZ(          sx*sx*sx/h,                   0,     -3.0*sx*sx*sz/h);
 
 1130                 case 71: 
return XYZ(                   0,                   0,                   0);
 
 1131                 case 72: 
return XYZ(                   0,                   0,     -2.0*sx*sy*sy/h);
 
 1132                 case 73: 
return XYZ(          sx*sx*sy/h,         -sx*sy*sy/h,                   0);
 
 1133                 case 74: 
return XYZ(          sx*sx*sy/h,                   0,       -2*sx*sy*sz/h);
 
 1134                 case 75: 
return XYZ(        2*sx*sx*sz/h,     -4.0*sx*sy*sz/h,                   0);
 
 1135                 case 76: 
return XYZ(        2*sx*sx*sz/h,                   0,  -6.0*th*sx*sz*sz/h);
 
 1136                 case 77: 
return XYZ(                   0,                   0,                   0);
 
 1137                 case 78: 
return XYZ(                   0,                   0,         -sy*sy*sy/h);
 
 1138                 case 79: 
return XYZ(          sx*sy*sy/h,      -th*sy*sy*sy/h,                   0);
 
 1139                 case 80: 
return XYZ(          sx*sy*sy/h,                   0,     -1.0*sy*sy*sz/h);
 
 1140                 case 81: 
return XYZ(        2*sx*sy*sz/h,     -1.0*sy*sy*sz/h,                   0);
 
 1141                 case 82: 
return XYZ(        2*sx*sy*sz/h,                   0,    -3*th*sy*sz*sz/h);
 
 1142                 case 83: 
return XYZ(        3*sx*sz*sz/h,       -3*sy*sz*sz/h,                   0);
 
 1143                 case 84: 
return XYZ(        3*sx*sz*sz/h,                   0,     -1.0*sz*sz*sz/h);
 
 1147 ports up     to 4th-order polynomials for now.");
 
 1162     KOKKOS_INLINE_FUNCTION
 
 1166         if (partial_direction==0) {
 
 1169                 case 0: 
return XYZ(0.0,0.0,0.0);
 
 1170                 case 1: 
return XYZ(0.0,0.0,0.0);
 
 1173                 case 2: 
return XYZ(     0,      0, 0);
 
 1174                 case 3: 
return XYZ(     0,  1.0/h, 0);
 
 1175                 case 4: 
return XYZ( 1.0/h,      0, 0);
 
 1178                 case 5: 
return XYZ(          0,            0, 0);
 
 1179                 case 6: 
return XYZ(          0,       2*sx/h, 0);
 
 1181                 case 7: 
return XYZ(       2*sx/h,    -2.0*sy/h, 0);
 
 1182                 case 8: 
return XYZ(    -2.0*sy/h,            0, 0);
 
 1185                 case 9 : 
return XYZ(            0,               0, 0);
 
 1186                 case 10: 
return XYZ(            0,       3*sx*sx/h, 0);
 
 1188                 case 11: 
return XYZ(      3*sx*sx/h,    -6.0*sx*sy/h, 0);
 
 1189                 case 12: 
return XYZ(    2.0*sx*sy/h,    -1.0*sy*sy/h, 0);
 
 1190                 case 13: 
return XYZ(   -3.0*sy*sy/h,               0, 0);
 
 1193                 case 14: 
return XYZ(               0,                  0, 0);
 
 1194                 case 15: 
return XYZ(               0,       4*sx*sx*sx/h, 0);
 
 1196                 case 16: 
return XYZ(    4*sx*sx*sx/h,   -12.0*sx*sx*sy/h, 0);
 
 1197                 case 17: 
return XYZ(  6.0*sx*sx*sy/h,    -6.0*sx*sy*sy/h, 0);
 
 1198                 case 18: 
return XYZ( -6.0*sx*sy*sy/h,     2.0*sy*sy*sy/h, 0);
 
 1199                 case 19: 
return XYZ( -4.0*sy*sy*sy/h,                  0, 0);
 
 1203 ports up     to 4th-order polynomials for now.");
 
 1209                 case 0: 
return XYZ(0.0,0.0,0.0);
 
 1210                 case 1: 
return XYZ(0.0,0.0,0.0);
 
 1213                 case 2: 
return XYZ( 1.0/h,      0, 0);
 
 1214                 case 3: 
return XYZ(     0,      0, 0);
 
 1215                 case 4: 
return XYZ(     0, -1.0/h, 0);
 
 1218                 case 5: 
return XYZ(       2*sy/h,          0, 0);
 
 1219                 case 6: 
return XYZ(            0,          0, 0);
 
 1221                 case 7: 
return XYZ(            0,    -2.0*sx/h, 0);
 
 1222                 case 8: 
return XYZ(    -2.0*sx/h,       2*sy/h, 0);
 
 1225                 case 9 : 
return XYZ(      3*sy*sy/h,             0, 0);
 
 1226                 case 10: 
return XYZ(              0,             0, 0);
 
 1228                 case 11: 
return XYZ(              0,    -3.0*sx*sx/h, 0);
 
 1229                 case 12: 
return XYZ(        sx*sx/h,    -2.0*sx*sy/h, 0);
 
 1230                 case 13: 
return XYZ(   -6.0*sx*sy/h,       3*sy*sy/h, 0);
 
 1233                 case 14: 
return XYZ(      4*sy*sy*sy/h,                0, 0);
 
 1234                 case 15: 
return XYZ(                 0,                0, 0);
 
 1236                 case 16: 
return XYZ(                 0,    -4.0*sx*sx*sx/h, 0);
 
 1237                 case 17: 
return XYZ(    2.0*sx*sx*sx/h,    -6.0*sx*sx*sy/h, 0);
 
 1238                 case 18: 
return XYZ(   -6.0*sx*sx*sy/h,     6.0*sx*sy*sy/h, 0);
 
 1239                 case 19: 
return XYZ(  -12.0*sx*sy*sy/h,       4*sy*sy*sy/h, 0);
 
 1243 ports up     to 4th-order polynomials for now.");
 
KOKKOS_INLINE_FUNCTION int getSize(const int degree, const int dimension)
Returns size of basis. 
 
#define compadre_kernel_assert_release(condition)
compadre_kernel_assert_release is similar to compadre_assert_release, but is a call on the device...
 
KOKKOS_INLINE_FUNCTION void evaluate(const member_type &teamMember, double *delta, double *workspace, const int dimension, const int max_degree, const int component, const double h, const double x, const double y, const double z, const int starting_order=0, const double weight_of_original_value=0.0, const double weight_of_new_value=1.0)
Evaluates the divergence-free polynomial basis delta[j] = weight_of_original_value * delta[j] + weigh...
 
team_policy::member_type member_type
 
KOKKOS_INLINE_FUNCTION void evaluateSecondPartialDerivative(const member_type &teamMember, double *delta, double *workspace, const int dimension, const int max_degree, const int component, const int partial_direction_1, const int partial_direction_2, const double h, const double x, const double y, const double z, const int starting_order=0, const double weight_of_original_value=0.0, const double weight_of_new_value=1.0)
Evaluates the second partial derivatives of the divergence-free polynomial basis delta[j] = weight_of...
 
KOKKOS_INLINE_FUNCTION int getSize(const int degree, const int dimension)
Returns size of basis. 
 
KOKKOS_INLINE_FUNCTION void evaluatePartialDerivative(const member_type &teamMember, double *delta, double *workspace, const int dimension, const int max_degree, const int component, const int partial_direction, const double h, const double x, const double y, const double z, const int starting_order=0, const double weight_of_original_value=0.0, const double weight_of_new_value=1.0)
Evaluates the first partial derivatives of the divergence-free polynomial basis delta[j] = weight_of_...
 
Kokkos::View< double *, Kokkos::MemoryTraits< Kokkos::Unmanaged > > scratch_vector_type
 
import subprocess import os import re import math import sys import argparse d d d(20 *num_target_sites *pow(4, grid_num))