xref: /libCEED/examples/petsc/include/structs.h (revision 4f19f491a454b5597e5146ab3a5609861c5b4955)
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 {
61   CEED_BP1 = 0, CEED_BP2 = 1, CEED_BP3 = 2,
62   CEED_BP4 = 3, CEED_BP5 = 4, CEED_BP6 = 5
63 } BPType;
64 
65 // -----------------------------------------------------------------------------
66 // Parameter structure for running problems
67 // -----------------------------------------------------------------------------
68 typedef struct RunParams_ *RunParams;
69 struct RunParams_ {
70   MPI_Comm comm;
71   PetscBool test_mode, read_mesh, user_l_nodes, write_solution, simplex;
72   char *filename, *hostname;
73   PetscInt local_nodes, degree, q_extra, dim, num_comp_u, *mesh_elem;
74   PetscInt ksp_max_it_clip[2];
75   PetscMPIInt ranks_per_node;
76   BPType bp_choice;
77   PetscLogStage solve_stage;
78 
79 };
80 
81 #endif // libceed_petsc_examples_structs_h
82