xref: /libCEED/tests/t216-elemrestriction.c (revision 5cd6c1fb67d52eb6a42b887bb79c183682dd86ca)
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 #include <stdio.h>
6 
7 int main(int argc, char **argv) {
8   Ceed                ceed;
9   CeedInt             num_elem = 3, comp_stride = 1;
10   CeedInt             ind[2 * num_elem];
11   CeedElemRestriction elem_restriction, elem_restriction_2;
12 
13   CeedInit(argv[1], &ceed);
14 
15   for (CeedInt i = 0; i < num_elem; i++) {
16     ind[2 * i + 0] = i;
17     ind[2 * i + 1] = i + 1;
18   }
19   CeedElemRestrictionCreate(ceed, num_elem, 2, 1, comp_stride, num_elem + 1, CEED_MEM_HOST, CEED_USE_POINTER, ind, &elem_restriction);
20   CeedElemRestrictionCreate(ceed, num_elem, 2, 1, comp_stride + 1, num_elem + 1, CEED_MEM_HOST, CEED_USE_POINTER, ind, &elem_restriction_2);
21 
22   CeedElemRestrictionReferenceCopy(elem_restriction, &elem_restriction_2);  // This destroys the previous r_2
23   CeedElemRestrictionDestroy(&elem_restriction);
24 
25   CeedInt comp_stride_2;
26   CeedElemRestrictionGetCompStride(elem_restriction_2, &comp_stride_2);
27   if (comp_stride_2 != comp_stride) printf("Error copying CeedElemRestriction reference\n");
28 
29   CeedElemRestrictionDestroy(&elem_restriction_2);
30   CeedDestroy(&ceed);
31   return 0;
32 }
33