1 /// @file 2 /// Test creation, setting, and taking data for QFunctionContext 3 /// \test Test creation, setting, and taking data for QFunctionContext 4 #include <ceed.h> 5 #include <math.h> 6 7 int main(int argc, char **argv) { 8 Ceed ceed; 9 CeedQFunctionContext ctx; 10 CeedScalar ctxData[5] = {1, 2, 3, 4, 5}, *ctxDataCopy; 11 12 CeedInit(argv[1], &ceed); 13 14 CeedQFunctionContextCreate(ceed, &ctx); 15 CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_USE_POINTER, 16 sizeof(ctxData), &ctxData); 17 18 CeedQFunctionContextGetData(ctx, CEED_MEM_HOST, &ctxDataCopy); 19 ctxDataCopy[4] = 6; 20 CeedQFunctionContextRestoreData(ctx, &ctxDataCopy); 21 if (fabs(ctxData[4] - 6) > 1.e-14) 22 // LCOV_EXCL_START 23 printf("error modifying data: %f != 6.0\n", ctxData[4]); 24 // LCOV_EXCL_STOP 25 26 // Verify that taking the data revokes access 27 CeedQFunctionContextTakeData(ctx, CEED_MEM_HOST, &ctxDataCopy); 28 CeedQFunctionContextGetData(ctx, CEED_MEM_HOST, &ctxDataCopy); 29 30 // LCOV_EXCL_START 31 CeedQFunctionContextDestroy(&ctx); 32 CeedDestroy(&ceed); 33 return 0; 34 // LCOV_EXCL_STOP 35 } 36