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