14411cf47Sjeremylt /// @file 252bfb9bbSJeremy L Thompson /// Test Collocated Grad calculated matches basis with Lobatto points 352bfb9bbSJeremy L Thompson /// \test Test Collocated Grad calculated matches basis with Lobatto points 457c64913Sjeremylt #include <ceed.h> 552bfb9bbSJeremy L Thompson #include <ceed-backend.h> 657c64913Sjeremylt #include <math.h> 757c64913Sjeremylt 857c64913Sjeremylt int main(int argc, char **argv) { 957c64913Sjeremylt Ceed ceed; 1052bfb9bbSJeremy L Thompson CeedInt P=4, Q=4; 11*b300f92cSjeremylt CeedScalar collograd1d[Q*Q], collograd1d2[(P+2)*(P+2)]; 1252bfb9bbSJeremy L Thompson CeedBasis b; 1357c64913Sjeremylt 1457c64913Sjeremylt CeedInit(argv[1], &ceed); 15aedaa0e5Sjeremylt 1652bfb9bbSJeremy L Thompson // Already collocated, GetCollocatedGrad will return grad1d 1752bfb9bbSJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, 1, 1, P, Q, CEED_GAUSS_LOBATTO, &b); 18*b300f92cSjeremylt CeedBasisGetCollocatedGrad(b, collograd1d); 19aedaa0e5Sjeremylt 2052bfb9bbSJeremy L Thompson CeedBasisView(b, stdout); 2152bfb9bbSJeremy L Thompson for (int i=0; i<Q; i++) { 22*b300f92cSjeremylt fprintf(stdout, "%12s[%d]:", "collograd1d", i); 2352bfb9bbSJeremy L Thompson for (int j=0; j<Q; j++) { 24*b300f92cSjeremylt if (fabs(collograd1d[j+Q*i]) <= 1E-14) collograd1d[j+Q*i] = 0; 25*b300f92cSjeremylt fprintf(stdout, "\t% 12.8f", collograd1d[j+Q*i]); 2657c64913Sjeremylt } 2752bfb9bbSJeremy L Thompson fprintf(stdout, "\n"); 2852bfb9bbSJeremy L Thompson } 2952bfb9bbSJeremy L Thompson CeedBasisDestroy(&b); 3057c64913Sjeremylt 3152bfb9bbSJeremy L Thompson // Q = P, not already collocated 3252bfb9bbSJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, 1, 1, P, Q, CEED_GAUSS, &b); 33*b300f92cSjeremylt CeedBasisGetCollocatedGrad(b, collograd1d); 3452bfb9bbSJeremy L Thompson 3552bfb9bbSJeremy L Thompson CeedBasisView(b, stdout); 3652bfb9bbSJeremy L Thompson for (int i=0; i<Q; i++) { 37*b300f92cSjeremylt fprintf(stdout, "%12s[%d]:", "collograd1d", i); 3852bfb9bbSJeremy L Thompson for (int j=0; j<Q; j++) { 39*b300f92cSjeremylt if (fabs(collograd1d[j+Q*i]) <= 1E-14) collograd1d[j+Q*i] = 0; 40*b300f92cSjeremylt fprintf(stdout, "\t% 12.8f", collograd1d[j+Q*i]); 4152bfb9bbSJeremy L Thompson } 4252bfb9bbSJeremy L Thompson fprintf(stdout, "\n"); 4352bfb9bbSJeremy L Thompson } 4452bfb9bbSJeremy L Thompson CeedBasisDestroy(&b); 4552bfb9bbSJeremy L Thompson 4652bfb9bbSJeremy L Thompson // Q = P + 2, not already collocated 4752bfb9bbSJeremy L Thompson CeedBasisCreateTensorH1Lagrange(ceed, 1, 1, P, P+2, CEED_GAUSS, &b); 48*b300f92cSjeremylt CeedBasisGetCollocatedGrad(b, collograd1d2); 4952bfb9bbSJeremy L Thompson 5052bfb9bbSJeremy L Thompson CeedBasisView(b, stdout); 5152bfb9bbSJeremy L Thompson for (int i=0; i<P+2; i++) { 52*b300f92cSjeremylt fprintf(stdout, "%12s[%d]:", "collograd1d", i); 5352bfb9bbSJeremy L Thompson for (int j=0; j<P+2; j++) { 54*b300f92cSjeremylt if (fabs(collograd1d2[j+(P+2)*i]) <= 1E-14) collograd1d2[j+(P+2)*i] = 0; 55*b300f92cSjeremylt fprintf(stdout, "\t% 12.8f", collograd1d2[j+(P+2)*i]); 5652bfb9bbSJeremy L Thompson } 5752bfb9bbSJeremy L Thompson fprintf(stdout, "\n"); 5852bfb9bbSJeremy L Thompson } 5952bfb9bbSJeremy L Thompson CeedBasisDestroy(&b); 6052bfb9bbSJeremy L Thompson 6157c64913Sjeremylt CeedDestroy(&ceed); 6257c64913Sjeremylt return 0; 6357c64913Sjeremylt } 64