xref: /libCEED/examples/petsc/include/structs.h (revision daadeac6547c0bce0e170b8a41c931051f52e9a3)
1 #ifndef libceed_petsc_examples_structs_h
2 #define libceed_petsc_examples_structs_h
3 
4 #include <ceed.h>
5 #include <petsc.h>
6 
7 // -----------------------------------------------------------------------------
8 // PETSc Operator Structs
9 // -----------------------------------------------------------------------------
10 
11 // Data for PETSc Matshell
12 typedef struct OperatorApplyContext_ *OperatorApplyContext;
13 struct OperatorApplyContext_ {
14   MPI_Comm     comm;
15   DM           dm;
16   Vec          X_loc, Y_loc, diag;
17   CeedVector   x_ceed, y_ceed;
18   CeedOperator op;
19   Ceed         ceed;
20 };
21 
22 // Data for PETSc Prolong/Restrict Matshells
23 typedef struct ProlongRestrContext_ *ProlongRestrContext;
24 struct ProlongRestrContext_ {
25   MPI_Comm     comm;
26   DM           dmc, dmf;
27   Vec          loc_vec_c, loc_vec_f, mult_vec;
28   CeedVector   ceed_vec_c, ceed_vec_f;
29   CeedOperator op_prolong, op_restrict;
30   Ceed         ceed;
31 };
32 
33 // -----------------------------------------------------------------------------
34 // libCEED Data Structs
35 // -----------------------------------------------------------------------------
36 
37 // libCEED data struct for level
38 typedef struct CeedData_ *CeedData;
39 struct CeedData_ {
40   Ceed                ceed;
41   CeedBasis           basis_x, basis_u;
42   CeedElemRestriction elem_restr_x, elem_restr_u, elem_restr_u_i, elem_restr_qd_i;
43   CeedQFunction       qf_apply;
44   CeedOperator        op_apply, op_restrict, op_prolong;
45   CeedVector          q_data, x_ceed, y_ceed;
46   CeedInt             q_data_size;
47 };
48 
49 // BP specific data
50 typedef struct {
51   CeedInt           num_comp_x, num_comp_u, topo_dim, q_data_size, q_extra;
52   CeedQFunctionUser setup_geo, setup_rhs, apply, error;
53   const char       *setup_geo_loc, *setup_rhs_loc, *apply_loc, *error_loc;
54   CeedEvalMode      in_mode, out_mode;
55   CeedQuadMode      q_mode;
56   PetscBool         enforce_bc;
57 } BPData;
58 
59 // BP options
60 typedef enum { CEED_BP1 = 0, CEED_BP2 = 1, CEED_BP3 = 2, CEED_BP4 = 3, CEED_BP5 = 4, CEED_BP6 = 5 } BPType;
61 
62 // -----------------------------------------------------------------------------
63 // Parameter structure for running problems
64 // -----------------------------------------------------------------------------
65 typedef struct RunParams_ *RunParams;
66 struct RunParams_ {
67   MPI_Comm      comm;
68   PetscBool     test_mode, read_mesh, user_l_nodes, write_solution, simplex;
69   char         *filename, *hostname;
70   PetscInt      local_nodes, degree, q_extra, dim, num_comp_u, *mesh_elem;
71   PetscInt      ksp_max_it_clip[2];
72   PetscMPIInt   ranks_per_node;
73   BPType        bp_choice;
74   PetscLogStage solve_stage;
75 };
76 
77 #endif  // libceed_petsc_examples_structs_h
78