1 // Test creation, use, and destruction of a blocked element restriction 2 // with multiple components in the lvector 3 #include <ceed.h> 4 5 int main(int argc, char **argv) { 6 Ceed ceed; 7 CeedVector x, y; 8 CeedInt ne = 8; 9 CeedInt blksize = 5; 10 CeedInt ncomp = 3; 11 CeedInt ind[2*ne]; 12 CeedScalar a[ncomp*(ne+1)]; 13 CeedElemRestriction r; 14 15 CeedInit(argv[1], &ceed); 16 CeedVectorCreate(ceed, (ne+1)*ncomp, &x); 17 for (CeedInt i=0; i<(ne+1); i++) { 18 a[i+0*(ne+1)] = 10 + i; 19 a[i+1*(ne+1)] = 20 + i; 20 a[i+2*(ne+1)] = 30 + i; 21 } 22 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a); 23 CeedVectorView(x, "%12.8f", stdout); 24 for (CeedInt i=0; i<ne; i++) { 25 ind[2*i+0] = i; 26 ind[2*i+1] = i+1; 27 } 28 CeedElemRestrictionCreateBlocked(ceed, ne, 2, blksize, ne+1, ncomp, CEED_MEM_HOST, 29 CEED_USE_POINTER, ind, &r); 30 CeedVectorCreate(ceed, 2*blksize*2*ncomp, &y); 31 CeedVectorSetArray(y, CEED_MEM_HOST, CEED_COPY_VALUES, NULL); // Allocates array 32 33 // NoTranspose 34 CeedElemRestrictionApply(r, CEED_NOTRANSPOSE, CEED_NOTRANSPOSE, x, y, 35 CEED_REQUEST_IMMEDIATE); 36 CeedVectorView(y, "%12.8f", stdout); 37 38 // Transpose 39 CeedVectorGetArray(x, CEED_MEM_HOST, (CeedScalar **)&a); 40 for (CeedInt i=0; i<(ne+1)*ncomp; i++) a[i] = 0; 41 CeedVectorRestoreArray(x, (CeedScalar **)&a); 42 CeedElemRestrictionApply(r, CEED_TRANSPOSE, CEED_NOTRANSPOSE, y, x, 43 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