xref: /libCEED/tests/t402-qfunction.c (revision b748b478928b2ce7f3faeb46c0d9cffd927360f6)
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, "q data", 1, CEED_EVAL_NONE);
18 
19   CeedQFunctionCreateInterior(ceed, 1, mass, mass_loc, &qf_mass);
20   CeedQFunctionAddInput(qf_mass, "q data", 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 
31     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
32   } else {  // Make context twice as long so the size is the same in output
33     CeedScalar ctxData[10] = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
34 
35     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
36   }
37   CeedQFunctionContextView(ctx, stdout);
38 
39   CeedQFunctionDestroy(&qf_setup);
40   CeedQFunctionDestroy(&qf_mass);
41   CeedQFunctionContextDestroy(&ctx);
42   CeedDestroy(&ceed);
43   return 0;
44 }
45