1 /// @file 2 /// Test creation, use, and destruction of an element restriction 3 /// \test Test creation, use, and destruction of an element restriction 4 #include <ceed.h> 5 6 int main(int argc, char **argv) { 7 Ceed ceed; 8 CeedVector x, y; 9 CeedInt num_elem = 3; 10 CeedInt ind[2*num_elem]; 11 CeedScalar a[num_elem+1]; 12 const CeedScalar *yy; 13 CeedElemRestriction r; 14 15 CeedInit(argv[1], &ceed); 16 17 CeedVectorCreate(ceed, num_elem+1, &x); 18 for (CeedInt i=0; i<num_elem+1; i++) 19 a[i] = 10 + i; 20 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a); 21 22 for (CeedInt i=0; i<num_elem; i++) { 23 ind[2*i+0] = i; 24 ind[2*i+1] = i+1; 25 } 26 CeedElemRestrictionCreate(ceed, num_elem, 2, 1, 1, num_elem+1, CEED_MEM_HOST, 27 CEED_USE_POINTER, ind, &r); 28 CeedVectorCreate(ceed, num_elem*2, &y); 29 CeedElemRestrictionApply(r, CEED_NOTRANSPOSE, x, y, CEED_REQUEST_IMMEDIATE); 30 31 CeedVectorGetArrayRead(y, CEED_MEM_HOST, &yy); 32 for (CeedInt i=0; i<num_elem*2; i++) 33 if (10+(i+1)/2 != yy[i]) 34 // LCOV_EXCL_START 35 printf("Error in restricted array y[%d] = %f", 36 i, (CeedScalar)yy[i]); 37 // LCOV_EXCL_STOP 38 CeedVectorRestoreArrayRead(y, &yy); 39 40 CeedVectorDestroy(&x); 41 CeedVectorDestroy(&y); 42 CeedElemRestrictionDestroy(&r); 43 CeedDestroy(&ceed); 44 return 0; 45 } 46