9 #ifndef _GMLS_TUTORIAL_HPP_
10 #define _GMLS_TUTORIAL_HPP_
12 #include <Kokkos_Core.hpp>
16 KOKKOS_INLINE_FUNCTION
18 return (d1 > d2) ? d1 : d2;
21 KOKKOS_INLINE_FUNCTION
22 double trueSolution(
double x,
double y,
double z,
int order,
int dimension) {
24 for (
int i=0; i<order+1; i++) {
25 for (
int j=0; j<order+1; j++) {
26 for (
int k=0; k<order+1; k++) {
28 ans += std::pow(x,i)*std::pow(y,j)*std::pow(z,k);
36 KOKKOS_INLINE_FUNCTION
37 double trueLaplacian(
double x,
double y,
double z,
int order,
int dimension) {
39 for (
int i=0; i<order+1; i++) {
40 for (
int j=0; j<order+1; j++) {
41 for (
int k=0; k<order+1; k++) {
44 std::pow(x,
device_max(0,i-2))*std::pow(y,j)*std::pow(z,k);
50 for (
int i=0; i<order+1; i++) {
51 for (
int j=0; j<order+1; j++) {
52 for (
int k=0; k<order+1; k++) {
55 std::pow(x,i)*std::pow(y,
device_max(0,j-2))*std::pow(z,k);
62 for (
int i=0; i<order+1; i++) {
63 for (
int j=0; j<order+1; j++) {
64 for (
int k=0; k<order+1; k++) {
67 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-2));
76 KOKKOS_INLINE_FUNCTION
77 void trueGradient(
double* ans,
double x,
double y,
double z,
int order,
int dimension) {
79 for (
int i=0; i<order+1; i++) {
80 for (
int j=0; j<order+1; j++) {
81 for (
int k=0; k<order+1; k++) {
84 std::pow(x,
device_max(0,i-1))*std::pow(y,j)*std::pow(z,k);
90 for (
int i=0; i<order+1; i++) {
91 for (
int j=0; j<order+1; j++) {
92 for (
int k=0; k<order+1; k++) {
95 std::pow(x,i)*std::pow(y,
device_max(0,j-1))*std::pow(z,k);
102 for (
int i=0; i<order+1; i++) {
103 for (
int j=0; j<order+1; j++) {
104 for (
int k=0; k<order+1; k++) {
105 if (i+j+k <= order) {
107 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-1));
115 KOKKOS_INLINE_FUNCTION
118 for (
int i=0; i<order+1; i++) {
119 for (
int j=0; j<order+1; j++) {
120 for (
int k=0; k<order+1; k++) {
121 if (i+j+k <= order) {
123 std::pow(x,
device_max(0,i-1))*std::pow(y,j)*std::pow(z,k);
129 for (
int i=0; i<order+1; i++) {
130 for (
int j=0; j<order+1; j++) {
131 for (
int k=0; k<order+1; k++) {
132 if (i+j+k <= order) {
134 std::pow(x,i)*std::pow(y,
device_max(0,j-1))*std::pow(z,k);
141 for (
int i=0; i<order+1; i++) {
142 for (
int j=0; j<order+1; j++) {
143 for (
int k=0; k<order+1; k++) {
144 if (i+j+k <= order) {
146 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-1));
155 KOKKOS_INLINE_FUNCTION
156 void trueHessian(
double* ans,
double x,
double y,
double z,
int order,
int dimension) {
157 for (
int i=0; i<order+1; i++) {
158 for (
int j=0; j<order+1; j++) {
159 for (
int k=0; k<order+1; k++) {
160 if (i+j+k <= order) {
163 std::pow(x,
device_max(0,i-2))*std::pow(y,j)*std::pow(z,k);
169 ans[1*dimension+0] = ans[1];
172 std::pow(x,i)*std::pow(y,
device_max(0,j-2))*std::pow(z,k);
182 ans[2*dimension+0] = ans[2];
184 ans[2*dimension+1] = ans[1*dimension+2];
187 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-2));
195 KOKKOS_INLINE_FUNCTION
200 return x*x + y*y - z*z;
202 return 2*x +3*y + 4*z;
204 return -21*x*y + 3*z*x*y + 4*z;
208 KOKKOS_INLINE_FUNCTION
217 return 2*x + 3 + 3*x*y + 4;
221 KOKKOS_INLINE_FUNCTION
228 return (-21*x + 3*z*x) - 4;
231 return (21*y - 3*z*y) - 2*z;
236 }
else if (dimension==2) {
250 KOKKOS_INLINE_FUNCTION
256 return 6.0*x*x*y - 9.0*x*y + 7.0*x*z*z + 6.0*y*y*z;
258 return 10.0*x*x*z - 7.0*y*z*z - 6.0*x*y*y;
260 return -2.0*x*x*x + 9.0*x*y*y + 9.0*y*z;
262 }
else if (dimension==2) {
274 KOKKOS_INLINE_FUNCTION
279 for (
int i=0; i<NP; ++i) {
281 val += basis_i[component];
284 for (
int i=0; i<NP; ++i) {
286 val += basis_i[component];
292 KOKKOS_INLINE_FUNCTION
298 return -10.0*x*x + 18.0*x*y + 14.0*y*z + 9.0*z;
300 return 6.0*x*x + 14.0*x*z - 3.0*y*y;
302 return -6.0*x*x + 20.0*x*z + 9.0*x - 6.0*y*y - 12.0*y*z;
309 KOKKOS_INLINE_FUNCTION
315 for (
int i=0; i<NP; ++i) {
318 val += grad_y[2] - grad_z[1];
320 }
else if (component==1) {
321 for (
int i=0; i<NP; ++i) {
324 val += -grad_x[2] + grad_z[0];
326 }
else if (component==2) {
327 for (
int i=0; i<NP; ++i) {
330 val += grad_x[1] - grad_y[0];
334 }
else if (dimension==2) {
336 for (
int i=0; i<NP; ++i) {
339 val += grad_x[1] - grad_y[0];
348 KOKKOS_INLINE_FUNCTION
354 return -14.0*x - 12.0*y - 12.0*z;
356 return 12.0*x + 14.0*y - 20.0*z;
360 }
else if (dimension==2) {
372 KOKKOS_INLINE_FUNCTION
377 return 12.0*x*y - 9.0*y + 7.0*z*z;
379 return 6.0*x*x - 9.0*x + 12.0*y*z;
381 return 14.0*x*z + 6.0*y*y;
383 return 20.0*x*z - 6.0*y*y;
385 return -7.0*z*z - 12.0*x*y;
387 return 10.0*x*x - 14.0*y*z;
389 return -6.0*x*x + 9.0*y*y;
391 return 18.0*x*y + 9.0*z;
411 KOKKOS_INLINE_FUNCTION
416 for (
int i=0; i<NP; ++i) {
418 val += basis_i[input_component];
421 for (
int i=0; i<NP; ++i) {
423 val += basis_i[input_component];
433 int main (
int argc,
char* args[]);
KOKKOS_INLINE_FUNCTION double divfreeTestSolution_span_basis(double x, double y, double z, int component, int dimension, int exact_order)
KOKKOS_INLINE_FUNCTION double gradientdivfreeTestSolution_single_polynomial(double x, double y, double z, int component, int dimension)
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...
KOKKOS_INLINE_FUNCTION void trueHessian(double *ans, double x, double y, double z, int order, int dimension)
KOKKOS_INLINE_FUNCTION double curldivfreeTestSolution_span_basis(double x, double y, double z, int component, int dimension, int exact_order)
int main(int argc, char **argv)
KOKKOS_INLINE_FUNCTION double curlcurldivfreeTestSolution_single_polynomial(double x, double y, double z, int component, int dimension)
KOKKOS_INLINE_FUNCTION double device_max(double d1, double d2)
static KOKKOS_INLINE_FUNCTION int getNP(const int m, const int dimension=3, const ReconstructionSpace r_space=ReconstructionSpace::ScalarTaylorPolynomial)
Returns size of the basis for a given polynomial order and dimension General to dimension 1...
KOKKOS_INLINE_FUNCTION void trueGradient(double *ans, double x, double y, double z, int order, int dimension)
KOKKOS_INLINE_FUNCTION double divfreeTestSolution_single_polynomial(double x, double y, double z, int component, int dimension)
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_INLINE_FUNCTION double divergenceTestSolution(double x, double y, double z, int dimension)
KOKKOS_INLINE_FUNCTION double trueLaplacian(double x, double y, double z, int order, int dimension)
KOKKOS_INLINE_FUNCTION double curlTestSolution(double x, double y, double z, int component, int dimension)
KOKKOS_INLINE_FUNCTION double divergenceTestSamples(double x, double y, double z, int component, int dimension)
Divergence-free vector polynomial basis.
KOKKOS_INLINE_FUNCTION double gradientdivfreeTestSolution_span_basis(double x, double y, double z, int input_component, int output_component, int dimension, int exact_order)
KOKKOS_INLINE_FUNCTION double curldivfreeTestSolution_single_polynomial(double x, double y, double z, int component, int dimension)
KOKKOS_INLINE_FUNCTION double trueSolution(double x, double y, double z, int order, int dimension)
KOKKOS_INLINE_FUNCTION double trueDivergence(double x, double y, double z, int order, int dimension)