Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49ee1a9

Browse files
committed
Add LIBMESH_PETSC_SUCCESS
1 parent ae8cf31 commit 49ee1a9

19 files changed

+170
-167
lines changed

examples/eigenproblems/eigenproblems_ex4/eigenproblems_ex4.C

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ form_functionA(SNES /*snes*/, Vec x, Vec Ax, void * ctx)
422422
eigen_system.copy_super_to_sub(*AX, wrapped_Ax);
423423
}
424424

425-
PetscFunctionReturn(0);
425+
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
426426
}
427427

428428
PetscErrorCode
@@ -551,7 +551,7 @@ form_functionB(SNES /*snes*/, Vec x, Vec Bx, void * ctx)
551551
eigen_system.copy_super_to_sub(*BX, wrapped_Bx);
552552
}
553553

554-
PetscFunctionReturn(0);
554+
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
555555
}
556556

557557
PetscErrorCode
@@ -711,7 +711,7 @@ form_matrixA(SNES /*snes*/, Vec x, Mat jac, Mat pc, void * ctx)
711711
ierr = MatAssemblyEnd(jac, MAT_FINAL_ASSEMBLY);
712712
CHKERRQ(ierr);
713713

714-
PetscFunctionReturn(0);
714+
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
715715
}
716716

717717
#endif

examples/systems_of_equations/systems_of_equations_ex6/systems_of_equations_ex6.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public:
100100

101101
virtual void configure_solver()
102102
{
103-
PetscErrorCode ierr = 0;
103+
auto ierr = LIBMESH_PETSC_SUCCESS;
104104
ierr = KSPSetType (_petsc_linear_solver.ksp(), const_cast<KSPType>(KSPCG));
105105
CHKERRABORT(_petsc_linear_solver.comm().get(), ierr);
106106

include/numerics/petsc_macro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@
107107
// As of 3.19, PETSC_NULL is deprecated
108108
#if PETSC_VERSION_LESS_THAN(3,19,0)
109109
# define LIBMESH_PETSC_NULLPTR PETSC_NULL
110+
# define LIBMESH_PETSC_SUCCESS static_cast<PetscErrorCode>(0)
110111
#else
111112
# define LIBMESH_PETSC_NULLPTR PETSC_NULLPTR
113+
# define LIBMESH_PETSC_SUCCESS PETSC_SUCCESS
112114
#endif
113115

114116
// If we're using quad precision, we need to disambiguate std

include/numerics/petsc_solver_exception.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#ifdef LIBMESH_HAVE_PETSC
2424

2525
#include "libmesh/libmesh_exceptions.h"
26+
#include "libmesh/petsc_macro.h"
2627
#include "timpi/communicator.h"
2728

2829
#ifdef I
@@ -108,7 +109,7 @@ class PetscSolverException : public SolverException
108109
inline \
109110
void Function ## BeginEnd(const Parallel::Communicator & comm, const Args&... args) \
110111
{ \
111-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0); \
112+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS; \
112113
ierr = Function ## Begin(args...); \
113114
LIBMESH_CHKERR2(comm, ierr); \
114115
ierr = Function ## End(args...); \

include/numerics/petsc_vector.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ PetscVector<T>::PetscVector (Vec v,
572572

573573
/* We need to ask PETSc about the (local to global) ghost value
574574
mapping and create the inverse mapping out of it. */
575-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
575+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
576576
PetscInt petsc_local_size=0;
577577
ierr = VecGetLocalSize(_vec, &petsc_local_size);
578578
LIBMESH_CHKERR(ierr);
@@ -679,7 +679,7 @@ void PetscVector<T>::init (const numeric_index_type n,
679679
{
680680
parallel_object_only();
681681

682-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
682+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
683683
PetscInt petsc_n=static_cast<PetscInt>(n);
684684

685685
// Clear initialized vectors
@@ -758,7 +758,7 @@ void PetscVector<T>::init (const numeric_index_type n,
758758
{
759759
parallel_object_only();
760760

761-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
761+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
762762
PetscInt petsc_n=static_cast<PetscInt>(n);
763763
PetscInt petsc_n_local=static_cast<PetscInt>(n_local);
764764
PetscInt petsc_n_ghost=static_cast<PetscInt>(ghost.size());
@@ -909,7 +909,7 @@ void PetscVector<T>::zero ()
909909

910910
this->_restore_array();
911911

912-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
912+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
913913

914914
PetscScalar z=0.;
915915

@@ -967,7 +967,7 @@ numeric_index_type PetscVector<T>::size () const
967967
{
968968
libmesh_assert (this->initialized());
969969

970-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
970+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
971971
PetscInt petsc_size=0;
972972

973973
if (!this->initialized())
@@ -987,7 +987,7 @@ numeric_index_type PetscVector<T>::local_size () const
987987
{
988988
libmesh_assert (this->initialized());
989989

990-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
990+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
991991
PetscInt petsc_size=0;
992992

993993
ierr = VecGetLocalSize(_vec, &petsc_size);
@@ -1010,7 +1010,7 @@ numeric_index_type PetscVector<T>::first_local_index () const
10101010
first = _first;
10111011
else
10121012
{
1013-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
1013+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
10141014
PetscInt petsc_first=0, petsc_last=0;
10151015
ierr = VecGetOwnershipRange (_vec, &petsc_first, &petsc_last);
10161016
LIBMESH_CHKERR(ierr);
@@ -1034,7 +1034,7 @@ numeric_index_type PetscVector<T>::last_local_index () const
10341034
last = _last;
10351035
else
10361036
{
1037-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
1037+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
10381038
PetscInt petsc_first=0, petsc_last=0;
10391039
ierr = VecGetOwnershipRange (_vec, &petsc_first, &petsc_last);
10401040
LIBMESH_CHKERR(ierr);
@@ -1062,7 +1062,7 @@ numeric_index_type PetscVector<T>::map_global_to_local_index (const numeric_inde
10621062
}
10631063
else
10641064
{
1065-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
1065+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
10661066
PetscInt petsc_first=0, petsc_last=0;
10671067
ierr = VecGetOwnershipRange (_vec, &petsc_first, &petsc_last);
10681068
LIBMESH_CHKERR(ierr);
@@ -1188,7 +1188,7 @@ Real PetscVector<T>::min () const
11881188

11891189
this->_restore_array();
11901190

1191-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
1191+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
11921192
PetscInt index=0;
11931193
PetscReal returnval=0.;
11941194

@@ -1209,7 +1209,7 @@ Real PetscVector<T>::max() const
12091209

12101210
this->_restore_array();
12111211

1212-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
1212+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
12131213
PetscInt index=0;
12141214
PetscReal returnval=0.;
12151215

src/base/libmesh.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ LibMeshInit::LibMeshInit (int argc, const char * const * argv,
481481
#endif
482482
)
483483
{
484-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
484+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
485485

486486
#ifdef LIBMESH_HAVE_MPI
487487
PETSC_COMM_WORLD = libMesh::GLOBAL_COMM_WORLD;
@@ -789,7 +789,7 @@ LibMeshInit::~LibMeshInit()
789789
#endif
790790
)
791791
{
792-
PetscErrorCode ierr = static_cast<PetscErrorCode>(0);
792+
PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS;
793793
# if defined(LIBMESH_HAVE_SLEPC)
794794
if (libmesh_initialized_slepc)
795795
ierr = SlepcFinalize();

0 commit comments

Comments
 (0)