xref: /libCEED/tests/t402-qfunction.c (revision 80a9ef0545a39c00cdcaab1ca26f8053604f3120)
175affc3bSjeremylt /// @file
2d1d35e2fSjeremylt /// Test viewing of QFunction
3d1d35e2fSjeremylt /// \test Test viewing of QFunction
475affc3bSjeremylt #include <ceed.h>
575affc3bSjeremylt #include "t400-qfunction.h"
675affc3bSjeremylt 
775affc3bSjeremylt int main(int argc, char **argv) {
875affc3bSjeremylt   Ceed ceed;
975affc3bSjeremylt   CeedQFunction qf_setup, qf_mass;
10777ff853SJeremy L Thompson   CeedQFunctionContext ctx;
1175affc3bSjeremylt 
1275affc3bSjeremylt   CeedInit(argv[1], &ceed);
1375affc3bSjeremylt 
1475affc3bSjeremylt   CeedQFunctionCreateInterior(ceed, 1, setup, setup_loc, &qf_setup);
1584e209c4Sjeremylt   CeedQFunctionAddInput(qf_setup, "w", 1, CEED_EVAL_WEIGHT);
1684e209c4Sjeremylt   CeedQFunctionAddOutput(qf_setup, "qdata", 1, CEED_EVAL_NONE);
1775affc3bSjeremylt 
1875affc3bSjeremylt   CeedQFunctionCreateInterior(ceed, 1, mass, mass_loc, &qf_mass);
1984e209c4Sjeremylt   CeedQFunctionAddInput(qf_mass, "qdata", 1, CEED_EVAL_NONE);
2075affc3bSjeremylt   CeedQFunctionAddInput(qf_mass, "u", 1, CEED_EVAL_INTERP);
2175affc3bSjeremylt   CeedQFunctionAddOutput(qf_mass, "v", 1, CEED_EVAL_INTERP);
2275affc3bSjeremylt 
2375affc3bSjeremylt   CeedQFunctionView(qf_setup, stdout);
2475affc3bSjeremylt   CeedQFunctionView(qf_mass, stdout);
2575affc3bSjeremylt 
26777ff853SJeremy L Thompson   CeedQFunctionContextCreate(ceed, &ctx);
27*80a9ef05SNatalie Beams   if (CEED_SCALAR_TYPE == CEED_SCALAR_FP64) {
28777ff853SJeremy L Thompson     CeedScalar ctxData[5] = {1, 2, 3, 4, 5};
29777ff853SJeremy L Thompson     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES,
30777ff853SJeremy L Thompson                                 sizeof(ctxData), &ctxData);
31*80a9ef05SNatalie Beams   } else { // Make context twice as long so the size is the same in output
32*80a9ef05SNatalie Beams     CeedScalar ctxData[10] = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
33*80a9ef05SNatalie Beams     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES,
34*80a9ef05SNatalie Beams                                 sizeof(ctxData), &ctxData);
35*80a9ef05SNatalie Beams   }
36777ff853SJeremy L Thompson   CeedQFunctionContextView(ctx, stdout);
37777ff853SJeremy L Thompson 
3875affc3bSjeremylt   CeedQFunctionDestroy(&qf_setup);
3975affc3bSjeremylt   CeedQFunctionDestroy(&qf_mass);
40777ff853SJeremy L Thompson   CeedQFunctionContextDestroy(&ctx);
4175affc3bSjeremylt   CeedDestroy(&ceed);
4275affc3bSjeremylt   return 0;
4375affc3bSjeremylt }
44