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