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