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 CeedInterlaceMode imode = CEED_NONINTERLACED; 15 16 CeedInit(argv[1], &ceed); 17 18 CeedVectorCreate(ceed, ne+1, &x); 19 for (CeedInt i=0; i<ne+1; i++) 20 a[i] = 10 + i; 21 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a); 22 23 for (CeedInt i=0; i<ne; i++) { 24 ind[2*i+0] = i; 25 ind[2*i+1] = i+1; 26 } 27 CeedElemRestrictionCreateBlocked(ceed, imode, ne, 2, blksize, ne+1, 1, 28 CEED_MEM_HOST, CEED_USE_POINTER, ind, &r); 29 CeedVectorCreate(ceed, 2*blksize*2, &y); 30 CeedVectorSetValue(y, 0); // Allocates array 31 32 // NoTranspose 33 CeedElemRestrictionApply(r, CEED_NOTRANSPOSE, x, y, CEED_REQUEST_IMMEDIATE); 34 CeedVectorView(y, "%12.8f", stdout); 35 36 // Transpose 37 CeedVectorGetArray(x, CEED_MEM_HOST, (CeedScalar **)&a); 38 for (CeedInt i=0; i<ne+1; i++) 39 a[i] = 0; 40 CeedVectorRestoreArray(x, (CeedScalar **)&a); 41 CeedElemRestrictionApply(r, CEED_TRANSPOSE, y, x, CEED_REQUEST_IMMEDIATE); 42 CeedVectorView(x, "%12.8f", stdout); 43 44 CeedVectorDestroy(&x); 45 CeedVectorDestroy(&y); 46 CeedElemRestrictionDestroy(&r); 47 CeedDestroy(&ceed); 48 return 0; 49 } 50