1 // Test creation, use, and destruction of a blocked element restriction 2 #include <ceed.h> 3 4 int main(int argc, char **argv) { 5 Ceed ceed; 6 CeedVector x, y; 7 CeedInt ne = 8; 8 CeedInt blksize = 5; 9 CeedInt ind[2*ne]; 10 CeedScalar a[ne+1]; 11 CeedElemRestriction r; 12 13 CeedInit(argv[1], &ceed); 14 CeedVectorCreate(ceed, ne+1, &x); 15 for (CeedInt i=0; i<ne+1; i++) a[i] = 10 + i; 16 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a); 17 18 for (CeedInt i=0; i<ne; i++) { 19 ind[2*i+0] = i; 20 ind[2*i+1] = i+1; 21 } 22 CeedElemRestrictionCreateBlocked(ceed, ne, 2, blksize, ne+1, 1, CEED_MEM_HOST, 23 CEED_USE_POINTER, ind, &r); 24 CeedVectorCreate(ceed, 2*blksize*2, &y); 25 CeedVectorSetArray(y, CEED_MEM_HOST, CEED_COPY_VALUES, NULL); // Allocates array 26 27 // NoTranspose 28 CeedElemRestrictionApply(r, CEED_NOTRANSPOSE, CEED_NOTRANSPOSE, x, y, 29 CEED_REQUEST_IMMEDIATE); 30 CeedVectorView(y, "%12.8f", stdout); 31 32 // Transpose 33 CeedVectorGetArray(x, CEED_MEM_HOST, (CeedScalar **)&a); 34 for (CeedInt i=0; i<ne+1; i++) a[i] = 0; 35 CeedVectorRestoreArray(x, (CeedScalar **)&a); 36 CeedElemRestrictionApply(r, CEED_TRANSPOSE, CEED_NOTRANSPOSE, y, x, 37 CEED_REQUEST_IMMEDIATE); 38 CeedVectorView(x, "%12.8f", stdout); 39 40 CeedVectorDestroy(&x); 41 CeedVectorDestroy(&y); 42 CeedElemRestrictionDestroy(&r); 43 CeedDestroy(&ceed); 44 return 0; 45 } 46