xref: /libCEED/tests/t402-qfunction.c (revision a9e65696a8c8214eb82d2dcf9ed1f28a32d2c94e)
1 /// @file
2 /// Test viewing of QFunction
3 /// \test Test viewing of QFunction
4 #include <ceed.h>
5 
6 #include "t400-qfunction.h"
7 
8 int main(int argc, char **argv) {
9   Ceed                 ceed;
10   CeedQFunction        qf_setup, qf_mass;
11   CeedQFunctionContext ctx;
12 
13   CeedInit(argv[1], &ceed);
14 
15   CeedQFunctionCreateInterior(ceed, 1, setup, setup_loc, &qf_setup);
16   CeedQFunctionAddInput(qf_setup, "w", 1, CEED_EVAL_WEIGHT);
17   CeedQFunctionAddOutput(qf_setup, "qdata", 1, CEED_EVAL_NONE);
18 
19   CeedQFunctionCreateInterior(ceed, 1, mass, mass_loc, &qf_mass);
20   CeedQFunctionAddInput(qf_mass, "qdata", 1, CEED_EVAL_NONE);
21   CeedQFunctionAddInput(qf_mass, "u", 1, CEED_EVAL_INTERP);
22   CeedQFunctionAddOutput(qf_mass, "v", 1, CEED_EVAL_INTERP);
23 
24   CeedQFunctionView(qf_setup, stdout);
25   CeedQFunctionView(qf_mass, stdout);
26 
27   CeedQFunctionContextCreate(ceed, &ctx);
28   if (CEED_SCALAR_TYPE == CEED_SCALAR_FP64) {
29     CeedScalar ctxData[5] = {1, 2, 3, 4, 5};
30     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
31   } else {  // Make context twice as long so the size is the same in output
32     CeedScalar ctxData[10] = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
33     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
34   }
35   CeedQFunctionContextView(ctx, stdout);
36 
37   CeedQFunctionDestroy(&qf_setup);
38   CeedQFunctionDestroy(&qf_mass);
39   CeedQFunctionContextDestroy(&ctx);
40   CeedDestroy(&ceed);
41   return 0;
42 }
43