14411cf47Sjeremylt /// @file 24411cf47Sjeremylt /// Test creation, use, and destruction of a blocked element restriction with multiple components in the lvector 34411cf47Sjeremylt /// \test Test creation, use, and destruction of a blocked element restriction with multiple components in the lvector 457c64913Sjeremylt #include <ceed.h> 557c64913Sjeremylt 657c64913Sjeremylt int main(int argc, char **argv) { 757c64913Sjeremylt Ceed ceed; 857c64913Sjeremylt CeedVector x, y; 957c64913Sjeremylt CeedInt ne = 8; 1057c64913Sjeremylt CeedInt blksize = 5; 1157c64913Sjeremylt CeedInt ncomp = 3; 1257c64913Sjeremylt CeedInt ind[2*ne]; 1357c64913Sjeremylt CeedScalar a[ncomp*(ne+1)]; 1457c64913Sjeremylt CeedElemRestriction r; 1557c64913Sjeremylt 1657c64913Sjeremylt CeedInit(argv[1], &ceed); 17288c0443SJeremy L Thompson 1857c64913Sjeremylt CeedVectorCreate(ceed, (ne+1)*ncomp, &x); 1957c64913Sjeremylt for (CeedInt i=0; i<(ne+1); i++) { 2057c64913Sjeremylt a[i+0*(ne+1)] = 10 + i; 2157c64913Sjeremylt a[i+1*(ne+1)] = 20 + i; 2257c64913Sjeremylt a[i+2*(ne+1)] = 30 + i; 2357c64913Sjeremylt } 2457c64913Sjeremylt CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a); 2557c64913Sjeremylt CeedVectorView(x, "%12.8f", stdout); 2657c64913Sjeremylt for (CeedInt i=0; i<ne; i++) { 2757c64913Sjeremylt ind[2*i+0] = i; 2857c64913Sjeremylt ind[2*i+1] = i+1; 2957c64913Sjeremylt } 30*d979a051Sjeremylt CeedElemRestrictionCreateBlocked(ceed, ne, 2, blksize, ncomp, ne+1, 31*d979a051Sjeremylt ncomp*(ne+1), CEED_MEM_HOST, 32*d979a051Sjeremylt CEED_USE_POINTER, ind, &r); 3357c64913Sjeremylt CeedVectorCreate(ceed, 2*blksize*2*ncomp, &y); 3473d26085Sjeremylt CeedVectorSetValue(y, 0); // Allocates array 3557c64913Sjeremylt 3657c64913Sjeremylt // NoTranspose 37a8d32208Sjeremylt CeedElemRestrictionApply(r, CEED_NOTRANSPOSE, x, y, CEED_REQUEST_IMMEDIATE); 3857c64913Sjeremylt CeedVectorView(y, "%12.8f", stdout); 3957c64913Sjeremylt 4057c64913Sjeremylt // Transpose 41*d979a051Sjeremylt CeedVectorSetValue(x, 0.0); 42a8d32208Sjeremylt CeedElemRestrictionApply(r, CEED_TRANSPOSE, y, x, CEED_REQUEST_IMMEDIATE); 4357c64913Sjeremylt CeedVectorView(x, "%12.8f", stdout); 4457c64913Sjeremylt 4557c64913Sjeremylt CeedVectorDestroy(&x); 4657c64913Sjeremylt CeedVectorDestroy(&y); 4757c64913Sjeremylt CeedElemRestrictionDestroy(&r); 4857c64913Sjeremylt CeedDestroy(&ceed); 4957c64913Sjeremylt return 0; 5057c64913Sjeremylt } 51