1 #ifndef libceed_solids_examples_structs_h 2 #define libceed_solids_examples_structs_h 3 4 #include <ceed.h> 5 #include <petsc.h> 6 #include "../problems/cl-problems.h" 7 8 // ----------------------------------------------------------------------------- 9 // Command Line Options 10 // ----------------------------------------------------------------------------- 11 // Forcing function options 12 typedef enum { 13 FORCE_NONE = 0, FORCE_CONST = 1, FORCE_MMS = 2 14 } forcingType; 15 static const char *const forcing_types[] = {"none", 16 "constant", 17 "mms", 18 "forcingType","FORCE_",0 19 }; 20 static const char *const forcing_types_for_disp[] = {"None", 21 "Constant", 22 "Manufactured solution" 23 }; 24 25 // Multigrid options 26 typedef enum { 27 MULTIGRID_LOGARITHMIC = 0, MULTIGRID_UNIFORM = 1, MULTIGRID_NONE = 2 28 } multigridType; 29 static const char *const multigrid_types [] = {"logarithmic", 30 "uniform", 31 "none", 32 "multigridType","MULTIGRID",0 33 }; 34 static const char *const multigrid_types_for_disp[] = {"P-multigrid, logarithmic coarsening", 35 "P-multigrind, uniform coarsening", 36 "No multigrid" 37 }; 38 39 // ----------------------------------------------------------------------------- 40 // Application data structs 41 // ----------------------------------------------------------------------------- 42 // Units 43 typedef struct Units_ *Units; 44 struct Units_ { 45 // Fundamental units 46 PetscScalar meter; 47 PetscScalar kilogram; 48 PetscScalar second; 49 // Derived unit 50 PetscScalar Pascal; 51 }; 52 53 // Application context from user command line options 54 typedef struct AppCtx_ *AppCtx; 55 struct AppCtx_ { 56 const char *name, *name_for_disp; // problem name 57 char ceed_resource[PETSC_MAX_PATH_LEN]; // libCEED backend 58 char mesh_file[PETSC_MAX_PATH_LEN]; // exodusII mesh file 59 char output_dir[PETSC_MAX_PATH_LEN]; 60 PetscBool test_mode; 61 PetscBool view_soln; 62 PetscBool view_final_soln; 63 PetscViewer energy_viewer; 64 problemType problem_choice; 65 forcingType forcing_choice; 66 multigridType multigrid_choice; 67 PetscInt degree; 68 PetscInt q_extra; 69 PetscInt num_levels; 70 PetscInt *level_degrees; 71 PetscInt num_increments; // Number of steps 72 PetscInt bc_clamp_count; 73 PetscInt bc_clamp_faces[16]; 74 // [translation; 3] [rotation axis; 3] [rotation magnitude c_0, c_1] 75 // The rotations are (c_0 + c_1 s) \pi, where s = x · axis 76 PetscScalar bc_clamp_max[16][8]; 77 PetscInt bc_traction_count; 78 PetscInt bc_traction_faces[16]; 79 PetscScalar bc_traction_vector[16][3]; 80 PetscScalar forcing_vector[3]; 81 PetscReal test_tol; 82 PetscReal expect_final_strain; 83 }; 84 85 // Forcing function data 86 typedef struct { 87 CeedQFunctionUser setup_forcing; 88 const char *setup_forcing_loc; 89 } forcingData; 90 91 extern forcingData forcing_options[3]; 92 93 // Data for PETSc Matshell 94 typedef struct UserMult_ *UserMult; 95 struct UserMult_ { 96 MPI_Comm comm; 97 DM dm; 98 Vec X_loc, Y_loc, neumann_bcs; 99 CeedVector x_ceed, y_ceed; 100 CeedOperator op; 101 CeedQFunction qf; 102 Ceed ceed; 103 PetscScalar load_increment; 104 CeedQFunctionContext ctx_phys, ctx_phys_smoother; 105 }; 106 107 // Data for Jacobian setup routine 108 typedef struct FormJacobCtx_ *FormJacobCtx; 109 struct FormJacobCtx_ { 110 UserMult *jacob_ctx; 111 PetscInt num_levels; 112 Mat *jacob_mat, jacob_mat_coarse; 113 CeedVector coo_values; 114 CeedOperator op_coarse; 115 }; 116 117 // Data for PETSc Prolongation/Restriction Matshell 118 typedef struct UserMultProlongRestr_ *UserMultProlongRestr; 119 struct UserMultProlongRestr_ { 120 MPI_Comm comm; 121 DM dm_c, dm_f; 122 Vec loc_vec_c, loc_vec_f; 123 CeedVector ceed_vec_c, ceed_vec_f; 124 CeedOperator op_prolong, op_restrict; 125 Ceed ceed; 126 }; 127 128 #define SOLIDS_MAX_NUMBER_FIELDS 16 129 130 // libCEED data struct for level 131 typedef struct CeedData_ *CeedData; 132 struct CeedData_ { 133 Ceed ceed; 134 CeedBasis basis_x, basis_u, basis_c_to_f, basis_energy, 135 basis_diagnostic; 136 CeedElemRestriction elem_restr_x, elem_restr_u, elem_restr_geo_data_i, 137 elem_restr_energy, elem_restr_diagnostic, 138 elem_restr_geo_data_diagnostic_i, 139 elem_restr_stored_fields_i[SOLIDS_MAX_NUMBER_FIELDS]; 140 CeedQFunction qf_residual, qf_jacobian, qf_energy, qf_diagnostic; 141 CeedOperator op_residual, op_jacobian, op_restrict, op_prolong, 142 op_energy, 143 op_diagnostic; 144 CeedVector geo_data, geo_data_diagnostic, x_ceed, y_ceed, 145 true_soln, stored_fields[SOLIDS_MAX_NUMBER_FIELDS]; 146 }; 147 148 typedef struct { 149 CeedQFunctionUser setup_geo, residual, jacobian, energy, 150 diagnostic, true_soln; 151 const char *setup_geo_loc, *residual_loc, *jacobian_loc, *energy_loc, 152 *diagnostic_loc, *true_soln_loc; 153 CeedQuadMode quadrature_mode; 154 CeedInt q_data_size, number_fields_stored; 155 CeedInt *field_sizes; 156 const char *const *field_names; 157 } ProblemData; 158 159 #endif // libceed_solids_examples_structs_h 160