19c774eddSJeremy L Thompson /// @file 29c774eddSJeremy L Thompson /// Test CeedVectorGetArrayWrite to modify array 39c774eddSJeremy L Thompson /// \test Test CeedVectorGetArrayWrite to modify array 49c774eddSJeremy L Thompson #include <ceed.h> 59c774eddSJeremy L Thompson 69c774eddSJeremy L Thompson int main(int argc, char **argv) { 79c774eddSJeremy L Thompson Ceed ceed; 89c774eddSJeremy L Thompson CeedVector x; 99c774eddSJeremy L Thompson const CeedInt n = 10; 109c774eddSJeremy L Thompson CeedScalar *a; 119c774eddSJeremy L Thompson 129c774eddSJeremy L Thompson CeedInit(argv[1], &ceed); 139c774eddSJeremy L Thompson 149c774eddSJeremy L Thompson CeedVectorCreate(ceed, n, &x); 159c774eddSJeremy L Thompson 169c774eddSJeremy L Thompson CeedVectorGetArrayWrite(x, CEED_MEM_HOST, &a); 17*2b730f8bSJeremy L Thompson for (CeedInt i = 0; i < n; i++) a[i] = 3 * i; 189c774eddSJeremy L Thompson CeedVectorRestoreArray(x, &a); 199c774eddSJeremy L Thompson 209c774eddSJeremy L Thompson CeedVectorGetArrayRead(x, CEED_MEM_HOST, (const CeedScalar **)&a); 21*2b730f8bSJeremy L Thompson for (CeedInt i = 0; i < n; i++) { 22*2b730f8bSJeremy L Thompson if (a[i] != (CeedScalar)(3 * i)) printf("Error writing array a[%" CeedInt_FMT "] = %f\n", i, a[i]); 23*2b730f8bSJeremy L Thompson } 249c774eddSJeremy L Thompson CeedVectorRestoreArrayRead(x, (const CeedScalar **)&a); 259c774eddSJeremy L Thompson 269c774eddSJeremy L Thompson CeedVectorDestroy(&x); 279c774eddSJeremy L Thompson CeedDestroy(&ceed); 289c774eddSJeremy L Thompson return 0; 299c774eddSJeremy L Thompson } 30