@@ -71,7 +71,7 @@ int main(int argc, char **argv) {
7171 Ceed ceed ;
7272 CeedData ceed_data ;
7373 ProblemType problem_choice ;
74- VecType vec_type ;
74+ VecType vec_type = VECSTANDARD ;
7575 PetscMemType mem_type ;
7676
7777 PetscCall (PetscInitialize (& argc , & argv , NULL , help ));
@@ -110,15 +110,6 @@ int main(int argc, char **argv) {
110110 // Create DM
111111 PetscCall (SetupDMByDegree (dm , degree , q_extra , num_comp_u , topo_dim , false));
112112
113- // Create vectors
114- PetscCall (DMCreateGlobalVector (dm , & U ));
115- PetscCall (VecGetLocalSize (U , & l_size ));
116- PetscCall (VecGetSize (U , & g_size ));
117- PetscCall (DMCreateLocalVector (dm , & U_loc ));
118- PetscCall (VecGetSize (U_loc , & xl_size ));
119- PetscCall (VecDuplicate (U , & V ));
120- PetscCall (VecDuplicate (U_loc , & V_loc ));
121-
122113 // Setup op_apply_ctx structure
123114 PetscCall (PetscMalloc1 (1 , & op_apply_ctx ));
124115
@@ -127,23 +118,31 @@ int main(int argc, char **argv) {
127118 CeedMemType mem_type_backend ;
128119 CeedGetPreferredMemType (ceed , & mem_type_backend );
129120
130- PetscCall (DMGetVecType (dm , & vec_type ));
131- if (!vec_type ) { // Not yet set by op_apply_ctx -dm_vec_type
132- switch (mem_type_backend ) {
133- case CEED_MEM_HOST :
134- vec_type = VECSTANDARD ;
135- break ;
136- case CEED_MEM_DEVICE : {
137- const char * resolved ;
138- CeedGetResource (ceed , & resolved );
139- if (strstr (resolved , "/gpu/cuda" )) vec_type = VECCUDA ;
140- else if (strstr (resolved , "/gpu/hip/occa" )) vec_type = VECSTANDARD ; // https://github.com/CEED/libCEED/issues/678
141- else if (strstr (resolved , "/gpu/hip" )) vec_type = VECHIP ;
142- else vec_type = VECSTANDARD ;
143- }
121+ // Set mesh vec_type
122+ switch (mem_type_backend ) {
123+ case CEED_MEM_HOST :
124+ vec_type = VECSTANDARD ;
125+ break ;
126+ case CEED_MEM_DEVICE : {
127+ const char * resolved ;
128+
129+ CeedGetResource (ceed , & resolved );
130+ if (strstr (resolved , "/gpu/cuda" )) vec_type = VECCUDA ;
131+ else if (strstr (resolved , "/gpu/hip/occa" )) vec_type = VECSTANDARD ; // https://github.com/CEED/libCEED/issues/678
132+ else if (strstr (resolved , "/gpu/hip" )) vec_type = VECHIP ;
133+ else vec_type = VECSTANDARD ;
144134 }
145- PetscCall (DMSetVecType (dm , vec_type ));
146135 }
136+ PetscCall (DMSetVecType (dm , vec_type ));
137+
138+ // Create vectors
139+ PetscCall (DMCreateGlobalVector (dm , & U ));
140+ PetscCall (VecGetLocalSize (U , & l_size ));
141+ PetscCall (VecGetSize (U , & g_size ));
142+ PetscCall (DMCreateLocalVector (dm , & U_loc ));
143+ PetscCall (VecGetSize (U_loc , & xl_size ));
144+ PetscCall (VecDuplicate (U , & V ));
145+ PetscCall (VecDuplicate (U_loc , & V_loc ));
147146
148147 // Print summary
149148 if (!test_mode ) {
0 commit comments