xref: /libCEED/tests/t216-elemrestriction.c (revision bf4cb66493dbcc06b8d25c9c91cf89fe1cab7c9b)
1 /// @file
2 /// Test creation, copying, and destruction of an element restriction
3 /// \test Test creation, copying, and destruction of an element restriction
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed ceed;
8   CeedInt num_elem = 3, comp_stride = 1;
9   CeedInt ind[2*num_elem];
10   CeedElemRestriction r, r_2;
11 
12   CeedInit(argv[1], &ceed);
13 
14   for (CeedInt i=0; i<num_elem; i++) {
15     ind[2*i+0] = i;
16     ind[2*i+1] = i+1;
17   }
18   CeedElemRestrictionCreate(ceed, num_elem, 2, 1, comp_stride, num_elem+1,
19                             CEED_MEM_HOST, CEED_USE_POINTER, ind, &r);
20   CeedElemRestrictionCreate(ceed, num_elem, 2, 1, comp_stride+1, num_elem+1,
21                             CEED_MEM_HOST, CEED_USE_POINTER, ind, &r_2);
22 
23   CeedElemRestrictionReferenceCopy(r, &r_2); // This destroys the previous r_2
24   CeedElemRestrictionDestroy(&r);
25 
26   CeedInt comp_stride_2;
27   CeedElemRestrictionGetCompStride(r_2, &comp_stride_2);
28   if (comp_stride_2 != comp_stride)
29     // LCOV_EXCL_START
30     printf("Error copying CeedElemRestriction reference.");
31   // LCOV_EXCL_STOP
32 
33   CeedElemRestrictionDestroy(&r_2);
34   CeedDestroy(&ceed);
35   return 0;
36 }
37