xref: /libCEED/tests/t403-qfunction.c (revision 4febb80102c5c87c6a273a85e30d4673d8552be6)
1 /// @file
2 /// Test creation, copying, and destruction for QFunction and QFunctionContext
3 /// \test Test creation, copying, and destruction for QFunction and QFunctionContext
4 #include <ceed.h>
5 #include <stdio.h>
6 
7 #include "t400-qfunction.h"
8 
9 int main(int argc, char **argv) {
10   Ceed                 ceed;
11   CeedQFunction        qf, qf_2;
12   CeedQFunctionContext ctx, ctx_2;
13 
14   CeedInit(argv[1], &ceed);
15 
16   CeedQFunctionCreateInterior(ceed, 1, setup, setup_loc, &qf);
17   CeedQFunctionCreateInterior(ceed, 1, mass, mass_loc, &qf_2);
18 
19   CeedQFunctionReferenceCopy(qf, &qf_2);  // This destroys the previous qf_2
20   if (qf != qf_2) printf("Error copying CeedQFunction reference\n");
21 
22   CeedQFunctionContextCreate(ceed, &ctx);
23   CeedQFunctionContextCreate(ceed, &ctx_2);
24 
25   CeedQFunctionContextReferenceCopy(ctx, &ctx_2);
26   if (ctx != ctx_2) printf("Error copying CeedQFunctionContext reference\n");
27 
28   CeedQFunctionDestroy(&qf);
29   CeedQFunctionDestroy(&qf_2);
30   CeedQFunctionContextDestroy(&ctx);
31   CeedQFunctionContextDestroy(&ctx_2);
32   CeedDestroy(&ceed);
33   return 0;
34 }
35