1*28bfd0b7SJeremy L Thompson /// @file 2*28bfd0b7SJeremy L Thompson /// Test read access for QFunctionContext data 3*28bfd0b7SJeremy L Thompson /// \test Test read access for QFunctionContext data 4*28bfd0b7SJeremy L Thompson #include <ceed.h> 5*28bfd0b7SJeremy L Thompson #include <math.h> 6*28bfd0b7SJeremy L Thompson 7*28bfd0b7SJeremy L Thompson int main(int argc, char **argv) { 8*28bfd0b7SJeremy L Thompson Ceed ceed; 9*28bfd0b7SJeremy L Thompson CeedQFunctionContext ctx; 10*28bfd0b7SJeremy L Thompson CeedScalar ctxData[5] = {1, 2, 3, 4, 5}, *ctxDataCopy; 11*28bfd0b7SJeremy L Thompson 12*28bfd0b7SJeremy L Thompson CeedInit(argv[1], &ceed); 13*28bfd0b7SJeremy L Thompson 14*28bfd0b7SJeremy L Thompson CeedQFunctionContextCreate(ceed, &ctx); 15*28bfd0b7SJeremy L Thompson CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, 16*28bfd0b7SJeremy L Thompson sizeof(ctxData), &ctxData); 17*28bfd0b7SJeremy L Thompson 18*28bfd0b7SJeremy L Thompson // Get data access 19*28bfd0b7SJeremy L Thompson CeedQFunctionContextGetDataRead(ctx, CEED_MEM_HOST, &ctxDataCopy); 20*28bfd0b7SJeremy L Thompson if (ctxData[4] != 5) 21*28bfd0b7SJeremy L Thompson // LCOV_EXCL_START 22*28bfd0b7SJeremy L Thompson printf("error reading data: %f != 5.0\n", ctxData[4]); 23*28bfd0b7SJeremy L Thompson // LCOV_EXCL_STOP 24*28bfd0b7SJeremy L Thompson CeedQFunctionContextRestoreDataRead(ctx, &ctxDataCopy); 25*28bfd0b7SJeremy L Thompson 26*28bfd0b7SJeremy L Thompson // Check access protection - should error 27*28bfd0b7SJeremy L Thompson CeedQFunctionContextGetDataRead(ctx, CEED_MEM_HOST, &ctxDataCopy); 28*28bfd0b7SJeremy L Thompson CeedQFunctionContextGetData(ctx, CEED_MEM_HOST, &ctxDataCopy); 29*28bfd0b7SJeremy L Thompson CeedQFunctionContextRestoreData(ctx, &ctxDataCopy); 30*28bfd0b7SJeremy L Thompson CeedQFunctionContextRestoreDataRead(ctx, &ctxDataCopy); 31*28bfd0b7SJeremy L Thompson 32*28bfd0b7SJeremy L Thompson CeedQFunctionContextDestroy(&ctx); 33*28bfd0b7SJeremy L Thompson CeedDestroy(&ceed); 34*28bfd0b7SJeremy L Thompson return 0; 35*28bfd0b7SJeremy L Thompson } 36