-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy patht302-basis.c
60 lines (51 loc) · 1.79 KB
/
t302-basis.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/// @file
/// Test Collocated Grad calculated matches basis with Lobatto points
/// \test Test Collocated Grad calculated matches basis with Lobatto points
#include <ceed.h>
#include <ceed-backend.h>
#include <math.h>
int main(int argc, char **argv) {
Ceed ceed;
CeedInt P=4, Q=4;
CeedScalar collograd1d[Q*Q], collograd1d2[(P+2)*(P+2)];
CeedBasis b;
CeedInit(argv[1], &ceed);
// Already collocated, GetCollocatedGrad will return grad1d
CeedBasisCreateTensorH1Lagrange(ceed, 1, 1, P, Q, CEED_GAUSS_LOBATTO, &b);
CeedBasisGetCollocatedGrad(b, collograd1d);
for (int i=0; i<Q; i++) {
fprintf(stdout, "%12s[%d]:", "collograd1d", i);
for (int j=0; j<Q; j++) {
if (fabs(collograd1d[j+Q*i]) <= 1E-14) collograd1d[j+Q*i] = 0;
fprintf(stdout, "\t% 12.8f", collograd1d[j+Q*i]);
}
fprintf(stdout, "\n");
}
CeedBasisDestroy(&b);
// Q = P, not already collocated
CeedBasisCreateTensorH1Lagrange(ceed, 1, 1, P, Q, CEED_GAUSS, &b);
CeedBasisGetCollocatedGrad(b, collograd1d);
for (int i=0; i<Q; i++) {
fprintf(stdout, "%12s[%d]:", "collograd1d", i);
for (int j=0; j<Q; j++) {
if (fabs(collograd1d[j+Q*i]) <= 1E-14) collograd1d[j+Q*i] = 0;
fprintf(stdout, "\t% 12.8f", collograd1d[j+Q*i]);
}
fprintf(stdout, "\n");
}
CeedBasisDestroy(&b);
// Q = P + 2, not already collocated
CeedBasisCreateTensorH1Lagrange(ceed, 1, 1, P, P+2, CEED_GAUSS, &b);
CeedBasisGetCollocatedGrad(b, collograd1d2);
for (int i=0; i<P+2; i++) {
fprintf(stdout, "%12s[%d]:", "collograd1d", i);
for (int j=0; j<P+2; j++) {
if (fabs(collograd1d2[j+(P+2)*i]) <= 1E-14) collograd1d2[j+(P+2)*i] = 0;
fprintf(stdout, "\t% 12.8f", collograd1d2[j+(P+2)*i]);
}
fprintf(stdout, "\n");
}
CeedBasisDestroy(&b);
CeedDestroy(&ceed);
return 0;
}