xref: /libCEED/tests/t402-qfunction.c (revision 49aac155e7a09736f56fb3abac0f57dab29f7cbf)
175affc3bSjeremylt /// @file
2d1d35e2fSjeremylt /// Test viewing of QFunction
3d1d35e2fSjeremylt /// \test Test viewing of QFunction
475affc3bSjeremylt #include <ceed.h>
5*49aac155SJeremy 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);
2980a9ef05SNatalie Beams   if (CEED_SCALAR_TYPE == CEED_SCALAR_FP64) {
30777ff853SJeremy L Thompson     CeedScalar ctxData[5] = {1, 2, 3, 4, 5};
314fee36f0SJeremy L Thompson 
322b730f8bSJeremy L Thompson     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
3380a9ef05SNatalie Beams   } else {  // Make context twice as long so the size is the same in output
3480a9ef05SNatalie Beams     CeedScalar ctxData[10] = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
354fee36f0SJeremy L Thompson 
362b730f8bSJeremy L Thompson     CeedQFunctionContextSetData(ctx, CEED_MEM_HOST, CEED_COPY_VALUES, sizeof(ctxData), &ctxData);
3780a9ef05SNatalie Beams   }
38777ff853SJeremy L Thompson   CeedQFunctionContextView(ctx, stdout);
39777ff853SJeremy L Thompson 
4075affc3bSjeremylt   CeedQFunctionDestroy(&qf_setup);
4175affc3bSjeremylt   CeedQFunctionDestroy(&qf_mass);
42777ff853SJeremy L Thompson   CeedQFunctionContextDestroy(&ctx);
4375affc3bSjeremylt   CeedDestroy(&ceed);
4475affc3bSjeremylt   return 0;
4575affc3bSjeremylt }
46