xref: /libCEED/tests/t209-elemrestriction.c (revision 619db83ca0bfb3c95755a4b437abc8047796c977)
1 /// @file
2 /// Test calculation of dof multiplicity in element restriction
3 /// \test Test calculation of dof multiplicity in element restriction
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed ceed;
8   CeedVector mult;
9   CeedInt num_elem = 3;
10   CeedInt ind[4*num_elem];
11   const CeedScalar *mm;
12   CeedElemRestriction r;
13 
14   CeedInit(argv[1], &ceed);
15 
16   CeedVectorCreate(ceed, 3*num_elem+1, &mult);
17   CeedVectorSetValue(mult, 0); // Allocates array
18 
19   for (CeedInt i=0; i<num_elem; i++) {
20     ind[4*i+0] = i*3+0;
21     ind[4*i+1] = i*3+1;
22     ind[4*i+2] = i*3+2;
23     ind[4*i+3] = i*3+3;
24   }
25   CeedElemRestrictionCreate(ceed, num_elem, 4, 1, 1, 3*num_elem+1, CEED_MEM_HOST,
26                             CEED_USE_POINTER, ind, &r);
27 
28   CeedElemRestrictionGetMultiplicity(r, mult);
29 
30   CeedVectorGetArrayRead(mult, CEED_MEM_HOST, &mm);
31   for (CeedInt i=0; i<3*num_elem+1; i++)
32     if ((1 + (i > 0 && i < 3*num_elem && (i%3==0) ? 1 : 0)) != mm[i])
33       // LCOV_EXCL_START
34       printf("Error in multiplicity vector: mult[%d] = %f\n", i, (double)mm[i]);
35   // LCOV_EXCL_STOP
36   CeedVectorRestoreArrayRead(mult, &mm);
37 
38   CeedVectorDestroy(&mult);
39   CeedElemRestrictionDestroy(&r);
40   CeedDestroy(&ceed);
41   return 0;
42 }
43