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