xref: /libCEED/tests/t402-qfunction.c (revision f2989f2b3b8649d855bed22b6730ee0ecfa6b31b)
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 
main(int argc,char ** argv)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*82a9f6a5SJeremy L Thompson   // Check tabs and CeedObject functionality
38*82a9f6a5SJeremy L Thompson   {
39*82a9f6a5SJeremy L Thompson     CeedQFunction        qf_mass_copy = NULL;
40*82a9f6a5SJeremy L Thompson     CeedQFunctionContext ctx_copy     = NULL;
41*82a9f6a5SJeremy L Thompson 
42*82a9f6a5SJeremy L Thompson     CeedQFunctionReferenceCopy(qf_mass, &qf_mass_copy);
43*82a9f6a5SJeremy L Thompson     CeedQFunctionSetNumViewTabs(qf_mass_copy, 1);
44*82a9f6a5SJeremy L Thompson     CeedObjectView((CeedObject)qf_mass_copy, stdout);
45*82a9f6a5SJeremy L Thompson     CeedObjectDestroy((CeedObject *)&qf_mass_copy);
46*82a9f6a5SJeremy L Thompson 
47*82a9f6a5SJeremy L Thompson     CeedQFunctionContextReferenceCopy(ctx, &ctx_copy);
48*82a9f6a5SJeremy L Thompson     CeedQFunctionContextSetNumViewTabs(ctx_copy, 1);
49*82a9f6a5SJeremy L Thompson     CeedObjectView((CeedObject)ctx_copy, stdout);
50*82a9f6a5SJeremy L Thompson     CeedObjectDestroy((CeedObject *)&ctx_copy);
51*82a9f6a5SJeremy L Thompson   }
5262e2d410SJeremy L Thompson 
5375affc3bSjeremylt   CeedQFunctionDestroy(&qf_setup);
5475affc3bSjeremylt   CeedQFunctionDestroy(&qf_mass);
55777ff853SJeremy L Thompson   CeedQFunctionContextDestroy(&ctx);
5675affc3bSjeremylt   CeedDestroy(&ceed);
5775affc3bSjeremylt   return 0;
5875affc3bSjeremylt }
59