@@ -104,22 +104,24 @@ int main(int argc, char **argv) {
104104 // ---------------------------------------------------------------------------
105105 // -- Initialize backend
106106 Ceed ceed ;
107- CeedInit (app_ctx -> ceed_resource , & ceed );
107+ PetscCheck ( CeedInit (app_ctx -> ceed_resource , & ceed ) == CEED_ERROR_SUCCESS , comm , PETSC_ERR_LIB , "Ceed initialization failed" );
108108 user -> ceed = ceed ;
109109
110+ PetscCheck (CeedSetErrorHandler (ceed , CeedErrorStore ) == CEED_ERROR_SUCCESS , comm , PETSC_ERR_LIB , "Setting libCEED error handler failed" );
111+
110112 // -- Check preferred MemType
111113 CeedMemType mem_type_backend ;
112- CeedGetPreferredMemType (ceed , & mem_type_backend );
114+ PetscCallCeed ( ceed , CeedGetPreferredMemType (ceed , & mem_type_backend ) );
113115
114116 {
115117 const char * resource ;
116- CeedGetResource (ceed , & resource );
118+ PetscCallCeed ( ceed , CeedGetResource (ceed , & resource ) );
117119 if (strstr (resource , "/gpu/sycl" )) {
118120 PetscDeviceContext dctx ;
119121 PetscCall (PetscDeviceContextGetCurrentContext (& dctx ));
120122 void * stream_handle ;
121123 PetscCall (PetscDeviceContextGetStreamHandle (dctx , & stream_handle ));
122- CeedSetStream (ceed , stream_handle );
124+ PetscCallCeed ( ceed , CeedSetStream (ceed , stream_handle ) );
123125 }
124126 }
125127
@@ -136,7 +138,7 @@ int main(int argc, char **argv) {
136138 break ;
137139 case CEED_MEM_DEVICE : {
138140 const char * resolved ;
139- CeedGetResource (ceed , & resolved );
141+ PetscCallCeed ( ceed , CeedGetResource (ceed , & resolved ) );
140142 if (strstr (resolved , "/gpu/cuda" )) vec_type = VECCUDA ;
141143 else if (strstr (resolved , "/gpu/hip" )) vec_type = VECKOKKOS ;
142144 else if (strstr (resolved , "/gpu/sycl" )) vec_type = VECKOKKOS ;
@@ -256,65 +258,65 @@ int main(int argc, char **argv) {
256258 PetscCall (DifferentialFilterDataDestroy (user -> diff_filter ));
257259
258260 // -- Vectors
259- CeedVectorDestroy (& ceed_data -> x_coord );
260- CeedVectorDestroy (& ceed_data -> q_data );
261- CeedVectorDestroy (& user -> q_ceed );
262- CeedVectorDestroy (& user -> q_dot_ceed );
263- CeedVectorDestroy (& user -> g_ceed );
264- CeedVectorDestroy (& user -> coo_values_amat );
265- CeedVectorDestroy (& user -> coo_values_pmat );
261+ PetscCallCeed ( ceed , CeedVectorDestroy (& ceed_data -> x_coord ) );
262+ PetscCallCeed ( ceed , CeedVectorDestroy (& ceed_data -> q_data ) );
263+ PetscCallCeed ( ceed , CeedVectorDestroy (& user -> q_ceed ) );
264+ PetscCallCeed ( ceed , CeedVectorDestroy (& user -> q_dot_ceed ) );
265+ PetscCallCeed ( ceed , CeedVectorDestroy (& user -> g_ceed ) );
266+ PetscCallCeed ( ceed , CeedVectorDestroy (& user -> coo_values_amat ) );
267+ PetscCallCeed ( ceed , CeedVectorDestroy (& user -> coo_values_pmat ) );
266268
267269 // -- Bases
268- CeedBasisDestroy (& ceed_data -> basis_q );
269- CeedBasisDestroy (& ceed_data -> basis_x );
270- CeedBasisDestroy (& ceed_data -> basis_xc );
271- CeedBasisDestroy (& ceed_data -> basis_q_sur );
272- CeedBasisDestroy (& ceed_data -> basis_x_sur );
270+ PetscCallCeed ( ceed , CeedBasisDestroy (& ceed_data -> basis_q ) );
271+ PetscCallCeed ( ceed , CeedBasisDestroy (& ceed_data -> basis_x ) );
272+ PetscCallCeed ( ceed , CeedBasisDestroy (& ceed_data -> basis_xc ) );
273+ PetscCallCeed ( ceed , CeedBasisDestroy (& ceed_data -> basis_q_sur ) );
274+ PetscCallCeed ( ceed , CeedBasisDestroy (& ceed_data -> basis_x_sur ) );
273275
274276 // -- Restrictions
275- CeedElemRestrictionDestroy (& ceed_data -> elem_restr_q );
276- CeedElemRestrictionDestroy (& ceed_data -> elem_restr_x );
277- CeedElemRestrictionDestroy (& ceed_data -> elem_restr_qd_i );
277+ PetscCallCeed ( ceed , CeedElemRestrictionDestroy (& ceed_data -> elem_restr_q ) );
278+ PetscCallCeed ( ceed , CeedElemRestrictionDestroy (& ceed_data -> elem_restr_x ) );
279+ PetscCallCeed ( ceed , CeedElemRestrictionDestroy (& ceed_data -> elem_restr_qd_i ) );
278280
279281 // Destroy QFunction contexts after using
280282 // ToDo: Simplify tracked libCEED objects, smaller struct
281283 {
282- CeedQFunctionContextDestroy (& problem -> apply_inflow_jacobian .qfunction_context );
283- CeedQFunctionContextDestroy (& problem -> apply_inflow_jacobian .qfunction_context );
284- CeedQFunctionContextDestroy (& problem -> apply_outflow_jacobian .qfunction_context );
285- CeedQFunctionContextDestroy (& problem -> apply_outflow_jacobian .qfunction_context );
286- CeedQFunctionContextDestroy (& problem -> apply_freestream_jacobian .qfunction_context );
287- CeedQFunctionContextDestroy (& problem -> apply_freestream_jacobian .qfunction_context );
288- CeedQFunctionContextDestroy (& problem -> setup_sur .qfunction_context );
289- CeedQFunctionContextDestroy (& problem -> setup_vol .qfunction_context );
290- CeedQFunctionContextDestroy (& problem -> ics .qfunction_context );
291- CeedQFunctionContextDestroy (& problem -> apply_vol_rhs .qfunction_context );
292- CeedQFunctionContextDestroy (& problem -> apply_vol_ifunction .qfunction_context );
293- CeedQFunctionContextDestroy (& problem -> apply_vol_ijacobian .qfunction_context );
284+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_inflow_jacobian .qfunction_context ) );
285+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_inflow_jacobian .qfunction_context ) );
286+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_outflow_jacobian .qfunction_context ) );
287+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_outflow_jacobian .qfunction_context ) );
288+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_freestream_jacobian .qfunction_context ) );
289+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_freestream_jacobian .qfunction_context ) );
290+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> setup_sur .qfunction_context ) );
291+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> setup_vol .qfunction_context ) );
292+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> ics .qfunction_context ) );
293+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_vol_rhs .qfunction_context ) );
294+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_vol_ifunction .qfunction_context ) );
295+ PetscCallCeed ( ceed , CeedQFunctionContextDestroy (& problem -> apply_vol_ijacobian .qfunction_context ) );
294296 }
295297
296298 // -- QFunctions
297- CeedQFunctionDestroy (& ceed_data -> qf_setup_vol );
298- CeedQFunctionDestroy (& ceed_data -> qf_ics );
299- CeedQFunctionDestroy (& ceed_data -> qf_rhs_vol );
300- CeedQFunctionDestroy (& ceed_data -> qf_ifunction_vol );
301- CeedQFunctionDestroy (& ceed_data -> qf_setup_sur );
302- CeedQFunctionDestroy (& ceed_data -> qf_apply_inflow );
303- CeedQFunctionDestroy (& ceed_data -> qf_apply_inflow_jacobian );
304- CeedQFunctionDestroy (& ceed_data -> qf_apply_freestream );
305- CeedQFunctionDestroy (& ceed_data -> qf_apply_freestream_jacobian );
299+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_setup_vol ) );
300+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_ics ) );
301+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_rhs_vol ) );
302+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_ifunction_vol ) );
303+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_setup_sur ) );
304+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_apply_inflow ) );
305+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_apply_inflow_jacobian ) );
306+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_apply_freestream ) );
307+ PetscCallCeed ( ceed , CeedQFunctionDestroy (& ceed_data -> qf_apply_freestream_jacobian ) );
306308
307309 // -- Operators
308- CeedOperatorDestroy (& ceed_data -> op_setup_vol );
310+ PetscCallCeed ( ceed , CeedOperatorDestroy (& ceed_data -> op_setup_vol ) );
309311 PetscCall (OperatorApplyContextDestroy (ceed_data -> op_ics_ctx ));
310- CeedOperatorDestroy (& user -> op_rhs_vol );
311- CeedOperatorDestroy (& user -> op_ifunction_vol );
312+ PetscCallCeed ( ceed , CeedOperatorDestroy (& user -> op_rhs_vol ) );
313+ PetscCallCeed ( ceed , CeedOperatorDestroy (& user -> op_ifunction_vol ) );
312314 PetscCall (OperatorApplyContextDestroy (user -> op_rhs_ctx ));
313- CeedOperatorDestroy (& user -> op_ifunction );
314- CeedOperatorDestroy (& user -> op_ijacobian );
315+ PetscCallCeed ( ceed , CeedOperatorDestroy (& user -> op_ifunction ) );
316+ PetscCallCeed ( ceed , CeedOperatorDestroy (& user -> op_ijacobian ) );
315317
316318 // -- Ceed
317- CeedDestroy (& ceed );
319+ PetscCheck ( CeedDestroy (& ceed ) == CEED_ERROR_SUCCESS , comm , PETSC_ERR_LIB , "Destroying Ceed object failed" );
318320
319321 if (app_ctx -> test_type != TESTTYPE_NONE ) {
320322 PetscInt num_options_left = 0 ;
0 commit comments