@@ -141,57 +141,41 @@ main(int argc, char ** argv)
141141 // Prints information about the system to the screen.
142142 equation_systems .print_info ();
143143
144- auto ierr = PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_type" , "power" );
145- CHKERRQ (ierr );
146- ierr = PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_update" , "1" );
147- CHKERRQ (ierr );
148- ierr = PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_nonlinear" , "1" );
149- CHKERRQ (ierr );
150- ierr = PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_max_it" , "1" );
151- CHKERRQ (ierr );
152- ierr = PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_snes_mf_operator" , "1" );
153- CHKERRQ (ierr );
154- ierr = PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_pc_type" , "lu" );
155- CHKERRQ (ierr );
144+ LibmeshPetscCallQ (PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_type" , "power" ));
145+ LibmeshPetscCallQ (PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_update" , "1" ));
146+ LibmeshPetscCallQ (PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_nonlinear" , "1" ));
147+ LibmeshPetscCallQ (PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_max_it" , "1" ));
148+ LibmeshPetscCallQ (PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_snes_mf_operator" , "1" ));
149+ LibmeshPetscCallQ (PetscOptionsSetValue (LIBMESH_PETSC_NULLPTR , "-eps_power_pc_type" , "lu" ));
156150
157151 //
158152 // Set function/operator callback functions
159153 //
160154
161155 auto & A = static_cast < PetscShellMatrix < Number > & > (eigen_system .get_shell_matrix_A ());
162156 auto Amat = A .mat ();
163- ierr = PetscObjectComposeFunction ((PetscObject )Amat , "formFunction" , form_functionA );
164- CHKERRQ (ierr );
165- ierr = PetscObjectComposeFunction ((PetscObject )Amat , "formJacobian" , form_matrixA );
166- CHKERRQ (ierr );
157+ LibmeshPetscCallQ (PetscObjectComposeFunction ((PetscObject )Amat , "formFunction" , form_functionA ));
158+ LibmeshPetscCallQ (PetscObjectComposeFunction ((PetscObject )Amat , "formJacobian" , form_matrixA ));
167159
168160 auto & B = static_cast < PetscShellMatrix < Number > & > (eigen_system .get_shell_matrix_B ());
169161 auto Bmat = B .mat ();
170- ierr = PetscObjectComposeFunction ((PetscObject )Bmat , "formFunction" , form_functionB );
171- CHKERRQ (ierr );
162+ LibmeshPetscCallQ (PetscObjectComposeFunction ((PetscObject )Bmat , "formFunction" , form_functionB ));
172163
173164 //
174165 // Set function/operator callback function contexts
175166 //
176167
177168 PetscContainer container ;
178- ierr = PetscContainerCreate (equation_systems .comm ().get (), & container );
179- CHKERRQ (ierr );
180- ierr = PetscContainerSetPointer (container , & equation_systems );
181- CHKERRQ (ierr );
182- ierr = PetscObjectCompose ((PetscObject )Amat , "formFunctionCtx" , (PetscObject )container );
183- CHKERRQ (ierr );
184- ierr = PetscObjectCompose ((PetscObject )Amat , "formJacobianCtx" , (PetscObject )container );
185- CHKERRQ (ierr );
186- ierr = PetscObjectCompose ((PetscObject )Bmat , "formFunctionCtx" , (PetscObject )container );
187- CHKERRQ (ierr );
188- ierr = PetscContainerDestroy (& container );
189- CHKERRQ (ierr );
169+ LibmeshPetscCallQ (PetscContainerCreate (equation_systems .comm ().get (), & container ));
170+ LibmeshPetscCallQ (PetscContainerSetPointer (container , & equation_systems ));
171+ LibmeshPetscCallQ (PetscObjectCompose ((PetscObject )Amat , "formFunctionCtx" , (PetscObject )container ));
172+ LibmeshPetscCallQ (PetscObjectCompose ((PetscObject )Amat , "formJacobianCtx" , (PetscObject )container ));
173+ LibmeshPetscCallQ (PetscObjectCompose ((PetscObject )Bmat , "formFunctionCtx" , (PetscObject )container ));
174+ LibmeshPetscCallQ (PetscContainerDestroy (& container ));
190175
191176 // Set the initial space
192177 Vec initial_space ;
193- ierr = MatCreateVecs (Amat , & initial_space , nullptr );
194- CHKERRQ (ierr );
178+ LibmeshPetscCallQ (MatCreateVecs (Amat , & initial_space , nullptr ));
195179 PetscVector < Number > wrapped_initial_space (initial_space , equation_systems .comm ());
196180 wrapped_initial_space .add (1 );
197181 wrapped_initial_space .close ();
@@ -221,8 +205,7 @@ main(int argc, char ** argv)
221205 else
222206 libMesh ::out << "WARNING: Solver did not converge!\n" << nconv << std ::endl ;
223207
224- ierr = VecDestroy (& initial_space );
225- CHKERRQ (ierr );
208+ LibmeshPetscCallQ (VecDestroy (& initial_space ));
226209
227210 // All done.
228211 return 0 ;
@@ -578,13 +561,11 @@ form_matrixA(SNES /*snes*/, Vec x, Mat jac, Mat pc, void * ctx)
578561
579562 PetscBool pisshell , jismffd ;
580563
581- auto ierr = PetscObjectTypeCompare ((PetscObject )pc , MATSHELL , & pisshell );
582- CHKERRQ (ierr );
564+ LibmeshPetscCallQ (PetscObjectTypeCompare ((PetscObject )pc , MATSHELL , & pisshell ));
583565 if (pisshell )
584566 libmesh_error_msg ("Generic preconditioning requires that an explicit matrix representation of "
585567 "the preconditioner be formed" );
586- ierr = PetscObjectTypeCompare ((PetscObject )jac , MATMFFD , & jismffd );
587- CHKERRQ (ierr );
568+ LibmeshPetscCallQ (PetscObjectTypeCompare ((PetscObject )jac , MATMFFD , & jismffd ));
588569 if (!jismffd )
589570 libmesh_error_msg ("The operator should be formed matrix free" );
590571
@@ -714,10 +695,8 @@ form_matrixA(SNES /*snes*/, Vec x, Mat jac, Mat pc, void * ctx)
714695 }
715696
716697 // The MFFD Jac still must have assemble called on it
717- ierr = MatAssemblyBegin (jac , MAT_FINAL_ASSEMBLY );
718- CHKERRQ (ierr );
719- ierr = MatAssemblyEnd (jac , MAT_FINAL_ASSEMBLY );
720- CHKERRQ (ierr );
698+ LibmeshPetscCallQ (MatAssemblyBegin (jac , MAT_FINAL_ASSEMBLY ));
699+ LibmeshPetscCallQ (MatAssemblyEnd (jac , MAT_FINAL_ASSEMBLY ));
721700
722701 PetscFunctionReturn (LIBMESH_PETSC_SUCCESS );
723702}
0 commit comments