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