1 /// @file 2 /// Test creation, evaluation, and destruction of identity QFunction 3 /// \test Test creation, evaluation, and destruction of identity QFunction 4 #include <ceed.h> 5 #include <math.h> 6 7 int main(int argc, char **argv) { 8 Ceed ceed; 9 CeedVector in[16], out[16]; 10 CeedVector U, V; 11 CeedQFunction qf; 12 CeedInt Q = 8; 13 const CeedScalar *v; 14 CeedScalar u[Q]; 15 16 CeedInit(argv[1], &ceed); 17 18 CeedQFunctionCreateIdentity(ceed, 1, CEED_EVAL_INTERP, CEED_EVAL_INTERP, &qf); 19 20 for (CeedInt i = 0; i < Q; i++) u[i] = i * i; 21 22 CeedVectorCreate(ceed, Q, &U); 23 CeedVectorSetArray(U, CEED_MEM_HOST, CEED_USE_POINTER, u); 24 CeedVectorCreate(ceed, Q, &V); 25 CeedVectorSetValue(V, 0); 26 27 { 28 in[0] = U; 29 out[0] = V; 30 CeedQFunctionApply(qf, Q, in, out); 31 } 32 33 CeedVectorGetArrayRead(V, CEED_MEM_HOST, &v); 34 for (CeedInt i = 0; i < Q; i++) { 35 if (fabs(v[i] - u[i]) > 1e-14) printf("[%" CeedInt_FMT "] v %f != u %f\n", i, v[i], u[i]); 36 } 37 CeedVectorRestoreArrayRead(V, &v); 38 39 CeedVectorDestroy(&U); 40 CeedVectorDestroy(&V); 41 CeedQFunctionDestroy(&qf); 42 CeedDestroy(&ceed); 43 return 0; 44 } 45