-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy patht202-elemrestriction.c
48 lines (41 loc) · 1.36 KB
/
t202-elemrestriction.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
/// @file
/// Test creation, use, and destruction of a blocked element restriction
/// \test Test creation, use, and destruction of a blocked element restriction
#include <ceed.h>
int main(int argc, char **argv) {
Ceed ceed;
CeedVector x, y;
CeedInt ne = 8;
CeedInt blksize = 5;
CeedInt ind[2*ne];
CeedScalar a[ne+1];
CeedElemRestriction r;
CeedInit(argv[1], &ceed);
CeedVectorCreate(ceed, ne+1, &x);
for (CeedInt i=0; i<ne+1; i++)
a[i] = 10 + i;
CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a);
for (CeedInt i=0; i<ne; i++) {
ind[2*i+0] = i;
ind[2*i+1] = i+1;
}
CeedElemRestrictionCreateBlocked(ceed, ne, 2, blksize, 1, 1, ne+1,
CEED_MEM_HOST, CEED_USE_POINTER, ind, &r);
CeedVectorCreate(ceed, 2*blksize*2, &y);
CeedVectorSetValue(y, 0); // Allocates array
// NoTranspose
CeedElemRestrictionApply(r, CEED_NOTRANSPOSE, x, y, CEED_REQUEST_IMMEDIATE);
CeedVectorView(y, "%12.8f", stdout);
// Transpose
CeedVectorGetArray(x, CEED_MEM_HOST, (CeedScalar **)&a);
for (CeedInt i=0; i<ne+1; i++)
a[i] = 0;
CeedVectorRestoreArray(x, (CeedScalar **)&a);
CeedElemRestrictionApply(r, CEED_TRANSPOSE, y, x, CEED_REQUEST_IMMEDIATE);
CeedVectorView(x, "%12.8f", stdout);
CeedVectorDestroy(&x);
CeedVectorDestroy(&y);
CeedElemRestrictionDestroy(&r);
CeedDestroy(&ceed);
return 0;
}