1*9c774eddSJeremy L Thompson /// @file 2*9c774eddSJeremy L Thompson /// Test CeedVectorGetArrayWrite to modify array 3*9c774eddSJeremy L Thompson /// \test Test CeedVectorGetArrayWrite to modify array 4*9c774eddSJeremy L Thompson #include <ceed.h> 5*9c774eddSJeremy L Thompson 6*9c774eddSJeremy L Thompson int main(int argc, char **argv) { 7*9c774eddSJeremy L Thompson Ceed ceed; 8*9c774eddSJeremy L Thompson CeedVector x; 9*9c774eddSJeremy L Thompson const CeedInt n = 10; 10*9c774eddSJeremy L Thompson CeedScalar *a; 11*9c774eddSJeremy L Thompson 12*9c774eddSJeremy L Thompson CeedInit(argv[1], &ceed); 13*9c774eddSJeremy L Thompson 14*9c774eddSJeremy L Thompson CeedVectorCreate(ceed, n, &x); 15*9c774eddSJeremy L Thompson 16*9c774eddSJeremy L Thompson CeedVectorGetArrayWrite(x, CEED_MEM_HOST, &a); 17*9c774eddSJeremy L Thompson for (CeedInt i = 0; i < n; i++) 18*9c774eddSJeremy L Thompson a[i] = 3*i; 19*9c774eddSJeremy L Thompson CeedVectorRestoreArray(x, &a); 20*9c774eddSJeremy L Thompson 21*9c774eddSJeremy L Thompson CeedVectorGetArrayRead(x, CEED_MEM_HOST, (const CeedScalar **)&a); 22*9c774eddSJeremy L Thompson for (CeedInt i = 0; i < n; i++) 23*9c774eddSJeremy L Thompson if (a[i] != (CeedScalar)(3*i)) 24*9c774eddSJeremy L Thompson // LCOV_EXCL_START 25*9c774eddSJeremy L Thompson printf("Error writing array a[%d] = %f", i, a[i]); 26*9c774eddSJeremy L Thompson // LCOV_EXCL_STOP 27*9c774eddSJeremy L Thompson CeedVectorRestoreArrayRead(x, (const CeedScalar **)&a); 28*9c774eddSJeremy L Thompson 29*9c774eddSJeremy L Thompson CeedVectorDestroy(&x); 30*9c774eddSJeremy L Thompson CeedDestroy(&ceed); 31*9c774eddSJeremy L Thompson return 0; 32*9c774eddSJeremy L Thompson } 33