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