1 #ifndef _GMLS_TUTORIAL_HPP_
2 #define _GMLS_TUTORIAL_HPP_
4 #include <Kokkos_Core.hpp>
10 return (d1 > d2) ? d1 : d2;
13 KOKKOS_INLINE_FUNCTION
14 double trueSolution(
double x,
double y,
double z,
int order,
int dimension) {
16 for (
int i=0; i<order+1; i++) {
17 for (
int j=0; j<order+1; j++) {
18 for (
int k=0; k<order+1; k++) {
20 ans += std::pow(x,i)*std::pow(y,j)*std::pow(z,k);
28 KOKKOS_INLINE_FUNCTION
29 double trueLaplacian(
double x,
double y,
double z,
int order,
int dimension) {
31 for (
int i=0; i<order+1; i++) {
32 for (
int j=0; j<order+1; j++) {
33 for (
int k=0; k<order+1; k++) {
36 std::pow(x,
device_max(0,i-2))*std::pow(y,j)*std::pow(z,k);
42 for (
int i=0; i<order+1; i++) {
43 for (
int j=0; j<order+1; j++) {
44 for (
int k=0; k<order+1; k++) {
47 std::pow(x,i)*std::pow(y,
device_max(0,j-2))*std::pow(z,k);
54 for (
int i=0; i<order+1; i++) {
55 for (
int j=0; j<order+1; j++) {
56 for (
int k=0; k<order+1; k++) {
59 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-2));
68 KOKKOS_INLINE_FUNCTION
69 void trueGradient(
double* ans,
double x,
double y,
double z,
int order,
int dimension) {
71 for (
int i=0; i<order+1; i++) {
72 for (
int j=0; j<order+1; j++) {
73 for (
int k=0; k<order+1; k++) {
76 std::pow(x,
device_max(0,i-1))*std::pow(y,j)*std::pow(z,k);
82 for (
int i=0; i<order+1; i++) {
83 for (
int j=0; j<order+1; j++) {
84 for (
int k=0; k<order+1; k++) {
87 std::pow(x,i)*std::pow(y,
device_max(0,j-1))*std::pow(z,k);
94 for (
int i=0; i<order+1; i++) {
95 for (
int j=0; j<order+1; j++) {
96 for (
int k=0; k<order+1; k++) {
99 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-1));
107 KOKKOS_INLINE_FUNCTION
110 for (
int i=0; i<order+1; i++) {
111 for (
int j=0; j<order+1; j++) {
112 for (
int k=0; k<order+1; k++) {
113 if (i+j+k <= order) {
115 std::pow(x,
device_max(0,i-1))*std::pow(y,j)*std::pow(z,k);
121 for (
int i=0; i<order+1; i++) {
122 for (
int j=0; j<order+1; j++) {
123 for (
int k=0; k<order+1; k++) {
124 if (i+j+k <= order) {
126 std::pow(x,i)*std::pow(y,
device_max(0,j-1))*std::pow(z,k);
133 for (
int i=0; i<order+1; i++) {
134 for (
int j=0; j<order+1; j++) {
135 for (
int k=0; k<order+1; k++) {
136 if (i+j+k <= order) {
138 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-1));
147 KOKKOS_INLINE_FUNCTION
148 void trueHessian(
double* ans,
double x,
double y,
double z,
int order,
int dimension) {
149 for (
int i=0; i<order+1; i++) {
150 for (
int j=0; j<order+1; j++) {
151 for (
int k=0; k<order+1; k++) {
152 if (i+j+k <= order) {
155 std::pow(x,
device_max(0,i-2))*std::pow(y,j)*std::pow(z,k);
161 ans[1*dimension+0] = ans[1];
164 std::pow(x,i)*std::pow(y,
device_max(0,j-2))*std::pow(z,k);
174 ans[2*dimension+0] = ans[2];
176 ans[2*dimension+1] = ans[1*dimension+2];
179 std::pow(x,i)*std::pow(y,j)*std::pow(z,
device_max(0,k-2));
187 KOKKOS_INLINE_FUNCTION
192 return x*x + y*y - z*z;
194 return 2*x +3*y + 4*z;
196 return -21*x*y + 3*z*x*y + 4*z;
200 KOKKOS_INLINE_FUNCTION
209 return 2*x + 3 + 3*x*y + 4;
213 KOKKOS_INLINE_FUNCTION
220 return (-21*x + 3*z*x) - 4;
223 return (21*y - 3*z*y) - 2*z;
228 }
else if (dimension==2) {
242 KOKKOS_INLINE_FUNCTION
248 return 6.0*x*x*y - 9.0*x*y + 7.0*x*z*z + 6.0*y*y*z;
250 return 10.0*x*x*z - 7.0*y*z*z - 6.0*x*y*y;
252 return -2.0*x*x*x + 9.0*x*y*y + 9.0*y*z;
254 }
else if (dimension==2) {
266 KOKKOS_INLINE_FUNCTION
271 for (
int i=0; i<NP; ++i) {
273 val += basis_i[component];
276 for (
int i=0; i<NP; ++i) {
278 val += basis_i[component];
284 KOKKOS_INLINE_FUNCTION
290 return -10.0*x*x + 18.0*x*y + 14.0*y*z + 9.0*z;
292 return 6.0*x*x + 14.0*x*z - 3.0*y*y;
294 return -6.0*x*x + 20.0*x*z + 9.0*x - 6.0*y*y - 12.0*y*z;
301 KOKKOS_INLINE_FUNCTION
307 for (
int i=0; i<NP; ++i) {
310 val += grad_y[2] - grad_z[1];
312 }
else if (component==1) {
313 for (
int i=0; i<NP; ++i) {
316 val += -grad_x[2] + grad_z[0];
318 }
else if (component==2) {
319 for (
int i=0; i<NP; ++i) {
322 val += grad_x[1] - grad_y[0];
326 }
else if (dimension==2) {
328 for (
int i=0; i<NP; ++i) {
331 val += grad_x[1] - grad_y[0];
340 KOKKOS_INLINE_FUNCTION
346 return -14.0*x - 12.0*y - 12.0*z;
348 return 12.0*x + 14.0*y - 20.0*z;
352 }
else if (dimension==2) {
364 KOKKOS_INLINE_FUNCTION
369 return 12.0*x*y - 9.0*y + 7.0*z*z;
371 return 6.0*x*x - 9.0*x + 12.0*y*z;
373 return 14.0*x*z + 6.0*y*y;
375 return 20.0*x*z - 6.0*y*y;
377 return -7.0*z*z - 12.0*x*y;
379 return 10.0*x*x - 14.0*y*z;
381 return -6.0*x*x + 9.0*y*y;
383 return 18.0*x*y + 9.0*z;
403 KOKKOS_INLINE_FUNCTION
408 for (
int i=0; i<NP; ++i) {
410 val += basis_i[input_component];
413 for (
int i=0; i<NP; ++i) {
415 val += basis_i[input_component];
425 int main (
int argc,
char* args[]);
Divergence-free vector polynomial basis.
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)
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)
int main(int argc, char *args[])
[Parse Command Line Arguments]
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)
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)