xref: /libCEED/tests/t330-basis.c (revision f9996dfd0db601698d1ad85cf5741d3360a86e68)
1 /// @file
2 /// Test creation and destruction of a 2D Quad non-tensor Hdiv basis
3 /// \test Test creation and distruction of a 2D Quad non-tensor Hdiv basis
4 #include <ceed.h>
5 #include "t330-basis.h"
6 
7 int main(int argc, char **argv) {
8   Ceed ceed;
9   const CeedInt Q = 3, dim = 2, num_qpts = Q*Q, elem_nodes = 4;
10   CeedInt num_comp = 1;
11   CeedInt P = dim*elem_nodes; // dof per element! dof is vector in H(div)
12   CeedBasis b;
13   CeedScalar q_ref[dim*num_qpts], q_weights[num_qpts];
14   CeedScalar interp[dim*P*num_qpts], div[P*num_qpts];
15 
16   CeedInit(argv[1], &ceed);
17 
18   // Test skipped if using single precision
19   if (CEED_SCALAR_TYPE == CEED_SCALAR_FP32) {
20     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
21                      "Test not implemented in single precision");
22   }
23 
24   HdivBasisQuad(Q, q_ref, q_weights, interp, div, CEED_GAUSS);
25   CeedBasisCreateHdiv(ceed, CEED_TOPOLOGY_QUAD, num_comp, P, num_qpts, interp,
26                       div, q_ref, q_weights, &b);
27   // interp[0]--.interp[num_qpts-1] ==> basis in x-direction
28   // interp[num_qpts]--.interp[dim*num_qpts-1] ==> basis in y-direction
29   CeedBasisView(b, stdout);
30 
31   CeedBasisDestroy(&b);
32   CeedDestroy(&ceed);
33   return 0;
34 }
35