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 #include <stdio.h> 6 7 int main(int argc, char **argv) { 8 Ceed ceed; 9 CeedVector mult; 10 CeedInt num_elem = 3; 11 CeedInt ind[4 * num_elem]; 12 CeedElemRestriction elem_restriction; 13 14 CeedInit(argv[1], &ceed); 15 16 CeedVectorCreate(ceed, 3 * num_elem + 1, &mult); 17 18 for (CeedInt i = 0; i < num_elem; i++) { 19 ind[4 * i + 0] = i * 3 + 0; 20 ind[4 * i + 1] = i * 3 + 1; 21 ind[4 * i + 2] = i * 3 + 2; 22 ind[4 * i + 3] = i * 3 + 3; 23 } 24 CeedElemRestrictionCreate(ceed, num_elem, 4, 1, 1, 3 * num_elem + 1, CEED_MEM_HOST, CEED_USE_POINTER, ind, &elem_restriction); 25 26 CeedElemRestrictionGetMultiplicity(elem_restriction, mult); 27 { 28 const CeedScalar *mult_array; 29 30 CeedVectorGetArrayRead(mult, CEED_MEM_HOST, &mult_array); 31 for (CeedInt i = 0; i < 3 * num_elem + 1; i++) { 32 if (mult_array[i] != (1 + (i > 0 && i < 3 * num_elem && (i % 3 == 0) ? 1 : 0))) { 33 // LCOV_EXCL_START 34 printf("Error in multiplicity vector: mult[%" CeedInt_FMT "] = %f\n", i, (CeedScalar)mult_array[i]); 35 // LCOV_EXCL_STOP 36 } 37 } 38 CeedVectorRestoreArrayRead(mult, &mult_array); 39 } 40 41 CeedVectorDestroy(&mult); 42 CeedElemRestrictionDestroy(&elem_restriction); 43 CeedDestroy(&ceed); 44 return 0; 45 } 46