xref: /libCEED/tests/t402-qfunction.c (revision 62e2d4103ebce4cf22bacb0bf84df0fd456c3171)
175affc3bSjeremylt /// @file
2bcbe1c99SJeremy L Thompson /// Test viewing of QFunction and QFunctionContext
3bcbe1c99SJeremy L Thompson /// \test Test viewing of QFunction and QFunctionContext
475affc3bSjeremylt #include <ceed.h>
549aac155SJeremy L Thompson #include <stdio.h>
62b730f8bSJeremy L Thompson 
775affc3bSjeremylt #include "t400-qfunction.h"
875affc3bSjeremylt 
975affc3bSjeremylt int main(int argc, char **argv) {
1075affc3bSjeremylt   Ceed                 ceed;
1175affc3bSjeremylt   CeedQFunction        qf_setup, qf_mass;
12777ff853SJeremy L Thompson   CeedQFunctionContext ctx;
1375affc3bSjeremylt 
1475affc3bSjeremylt   CeedInit(argv[1], &ceed);
1575affc3bSjeremylt 
1675affc3bSjeremylt   CeedQFunctionCreateInterior(ceed, 1, setup, setup_loc, &qf_setup);
1784e209c4Sjeremylt   CeedQFunctionAddInput(qf_setup, "w", 1, CEED_EVAL_WEIGHT);
1884e209c4Sjeremylt   CeedQFunctionAddOutput(qf_setup, "q data", 1, CEED_EVAL_NONE);
1975affc3bSjeremylt 
2075affc3bSjeremylt   CeedQFunctionCreateInterior(ceed, 1, mass, mass_loc, &qf_mass);
2184e209c4Sjeremylt   CeedQFunctionAddInput(qf_mass, "q data", 1, CEED_EVAL_NONE);
2275affc3bSjeremylt   CeedQFunctionAddInput(qf_mass, "u", 1, CEED_EVAL_INTERP);
2375affc3bSjeremylt   CeedQFunctionAddOutput(qf_mass, "v", 1, CEED_EVAL_INTERP);
2475affc3bSjeremylt 
2575affc3bSjeremylt   CeedQFunctionView(qf_setup, stdout);
2675affc3bSjeremylt   CeedQFunctionView(qf_mass, stdout);
2775affc3bSjeremylt 
28777ff853SJeremy L Thompson   CeedQFunctionContextCreate(ceed, &ctx);
29bcbe1c99SJeremy L Thompson   {
30bcbe1c99SJeremy L Thompson     double ctxData[5] = {1, 2, 3, 4, 5};
314fee36f0SJeremy L Thompson 
322b730f8bSJeremy L Thompson     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
33bcbe1c99SJeremy L Thompson     CeedQFunctionContextRegisterDouble(ctx, "scale", 0, 5, "scaling values");
3480a9ef05SNatalie Beams   }
35777ff853SJeremy L Thompson   CeedQFunctionContextView(ctx, stdout);
36777ff853SJeremy L Thompson 
37*62e2d410SJeremy L Thompson   CeedQFunctionSetNumViewTabs(qf_mass, 1);
38*62e2d410SJeremy L Thompson   CeedQFunctionView(qf_mass, stdout);
39*62e2d410SJeremy L Thompson   CeedQFunctionContextSetNumViewTabs(ctx, 1);
40*62e2d410SJeremy L Thompson   CeedQFunctionContextView(ctx, stdout);
41*62e2d410SJeremy L Thompson 
4275affc3bSjeremylt   CeedQFunctionDestroy(&qf_setup);
4375affc3bSjeremylt   CeedQFunctionDestroy(&qf_mass);
44777ff853SJeremy L Thompson   CeedQFunctionContextDestroy(&ctx);
4575affc3bSjeremylt   CeedDestroy(&ceed);
4675affc3bSjeremylt   return 0;
4775affc3bSjeremylt }
48