diff --git a/framework/src/utils/PetscDMMoose.C b/framework/src/utils/PetscDMMoose.C index 34b25b463d4f..3f71cf0a3115 100644 --- a/framework/src/utils/PetscDMMoose.C +++ b/framework/src/utils/PetscDMMoose.C @@ -140,7 +140,7 @@ DMMooseValidityCheck(DM dm) "Got DM of type %s, not of type %s", ((PetscObject)dm)->type_name, DMMOOSE); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -159,7 +159,7 @@ DMMooseGetContacts(DM dm, contact_names.push_back(it.second); displaced.push_back((*dmm->_contact_displaced)[it.second]); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -178,7 +178,7 @@ DMMooseGetUnContacts(DM dm, uncontact_names.push_back(it.second); displaced.push_back((*dmm->_uncontact_displaced)[it.second]); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -192,7 +192,7 @@ DMMooseGetSides(DM dm, std::vector & side_names) DM_Moose * dmm = (DM_Moose *)dm->data; for (const auto & it : *(dmm->_side_ids)) side_names.push_back(it.first); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -206,7 +206,7 @@ DMMooseGetUnSides(DM dm, std::vector & side_names) DM_Moose * dmm = (DM_Moose *)dm->data; for (const auto & it : *(dmm->_unside_ids)) side_names.push_back(it.first); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -220,7 +220,7 @@ DMMooseGetBlocks(DM dm, std::vector & block_names) DM_Moose * dmm = (DM_Moose *)dm->data; for (const auto & it : *(dmm->_block_ids)) block_names.push_back(it.first); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -234,7 +234,7 @@ DMMooseGetVariables(DM dm, std::vector & var_names) DM_Moose * dmm = (DM_Moose *)(dm->data); for (const auto & it : *(dmm->_var_ids)) var_names.push_back(it.first); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -251,7 +251,7 @@ DMMooseSetNonlinearSystem(DM dm, NonlinearSystemBase & nl) "Cannot reset the NonlinearSystem after DM has been set up."); DM_Moose * dmm = (DM_Moose *)(dm->data); dmm->_nl = &nl; - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -268,7 +268,7 @@ DMMooseSetName(DM dm, const std::string & dm_name) "Cannot reset the MOOSE DM name after DM has been set up."); DM_Moose * dmm = (DM_Moose *)(dm->data); *dmm->_name = dm_name; - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -286,7 +286,7 @@ DMMooseSetParentDM(DM dm, DM_Moose * parent) DM_Moose * dmm = (DM_Moose *)(dm->data); dmm->_parent = parent; - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -317,7 +317,7 @@ DMMooseSetVariables(DM dm, const std::set & vars) } dmm->_vars = new std::set(std::move(processed_vars)); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -334,7 +334,7 @@ DMMooseSetBlocks(DM dm, const std::set & blocks) if (dmm->_blocks) delete dmm->_blocks; dmm->_blocks = new std::set(blocks); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -351,7 +351,7 @@ DMMooseSetSides(DM dm, const std::set & sides) if (dmm->_sides) delete dmm->_sides; dmm->_sides = new std::set(sides); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -368,7 +368,7 @@ DMMooseSetUnSides(DM dm, const std::set & unsides) if (dmm->_unsides) delete dmm->_unsides; dmm->_unsides = new std::set(unsides); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -385,7 +385,7 @@ DMMooseSetUnSideByVar(DM dm, const std::set & unside_by_var) if (dmm->_unside_by_var) delete dmm->_unside_by_var; dmm->_unside_by_var = new std::set(unside_by_var); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -417,7 +417,7 @@ DMMooseSetContacts(DM dm, dmm->_contacts->insert(contacts[i]); dmm->_contact_displaced->insert(std::make_pair(contacts[i], displaced[i])); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -450,7 +450,7 @@ DMMooseSetUnContacts(DM dm, dmm->_uncontacts->insert(uncontacts[i]); dmm->_uncontact_displaced->insert(std::make_pair(uncontacts[i], displaced[i])); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -463,7 +463,7 @@ DMMooseGetNonlinearSystem(DM dm, NonlinearSystemBase *& nl) CHKERRQ(ierr); DM_Moose * dmm = (DM_Moose *)(dm->data); nl = dmm->_nl; - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -504,7 +504,7 @@ DMMooseSetSplitNames(DM dm, const std::vector & split_names) (*dmm->_splits)[name] = info; dmm->_splitlocs->insert(std::make_pair(name, i)); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -527,7 +527,7 @@ DMMooseGetSplitNames(DM dm, std::vector & split_names) unsigned int sloc = lit.second; split_names[sloc] = sname; } - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -538,7 +538,7 @@ DMMooseGetEmbedding_Private(DM dm, IS * embedding) PetscFunctionBegin; if (!embedding) - return PetscErrorCode(0); + return PETSC_SUCCESS; if (!dmm->_embedding) { // The rules interpreting the coexistence of blocks (un)sides/(un)contacts are these @@ -870,7 +870,7 @@ DMMooseGetEmbedding_Private(DM dm, IS * embedding) CHKERRQ(ierr); *embedding = dmm->_embedding; - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -886,7 +886,7 @@ DMCreateFieldDecomposition_Moose( /* Only called after DMSetUp(). */ if (!dmm->_splitlocs) - return PetscErrorCode(0); + return PETSC_SUCCESS; *len = dmm->_splitlocs->size(); if (namelist) { @@ -966,17 +966,16 @@ DMCreateFieldDecomposition_Moose( ierr = ISGetLocalSize(dmm->_embedding, &len); CHKERRQ(ierr); - ierr = cast_int(MPI_Scan(&len, - &off, - 1, + MPI_Scan(&len, + &off, + 1, #ifdef PETSC_USE_64BIT_INDICES - MPI_LONG_LONG_INT, + MPI_LONG_LONG_INT, #else - MPI_INT, + MPI_INT, #endif - MPI_SUM, - ((PetscObject)dm)->comm)); - CHKERRQ(ierr); + MPI_SUM, + ((PetscObject)dm)->comm); off -= len; for (i = 0; i < llen; ++i) @@ -1015,7 +1014,7 @@ DMCreateFieldDecomposition_Moose( split_size_sum, dmm->_nl->nonlinearSolver()->system().get_system_matrix().local_m()); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1031,7 +1030,7 @@ DMCreateDomainDecomposition_Moose( *outerislist = LIBMESH_PETSC_NULLPTR; /* FIX: allow mesh-based overlap. */ ierr = DMCreateFieldDecomposition_Moose(dm, len, namelist, innerislist, dmlist); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1103,7 +1102,7 @@ DMMooseFunction(DM dm, Vec x, Vec r) mooseError(err.str()); } R.close(); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1115,7 +1114,7 @@ SNESFunction_DMMoose(SNES, Vec x, Vec r, void * ctx) PetscFunctionBegin; ierr = DMMooseFunction(dm, x, r); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1197,7 +1196,7 @@ DMMooseJacobian(DM dm, Vec x, Mat jac, Mat pc) } the_pc.close(); Jac.close(); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1209,7 +1208,7 @@ SNESJacobian_DMMoose(SNES, Vec x, Mat jac, Mat pc, void * ctx) PetscFunctionBegin; ierr = DMMooseJacobian(dm, x, jac, pc); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1236,7 +1235,7 @@ DMVariableBounds_Moose(DM dm, Vec xl, Vec xu) else SETERRQ( ((PetscObject)dm)->comm, PETSC_ERR_ARG_WRONG, "No bounds calculation in this Moose object"); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1286,7 +1285,7 @@ DMCreateGlobalVector_Moose(DM dm, Vec * x) ierr = VecSetDM(*x, dm); CHKERRQ(ierr); #endif - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1343,7 +1342,7 @@ DMCreateMatrix_Moose(DM dm, Mat * A) * settings made here. */ ierr = MatSetUp(*A); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1476,7 +1475,7 @@ DMView_Moose(DM dm, PetscViewer viewer) else SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Non-ASCII viewers are not supported"); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1499,7 +1498,7 @@ DMMooseGetMeshBlocks_Private(DM dm, std::set & blocks) blocks.insert(elem->subdomain_id()); // Some subdomains may only live on other processors mesh.comm().set_union(blocks); - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1758,7 +1757,7 @@ DMSetUp_Moose_Pre(DM dm) } ierr = PetscObjectSetName((PetscObject)dm, name.c_str()); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1772,7 +1771,7 @@ DMMooseReset(DM dm) ierr = PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose); CHKERRQ(ierr); if (!ismoose) - return PetscErrorCode(0); + return PETSC_SUCCESS; if (!dmm->_nl) SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONGSTATE, "No Moose system set for DM_Moose"); ierr = ISDestroy(&dmm->_embedding); @@ -1789,7 +1788,7 @@ DMMooseReset(DM dm) } } dm->setupcalled = PETSC_FALSE; - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -1852,7 +1851,7 @@ DMSetUp_Moose(DM dm) ierr = DMSetVariableBounds(dm, DMVariableBounds_Moose); CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } #if !PETSC_VERSION_LESS_THAN(3, 18, 0) @@ -2237,7 +2236,7 @@ DMSetFromOptions_Moose(PetscOptions * /*options*/, DM dm) // >= 3.6.0 ierr = DMSetUp_Moose_Pre(dm); CHKERRQ(ierr); /* Need some preliminary set up because, strangely enough, DMView() is called in DMSetFromOptions(). */ - return PetscErrorCode(0); + return PETSC_SUCCESS; } static PetscErrorCode @@ -2292,7 +2291,7 @@ DMDestroy_Moose(DM dm) CHKERRQ(ierr); ierr = PetscFree(dm->data); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -2309,7 +2308,7 @@ DMCreateMoose(MPI_Comm comm, NonlinearSystemBase & nl, const std::string & dm_na CHKERRQ(ierr); ierr = DMMooseSetName(*dm, dm_name); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } EXTERN_C_BEGIN @@ -2371,7 +2370,7 @@ DMCreate_Moose(DM dm) dm->ops->view = DMView_Moose; dm->ops->setfromoptions = DMSetFromOptions_Moose; dm->ops->setup = DMSetUp_Moose; - return PetscErrorCode(0); + return PETSC_SUCCESS; } EXTERN_C_END @@ -2426,7 +2425,7 @@ SNESUpdateDMMoose(SNES snes, PetscInt iteration) ierr = PCDestroy(&pc); CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -2442,5 +2441,5 @@ DMMooseRegisterAll() CHKERRQ(ierr); DMMooseRegisterAllCalled = PETSC_TRUE; } - return PetscErrorCode(0); + return PETSC_SUCCESS; } diff --git a/framework/src/utils/PetscSupport.C b/framework/src/utils/PetscSupport.C index 19224b5e57ac..4bbbc632787d 100644 --- a/framework/src/utils/PetscSupport.C +++ b/framework/src/utils/PetscSupport.C @@ -278,7 +278,7 @@ petscSetupOutput(CommandLine * cmd_line) break; } } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -346,7 +346,7 @@ petscNonlinearConverged(SNES snes, if (domainerror) { *reason = SNES_DIVERGED_FUNCTION_DOMAIN; - return PetscErrorCode(0); + return PETSC_SUCCESS; } // Error message that will be set by the FEProblemBase. @@ -418,7 +418,7 @@ petscNonlinearConverged(SNES snes, break; } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PCSide diff --git a/framework/src/utils/SlepcSupport.C b/framework/src/utils/SlepcSupport.C index 27761a3c8b96..741c13afb375 100644 --- a/framework/src/utils/SlepcSupport.C +++ b/framework/src/utils/SlepcSupport.C @@ -520,13 +520,13 @@ mooseEPSFormMatrices(EigenProblem & eigen_problem, EPS eps, Vec x, void * ctx) PetscFunctionBegin; if (eigen_problem.constantMatrices() && eigen_problem.wereMatricesFormed()) - return PetscErrorCode(0); + return PETSC_SUCCESS; if (eigen_problem.onLinearSolver()) // We reach here during linear iteration when solve type is PJFNKMO. // We will use the matrices assembled at the beginning of this Newton // iteration for the following residual evaluation. - return PetscErrorCode(0); + return PETSC_SUCCESS; NonlinearEigenSystem & eigen_nl = eigen_problem.getCurrentNonlinearEigenSystem(); SNES snes = eigen_nl.getSNES(); @@ -552,7 +552,7 @@ mooseEPSFormMatrices(EigenProblem & eigen_problem, EPS eps, Vec x, void * ctx) moosePetscSNESFormMatricesTags( snes, x, mats, ctx, {eigen_nl.nonEigenMatrixTag(), eigen_nl.eigenMatrixTag()}); eigen_problem.wereMatricesFormed(true); - return PetscErrorCode(0); + return PETSC_SUCCESS; } void @@ -644,7 +644,7 @@ mooseSlepcEigenFormFunctionMFFD(void * ctx, Vec x, Vec r) eigen_problem->onLinearSolver(false); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -683,7 +683,7 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) ierr = MatAssemblyEnd(jac, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } ierr = PetscObjectTypeCompare((PetscObject)pc, MATSHELL, &pisshell); @@ -700,7 +700,7 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) ierr = MatAssemblyEnd(pc, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } // Jacobian and precond matrix are the same @@ -709,7 +709,7 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) if (!pisshell) moosePetscSNESFormMatrixTag(snes, x, pc, ctx, eigen_nl.precondMatrixTag()); - return PetscErrorCode(0); + return PETSC_SUCCESS; } else { @@ -718,7 +718,7 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) std::vector mats = {jac, pc}; moosePetscSNESFormMatricesTags( snes, x, mats, ctx, {eigen_nl.nonEigenMatrixTag(), eigen_nl.precondMatrixTag()}); - return PetscErrorCode(0); + return PETSC_SUCCESS; } if (!pisshell) // We need to form only precond matrix { @@ -727,7 +727,7 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) CHKERRQ(ierr); ierr = MatAssemblyEnd(jac, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } if (!jisshell && !jismffd) // We need to form only Jacobian matrix { @@ -736,10 +736,10 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) CHKERRQ(ierr); ierr = MatAssemblyEnd(pc, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -774,7 +774,7 @@ mooseSlepcEigenFormJacobianB(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) ierr = MatAssemblyEnd(pc, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } if (jac != pc && (!jshell && !jshell)) @@ -790,7 +790,7 @@ mooseSlepcEigenFormJacobianB(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } void @@ -850,12 +850,12 @@ mooseSlepcEigenFormFunctionA(SNES snes, Vec x, Vec r, void * ctx) ierr = MatMult(A, x, r); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } moosePetscSNESFormFunction(snes, x, r, ctx, eigen_nl.nonEigenVectorTag()); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -898,7 +898,7 @@ mooseSlepcEigenFormFunctionB(SNES snes, Vec x, Vec r, void * ctx) CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -942,7 +942,7 @@ mooseSlepcEigenFormFunctionAB(SNES /*snes*/, Vec x, Vec Ax, Vec Bx, void * ctx) CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscVector X_global(x, sys.comm()), AX(Ax, sys.comm()), BX(Bx, sys.comm()); @@ -978,7 +978,7 @@ mooseSlepcEigenFormFunctionAB(SNES /*snes*/, Vec x, Vec Ax, Vec Bx, void * ctx) CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -987,7 +987,7 @@ mooseSlepcEigenFormNorm(SNES /*snes*/, Vec /*Bx*/, PetscReal * norm, void * ctx) PetscFunctionBegin; auto * const eigen_problem = static_cast(ctx); *norm = eigen_problem->formNorm(); - return PetscErrorCode(0); + return PETSC_SUCCESS; } void @@ -1004,40 +1004,51 @@ attachCallbacksToMat(EigenProblem & eigen_problem, Mat mat, bool eigen) // Attach the Jacobian computation function. If \p mat is the "eigen" matrix corresponding to B, // then attach our JacobianB computation routine, else the matrix corresponds to A, and we attach // the JacobianA computation routine - LIBMESH_CHKERR( - PetscObjectComposeFunction((PetscObject)mat, - "formJacobian", - eigen ? Moose::SlepcSupport::mooseSlepcEigenFormJacobianB - : Moose::SlepcSupport::mooseSlepcEigenFormJacobianA)); + auto ierr = PetscObjectComposeFunction((PetscObject)mat, + "formJacobian", + eigen ? Moose::SlepcSupport::mooseSlepcEigenFormJacobianB + : Moose::SlepcSupport::mooseSlepcEigenFormJacobianA); + LIBMESH_CHKERR(ierr); // Attach the residual computation function. If \p mat is the "eigen" matrix corresponding to B, // then attach our FunctionB computation routine, else the matrix corresponds to A, and we attach // the FunctionA computation routine - LIBMESH_CHKERR( - PetscObjectComposeFunction((PetscObject)mat, - "formFunction", - eigen ? Moose::SlepcSupport::mooseSlepcEigenFormFunctionB - : Moose::SlepcSupport::mooseSlepcEigenFormFunctionA)); + ierr = PetscObjectComposeFunction((PetscObject)mat, + "formFunction", + eigen ? Moose::SlepcSupport::mooseSlepcEigenFormFunctionB + : Moose::SlepcSupport::mooseSlepcEigenFormFunctionA); + LIBMESH_CHKERR(ierr); // It's also beneficial to be able to evaluate both A and B residuals at once - LIBMESH_CHKERR(PetscObjectComposeFunction( - (PetscObject)mat, "formFunctionAB", Moose::SlepcSupport::mooseSlepcEigenFormFunctionAB)); + ierr = PetscObjectComposeFunction( + (PetscObject)mat, "formFunctionAB", Moose::SlepcSupport::mooseSlepcEigenFormFunctionAB); + LIBMESH_CHKERR(ierr); // Users may choose to provide a custom measure of the norm of B (Bx for a linear system) if (eigen_problem.bxNormProvided()) - LIBMESH_CHKERR(PetscObjectComposeFunction( - (PetscObject)mat, "formNorm", Moose::SlepcSupport::mooseSlepcEigenFormNorm)); + { + ierr = PetscObjectComposeFunction( + (PetscObject)mat, "formNorm", Moose::SlepcSupport::mooseSlepcEigenFormNorm); + LIBMESH_CHKERR(ierr); + } // Finally we need to attach the "context" object, which is our EigenProblem, to the matrices so // that eventually when we get callbacks from SLEPc we can call methods on the EigenProblem PetscContainer container; - LIBMESH_CHKERR(PetscContainerCreate(eigen_problem.comm().get(), &container)); - LIBMESH_CHKERR(PetscContainerSetPointer(container, &eigen_problem)); - LIBMESH_CHKERR(PetscObjectCompose((PetscObject)mat, "formJacobianCtx", (PetscObject)container)); - LIBMESH_CHKERR(PetscObjectCompose((PetscObject)mat, "formFunctionCtx", (PetscObject)container)); + ierr = PetscContainerCreate(eigen_problem.comm().get(), &container); + LIBMESH_CHKERR(ierr); + ierr = PetscContainerSetPointer(container, &eigen_problem); + LIBMESH_CHKERR(ierr); + ierr = PetscObjectCompose((PetscObject)mat, "formJacobianCtx", (PetscObject)container); + LIBMESH_CHKERR(ierr); + ierr = PetscObjectCompose((PetscObject)mat, "formFunctionCtx", (PetscObject)container); if (eigen_problem.bxNormProvided()) - LIBMESH_CHKERR(PetscObjectCompose((PetscObject)mat, "formNormCtx", (PetscObject)container)); - LIBMESH_CHKERR(PetscContainerDestroy(&container)); + { + ierr = PetscObjectCompose((PetscObject)mat, "formNormCtx", (PetscObject)container); + LIBMESH_CHKERR(ierr); + } + ierr = PetscContainerDestroy(&container); + LIBMESH_CHKERR(ierr); } void @@ -1087,7 +1098,7 @@ mooseMatMult_Eigen(Mat mat, Vec x, Vec r) CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1106,17 +1117,19 @@ mooseMatMult_NonEigen(Mat mat, Vec x, Vec r) mooseMatMult(*eigen_problem, x, r, eigen_nl.nonEigenVectorTag()); - return PetscErrorCode(0); + return PETSC_SUCCESS; } void setOperationsForShellMat(EigenProblem & eigen_problem, Mat mat, bool eigen) { - LIBMESH_CHKERR(MatShellSetContext(mat, &eigen_problem)); - LIBMESH_CHKERR(MatShellSetOperation(mat, - MATOP_MULT, - eigen ? (void (*)(void))mooseMatMult_Eigen - : (void (*)(void))mooseMatMult_NonEigen)); + auto ierr = MatShellSetContext(mat, &eigen_problem); + LIBMESH_CHKERR(ierr); + ierr = MatShellSetOperation(mat, + MATOP_MULT, + eigen ? (void (*)(void))mooseMatMult_Eigen + : (void (*)(void))mooseMatMult_NonEigen); + LIBMESH_CHKERR(ierr); } PETSC_EXTERN PetscErrorCode @@ -1128,7 +1141,7 @@ registerPCToPETSc() ierr = PCRegister("moosepc", PCCreate_MoosePC); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PETSC_EXTERN PetscErrorCode @@ -1141,7 +1154,7 @@ PCCreate_MoosePC(PC pc) pc->ops->setup = PCSetUp_MoosePC; pc->ops->apply = PCApply_MoosePC; - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1150,7 +1163,7 @@ PCDestroy_MoosePC(PC /*pc*/) PetscFunctionBegin; /* We do not need to do anything right now, but later we may have some data we need to free here */ - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1167,7 +1180,7 @@ PCView_MoosePC(PC /*pc*/, PetscViewer viewer) ierr = PetscViewerASCIIPrintf(viewer, " %s\n", "moosepc"); CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1204,7 +1217,7 @@ PCApply_MoosePC(PC pc, Vec x, Vec y) preconditioner->apply(x_vec, y_vec); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1240,7 +1253,7 @@ PCSetUp_MoosePC(PC pc) preconditioner->setup(); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1269,7 +1282,7 @@ mooseSlepcStoppingTest(EPS eps, *reason = EPS_CONVERGED_USER; eps->nconv = 1; } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1293,7 +1306,7 @@ mooseSlepcEPSGetSNES(EPS eps, SNES * snes) ierr = EPSPowerGetSNES(eps, snes); LIBMESH_CHKERR(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1314,7 +1327,7 @@ mooseSlepcEPSSNESSetUpOptionPrefix(EPS eps) ierr = SNESSetOptionsPrefix(snes, prefix); LIBMESH_CHKERR(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1337,7 +1350,7 @@ mooseSlepcEPSSNESSetCustomizePC(EPS eps) // Set PC type ierr = PCSetType(pc, "moosepc"); LIBMESH_CHKERR(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1357,7 +1370,7 @@ mooseSlepcEPSSNESKSPSetPCSide(FEProblemBase & problem, EPS eps) Moose::PetscSupport::petscSetDefaultPCSide(problem, ksp); Moose::PetscSupport::petscSetDefaultKSPNormType(problem, ksp); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -1392,7 +1405,7 @@ mooseSlepcEPSMonitor(EPS eps, console << " Iteration " << its << std::setprecision(10) << std::fixed << (inverse ? " k-eigenvalue = " : " eigenvalue = ") << eigenvalue << std::endl; - return PetscErrorCode(0); + return PETSC_SUCCESS; } } // namespace SlepcSupport diff --git a/modules/external_petsc_solver/src/petscsolver/PETScDiffusionFDM.C b/modules/external_petsc_solver/src/petscsolver/PETScDiffusionFDM.C index c37cfb223190..00b7b67c9501 100644 --- a/modules/external_petsc_solver/src/petscsolver/PETScDiffusionFDM.C +++ b/modules/external_petsc_solver/src/petscsolver/PETScDiffusionFDM.C @@ -83,7 +83,7 @@ PETScExternalSolverCreate(MPI_Comm comm, TS * ts) CHKERRQ(ierr); ierr = TSSetFromOptions(*ts); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -94,7 +94,7 @@ PETScExternalSolverDestroy(TS ts) PetscFunctionBeginUser; ierr = TSDestroy(&ts); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } /* @@ -185,7 +185,7 @@ externalPETScDiffusionFDMSolve( CHKERRQ(ierr); *converged = reason > 0 ? PETSC_TRUE : PETSC_FALSE; - return PetscErrorCode(0); + return PETSC_SUCCESS; } /* --------------------------------------------------------------------- */ @@ -335,7 +335,7 @@ FormIFunction(TS ts, PetscReal /*t*/, Vec U, Vec Udot, Vec F, void * /*ctx*/) CHKERRQ(ierr); ierr = PetscLogFlops(11.0 * ym * xm); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } /* --------------------------------------------------------------------- */ @@ -462,7 +462,7 @@ FormIJacobian( CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } /* ------------------------------------------------------------------- */ @@ -524,5 +524,5 @@ FormInitialSolution(TS ts, Vec U, void * /*ptr*/) /* Restore vectors */ ierr = DMDAVecRestoreArray(da, U, &u); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } diff --git a/modules/optimization/src/executioners/OptimizeSolve.C b/modules/optimization/src/executioners/OptimizeSolve.C index f5e39c5eea0b..0aa8d0602f40 100644 --- a/modules/optimization/src/executioners/OptimizeSolve.C +++ b/modules/optimization/src/executioners/OptimizeSolve.C @@ -345,7 +345,7 @@ OptimizeSolve::monitor(Tao tao, void * ctx) auto * solver = static_cast(ctx); solver->setTaoSolutionStatus((double)f, (int)its, (double)gnorm, (double)cnorm, (double)xdiff); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -357,7 +357,7 @@ OptimizeSolve::objectiveFunctionWrapper(Tao /*tao*/, Vec x, Real * objective, vo *solver->_parameters = param; (*objective) = solver->objectiveFunction(); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -374,7 +374,7 @@ OptimizeSolve::objectiveAndGradientFunctionWrapper( libMesh::PetscVector grad(gradient, solver->_my_comm); solver->gradientFunction(grad); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -387,7 +387,7 @@ OptimizeSolve::hessianFunctionWrapper(Tao /*tao*/, Vec x, Mat /*hessian*/, Mat / PetscErrorCode ierr = MatShellSetOperation( solver->_hessian, MATOP_MULT, (void (*)(void))OptimizeSolve::applyHessianWrapper); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -486,7 +486,7 @@ OptimizeSolve::applyHessian(libMesh::PetscVector & s, libMesh::PetscVect _obj_function->computeGradient(Hs); _hess_iterate++; - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -518,7 +518,7 @@ OptimizeSolve::equalityFunctionWrapper(Tao /*tao*/, Vec /*x*/, Vec ce, void * ct // use the OptimizationReporterBase class to actually compute equality constraints OptimizationReporterBase * obj_func = solver->getObjFunction(); obj_func->computeEqualityConstraints(eq_con); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -532,7 +532,7 @@ OptimizeSolve::equalityGradientFunctionWrapper( // constraints gradient OptimizationReporterBase * obj_func = solver->getObjFunction(); obj_func->computeEqualityGradient(grad_eq); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -544,7 +544,7 @@ OptimizeSolve::inequalityFunctionWrapper(Tao /*tao*/, Vec /*x*/, Vec ci, void * // use the OptimizationReporterBase class to actually compute equality constraints OptimizationReporterBase * obj_func = solver->getObjFunction(); obj_func->computeInequalityConstraints(ineq_con); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -558,7 +558,7 @@ OptimizeSolve::inequalityGradientFunctionWrapper( // constraints gradient OptimizationReporterBase * obj_func = solver->getObjFunction(); obj_func->computeInequalityGradient(grad_ineq); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -633,7 +633,7 @@ OptimizeSolve::taoALCreate() _tao, _gradient_i, _gradient_i, inequalityGradientFunctionWrapper, this); CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -656,5 +656,5 @@ OptimizeSolve::taoALDestroy() CHKERRQ(ierr); } - return PetscErrorCode(0); + return PETSC_SUCCESS; } diff --git a/modules/stochastic_tools/src/utils/GaussianProcessHandler.C b/modules/stochastic_tools/src/utils/GaussianProcessHandler.C index bf9a323892aa..52d5c89eb2db 100644 --- a/modules/stochastic_tools/src/utils/GaussianProcessHandler.C +++ b/modules/stochastic_tools/src/utils/GaussianProcessHandler.C @@ -213,7 +213,7 @@ GaussianProcessHandler::tuneHyperParamsTAO(const RealEigenMatrix & training_para ierr = TaoDestroy(&tao); CHKERRQ(ierr); - return PetscErrorCode(0); + return PETSC_SUCCESS; } PetscErrorCode @@ -222,7 +222,7 @@ GaussianProcessHandler::formInitialGuessTAO(Vec theta_vec) libMesh::PetscVector theta(theta_vec, _tao_comm); _covariance_function->buildHyperParamMap(_hyperparam_map, _hyperparam_vec_map); mapToPetscVec(_tuning_data, _hyperparam_map, _hyperparam_vec_map, theta); - return PetscErrorCode(0); + return PETSC_SUCCESS; } void @@ -245,7 +245,7 @@ GaussianProcessHandler::formFunctionGradientWrapper( { GaussianProcessHandler * GP_ptr = (GaussianProcessHandler *)ptr; GP_ptr->formFunctionGradient(tao, theta_vec, f, grad_vec); - return PetscErrorCode(0); + return PETSC_SUCCESS; } void