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