diff --git a/framework/src/outputs/PetscOutput.C b/framework/src/outputs/PetscOutput.C index 2329dd7bcfe3..2ba5d899a9f4 100644 --- a/framework/src/outputs/PetscOutput.C +++ b/framework/src/outputs/PetscOutput.C @@ -244,8 +244,10 @@ PetscOutput::solveSetup() // get an updated nonlinear iteration number) // Not every Output should register its own DM monitor! Just register one each of nonlinear // and linear and dispatch all Outputs from there! - LibmeshPetscCallA(_communicator.get(), SNESMonitorSet(snes, petscNonlinearOutput, this, LIBMESH_PETSC_NULLPTR)); - LibmeshPetscCallA(_communicator.get(), KSPMonitorSet(ksp, petscLinearOutput, this, LIBMESH_PETSC_NULLPTR)); + LibmeshPetscCallA(_communicator.get(), + SNESMonitorSet(snes, petscNonlinearOutput, this, LIBMESH_PETSC_NULLPTR)); + LibmeshPetscCallA(_communicator.get(), + KSPMonitorSet(ksp, petscLinearOutput, this, LIBMESH_PETSC_NULLPTR)); } Real diff --git a/framework/src/partitioner/PetscExternalPartitioner.C b/framework/src/partitioner/PetscExternalPartitioner.C index 34eb9318a19b..fb5538f9073f 100644 --- a/framework/src/partitioner/PetscExternalPartitioner.C +++ b/framework/src/partitioner/PetscExternalPartitioner.C @@ -250,7 +250,9 @@ PetscExternalPartitioner::partitionGraph(const Parallel::Communicator & comm, values[i++] = weight; } - LibmeshPetscCallA(comm.get(), MatCreateMPIAdj(comm.get(), num_local_elems, num_elems, xadj, adjncy, values, &dual)); + LibmeshPetscCallA( + comm.get(), + MatCreateMPIAdj(comm.get(), num_local_elems, num_elems, xadj, adjncy, values, &dual)); LibmeshPetscCallA(comm.get(), MatPartitioningCreate(comm.get(), &part)); #if !PETSC_VERSION_LESS_THAN(3, 12, 3) @@ -289,7 +291,8 @@ PetscExternalPartitioner::partitionGraph(const Parallel::Communicator & comm, #endif LibmeshPetscCallA(comm.get(), MatPartitioningSetType(part, part_package.c_str())); if (part_package == "hierarch") - LibmeshPetscCallA(comm.get(), MatPartitioningHierarchicalSetNfineparts(part, num_parts_per_compute_node)); + LibmeshPetscCallA(comm.get(), + MatPartitioningHierarchicalSetNfineparts(part, num_parts_per_compute_node)); LibmeshPetscCallA(comm.get(), MatPartitioningSetFromOptions(part)); LibmeshPetscCallA(comm.get(), MatPartitioningApply(part, &is)); diff --git a/framework/src/systems/NonlinearSystem.C b/framework/src/systems/NonlinearSystem.C index 77a259e277d4..7c6aea152319 100644 --- a/framework/src/systems/NonlinearSystem.C +++ b/framework/src/systems/NonlinearSystem.C @@ -316,7 +316,8 @@ NonlinearSystem::setupColoringFiniteDifferencedPreconditioner() LibmeshPetscCallA(_communicator.get(), MatColoringApply(matcoloring, &iscoloring)); LibmeshPetscCallA(_communicator.get(), MatColoringDestroy(&matcoloring)); - LibmeshPetscCallA(_communicator.get(), MatFDColoringCreate(petsc_mat->mat(), iscoloring, &_fdcoloring)); + LibmeshPetscCallA(_communicator.get(), + MatFDColoringCreate(petsc_mat->mat(), iscoloring, &_fdcoloring)); LibmeshPetscCallA(_communicator.get(), MatFDColoringSetFromOptions(_fdcoloring)); // clang-format off LibmeshPetscCallA(_communicator.get(), MatFDColoringSetFunction(_fdcoloring, @@ -324,12 +325,14 @@ NonlinearSystem::setupColoringFiniteDifferencedPreconditioner() libMesh::libmesh_petsc_snes_fd_residual, &petsc_nonlinear_solver)); // clang-format on - LibmeshPetscCallA(_communicator.get(), MatFDColoringSetUp(petsc_mat->mat(), iscoloring, _fdcoloring)); - LibmeshPetscCallA(_communicator.get(), SNESSetJacobian(petsc_nonlinear_solver.snes(), - petsc_mat->mat(), - petsc_mat->mat(), - SNESComputeJacobianDefaultColor, - _fdcoloring)); + LibmeshPetscCallA(_communicator.get(), + MatFDColoringSetUp(petsc_mat->mat(), iscoloring, _fdcoloring)); + LibmeshPetscCallA(_communicator.get(), + SNESSetJacobian(petsc_nonlinear_solver.snes(), + petsc_mat->mat(), + petsc_mat->mat(), + SNESComputeJacobianDefaultColor, + _fdcoloring)); // PETSc >=3.3.0 LibmeshPetscCallA(_communicator.get(), ISColoringDestroy(&iscoloring)); } diff --git a/framework/src/utils/PetscDMMoose.C b/framework/src/utils/PetscDMMoose.C index 07e240ebf33f..c379fd327b7e 100644 --- a/framework/src/utils/PetscDMMoose.C +++ b/framework/src/utils/PetscDMMoose.C @@ -803,7 +803,8 @@ DMMooseGetEmbedding_Private(DM dm, IS * embedding) LibmeshPetscCallQ(DMCreateGlobalVector(dm, &v)); LibmeshPetscCallQ(VecGetOwnershipRange(v, &low, &high)); - LibmeshPetscCallQ(ISCreateStride(((PetscObject)dm)->comm, (high - low), low, 1, &dmm->_embedding)); + LibmeshPetscCallQ( + ISCreateStride(((PetscObject)dm)->comm, (high - low), low, 1, &dmm->_embedding)); } } LibmeshPetscCallQ(PetscObjectReference((PetscObject)(dmm->_embedding))); @@ -840,7 +841,8 @@ DMCreateFieldDecomposition_Moose( if (!dinfo._dm) { LibmeshPetscCallQ(DMCreateMoose(((PetscObject)dm)->comm, *dmm->_nl, dname, &dinfo._dm)); - LibmeshPetscCallQ(PetscObjectSetOptionsPrefix((PetscObject)dinfo._dm, ((PetscObject)dm)->prefix)); + LibmeshPetscCallQ( + PetscObjectSetOptionsPrefix((PetscObject)dinfo._dm, ((PetscObject)dm)->prefix)); std::string suffix = std::string("fieldsplit_") + dname + "_"; LibmeshPetscCallQ(PetscObjectAppendOptionsPrefix((PetscObject)dinfo._dm, suffix.c_str())); LibmeshPetscCallQ(DMMooseSetParentDM(dinfo._dm, dmm)); @@ -1225,7 +1227,8 @@ DMView_Moose(DM dm, PetscViewer viewer) { LibmeshPetscCallQ(PetscObjectGetName((PetscObject)dm, &name)); LibmeshPetscCallQ(PetscObjectGetOptionsPrefix((PetscObject)dm, &prefix)); - LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "DM Moose with name %s and prefix %s\n", name, prefix)); + LibmeshPetscCallQ( + PetscViewerASCIIPrintf(viewer, "DM Moose with name %s and prefix %s\n", name, prefix)); LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "variables:")); for (const auto & vit : *(dmm->_var_ids)) { @@ -1244,7 +1247,8 @@ DMView_Moose(DM dm, PetscViewer viewer) LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "sides:")); for (const auto & sit : *(dmm->_side_ids)) { - LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "(%s,%d) ", sit.first.c_str(), sit.second)); + LibmeshPetscCallQ( + PetscViewerASCIIPrintf(viewer, "(%s,%d) ", sit.first.c_str(), sit.second)); } LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "\n")); } @@ -1254,7 +1258,8 @@ DMView_Moose(DM dm, PetscViewer viewer) LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "unsides:")); for (const auto & sit : *(dmm->_unside_ids)) { - LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "(%s,%d) ", sit.first.c_str(), sit.second)); + LibmeshPetscCallQ( + PetscViewerASCIIPrintf(viewer, "(%s,%d) ", sit.first.c_str(), sit.second)); } LibmeshPetscCallQ(PetscViewerASCIIPrintf(viewer, "\n")); } @@ -1976,8 +1981,8 @@ DMSetFromOptions_Moose(PetscOptions * /*options*/, DM dm) // >= 3.6.0 &dmm->_print_embedding, LIBMESH_PETSC_NULLPTR)); PetscOptionsEnd(); - LibmeshPetscCallQ(DMSetUp_Moose_Pre(dm)); /* Need some preliminary set up because, strangely enough, DMView() is called in - DMSetFromOptions(). */ + LibmeshPetscCallQ(DMSetUp_Moose_Pre(dm)); /* Need some preliminary set up because, strangely + enough, DMView() is called in DMSetFromOptions(). */ PetscFunctionReturn(PETSC_SUCCESS); } diff --git a/framework/src/utils/PetscSupport.C b/framework/src/utils/PetscSupport.C index 5987b3166e80..25028ffa8603 100644 --- a/framework/src/utils/PetscSupport.C +++ b/framework/src/utils/PetscSupport.C @@ -301,7 +301,8 @@ petscNonlinearConverged(SNES snes, PetscInt maxf = 0; // maximum number of function evaluations // Ask the SNES object about its tolerances. - LibmeshPetscCallA(problem.comm().get(), SNESGetTolerances(snes, &atol, &rtol, &stol, &maxit, &maxf)); + LibmeshPetscCallA(problem.comm().get(), + SNESGetTolerances(snes, &atol, &rtol, &stol, &maxit, &maxf)); // Ask the SNES object about its divergence tolerance. PetscReal divtol = 0.; // relative divergence tolerance @@ -452,7 +453,8 @@ petscSetDefaultKSPNormType(FEProblemBase & problem, KSP ksp) for (const auto i : make_range(problem.numSolverSystems())) { SolverSystem & sys = problem.getSolverSystem(i); - LibmeshPetscCallA(problem.comm().get(), KSPSetNormType(ksp, getPetscKSPNormType(sys.getMooseKSPNormType()))); + LibmeshPetscCallA(problem.comm().get(), + KSPSetNormType(ksp, getPetscKSPNormType(sys.getMooseKSPNormType()))); } } @@ -524,7 +526,9 @@ petscSetDefaults(FEProblemBase & problem) // we use the default context provided by PETSc in addition to // a few other tests. { - LibmeshPetscCallA(nl.comm().get(), SNESSetConvergenceTest(snes, petscNonlinearConverged, &problem, LIBMESH_PETSC_NULLPTR)); + LibmeshPetscCallA( + nl.comm().get(), + SNESSetConvergenceTest(snes, petscNonlinearConverged, &problem, LIBMESH_PETSC_NULLPTR)); } petscSetKSPDefaults(problem, ksp); diff --git a/framework/src/utils/SlepcSupport.C b/framework/src/utils/SlepcSupport.C index de95d194af77..fc854ed5ebbc 100644 --- a/framework/src/utils/SlepcSupport.C +++ b/framework/src/utils/SlepcSupport.C @@ -732,7 +732,8 @@ mooseSlepcEigenFormJacobianA(SNES snes, Vec x, Mat jac, Mat pc, void * ctx) if (jismffd && eigen_problem->solverParams()._eigen_matrix_vector_mult) { - LibmeshPetscCallQ(MatMFFDSetFunction(jac, Moose::SlepcSupport::mooseSlepcEigenFormFunctionMFFD, ctx)); + LibmeshPetscCallQ( + MatMFFDSetFunction(jac, Moose::SlepcSupport::mooseSlepcEigenFormFunctionMFFD, ctx)); EPS eps = eigen_nl.getEPS(); @@ -1151,7 +1152,8 @@ PCApply_MoosePC(PC pc, Vec x, Vec y) PetscFunctionBegin; LibmeshPetscCallQ(PCGetOperators(pc, &Amat, &Pmat)); - LibmeshPetscCallQ(PetscObjectQuery((PetscObject)Pmat, "formFunctionCtx", (PetscObject *)&container)); + LibmeshPetscCallQ( + PetscObjectQuery((PetscObject)Pmat, "formFunctionCtx", (PetscObject *)&container)); if (container) LibmeshPetscCallQ(PetscContainerGetPointer(container, &ctx)); else @@ -1181,7 +1183,8 @@ PCSetUp_MoosePC(PC pc) PetscFunctionBegin; LibmeshPetscCallQ(PCGetOperators(pc, &Amat, &Pmat)); - LibmeshPetscCallQ(PetscObjectQuery((PetscObject)Pmat, "formFunctionCtx", (PetscObject *)&container)); + LibmeshPetscCallQ( + PetscObjectQuery((PetscObject)Pmat, "formFunctionCtx", (PetscObject *)&container)); if (container) LibmeshPetscCallQ(PetscContainerGetPointer(container, &ctx)); else diff --git a/modules/navier_stokes/src/problems/NavierStokesProblem.C b/modules/navier_stokes/src/problems/NavierStokesProblem.C index 1abeb5355428..9fcda06d9a6c 100644 --- a/modules/navier_stokes/src/problems/NavierStokesProblem.C +++ b/modules/navier_stokes/src/problems/NavierStokesProblem.C @@ -227,10 +227,12 @@ NavierStokesProblem::setupLSCMatrices(KSP schur_ksp) if (!_L) // If this is our first time in this routine, then we create the matrix - LibmeshPetscCall(MatCreateSubMatrix(our_parent_L, velocity_is, velocity_is, MAT_INITIAL_MATRIX, &_L)); + LibmeshPetscCall( + MatCreateSubMatrix(our_parent_L, velocity_is, velocity_is, MAT_INITIAL_MATRIX, &_L)); else // Else we reuse the matrix - LibmeshPetscCall(MatCreateSubMatrix(our_parent_L, velocity_is, velocity_is, MAT_REUSE_MATRIX, &_L)); + LibmeshPetscCall( + MatCreateSubMatrix(our_parent_L, velocity_is, velocity_is, MAT_REUSE_MATRIX, &_L)); } // Get the local index set complement corresponding to the pressure dofs from the velocity dofs @@ -245,7 +247,8 @@ NavierStokesProblem::setupLSCMatrices(KSP schur_ksp) // preconditioner (no LSC), then we must have access to a pressure mass matrix mooseAssert(our_parent_Q, "This should be non-null"); // Create a sub-matrix corresponding to the pressure index set - LibmeshPetscCall(MatCreateSubMatrix(our_parent_Q, pressure_is, pressure_is, mat_initialization, &_Q_scale)); + LibmeshPetscCall(MatCreateSubMatrix( + our_parent_Q, pressure_is, pressure_is, mat_initialization, &_Q_scale)); } else if (_have_mass_matrix) // If we don't have a mass matrix and the user has requested scaling // then the diagonal of A will be used @@ -255,7 +258,8 @@ NavierStokesProblem::setupLSCMatrices(KSP schur_ksp) mooseAssert(our_parent_Q, "This should be non-null"); // We are not commuting LSC, so we are doing Elman, and the user has passed us a mass matrix // tag. In this case we are creating a velocity mass matrix, so we use the velocity index set - LibmeshPetscCall(MatCreateSubMatrix(our_parent_Q, velocity_is, velocity_is, mat_initialization, &_Q_scale)); + LibmeshPetscCall(MatCreateSubMatrix( + our_parent_Q, velocity_is, velocity_is, mat_initialization, &_Q_scale)); } }; @@ -323,7 +327,8 @@ NavierStokesProblem::setupLSCMatrices(KSP schur_ksp) mooseAssert(_Q_scale, "This should be non-null"); // Attach our scaling/mass matrix to the PETSc object. PETSc will use this during the // preconditioner application - LibmeshPetscCall(PetscObjectCompose((PetscObject)lsc_pc_pmat, "LSC_Qscale", (PetscObject)_Q_scale)); + LibmeshPetscCall( + PetscObjectCompose((PetscObject)lsc_pc_pmat, "LSC_Qscale", (PetscObject)_Q_scale)); } } diff --git a/modules/optimization/src/executioners/OptimizeSolve.C b/modules/optimization/src/executioners/OptimizeSolve.C index 092217302b35..7caa6ed4a79f 100644 --- a/modules/optimization/src/executioners/OptimizeSolve.C +++ b/modules/optimization/src/executioners/OptimizeSolve.C @@ -170,9 +170,11 @@ OptimizeSolve::taoSolve() LibmeshPetscCallQ(TaoSetObjectiveRoutine(_tao, objectiveFunctionWrapper, this)); #endif #if !PETSC_VERSION_LESS_THAN(3, 17, 0) - LibmeshPetscCallQ(TaoSetObjectiveAndGradient(_tao, NULL, objectiveAndGradientFunctionWrapper, this)); + LibmeshPetscCallQ( + TaoSetObjectiveAndGradient(_tao, NULL, objectiveAndGradientFunctionWrapper, this)); #else - LibmeshPetscCallQ(TaoSetObjectiveAndGradientRoutine(_tao, objectiveAndGradientFunctionWrapper, this)); + LibmeshPetscCallQ( + TaoSetObjectiveAndGradientRoutine(_tao, objectiveAndGradientFunctionWrapper, this)); #endif // Set matrix-free version of the Hessian function @@ -550,7 +552,8 @@ OptimizeSolve::taoALCreate() { // Create equality vector LibmeshPetscCallQ(VecCreate(_my_comm.get(), &_ce)); - LibmeshPetscCallQ(VecSetSizes(_ce, _obj_function->getNumEqCons(), _obj_function->getNumEqCons())); + LibmeshPetscCallQ( + VecSetSizes(_ce, _obj_function->getNumEqCons(), _obj_function->getNumEqCons())); LibmeshPetscCallQ(VecSetFromOptions(_ce)); LibmeshPetscCallQ(VecSetUp(_ce)); @@ -573,7 +576,8 @@ OptimizeSolve::taoALCreate() { // Create inequality vector LibmeshPetscCallQ(VecCreate(_my_comm.get(), &_ci)); - LibmeshPetscCallQ(VecSetSizes(_ci, _obj_function->getNumInEqCons(), _obj_function->getNumInEqCons())); + LibmeshPetscCallQ( + VecSetSizes(_ci, _obj_function->getNumInEqCons(), _obj_function->getNumInEqCons())); LibmeshPetscCallQ(VecSetFromOptions(_ci)); LibmeshPetscCallQ(VecSetUp(_ci)); @@ -588,7 +592,8 @@ OptimizeSolve::taoALCreate() LibmeshPetscCallQ(MatSetUp(_gradient_i)); // Set the Inequality constraints - LibmeshPetscCallQ(TaoSetInequalityConstraintsRoutine(_tao, _ci, inequalityFunctionWrapper, this)); + LibmeshPetscCallQ( + TaoSetInequalityConstraintsRoutine(_tao, _ci, inequalityFunctionWrapper, this)); // Set the Inequality constraints Jacobian LibmeshPetscCallQ(TaoSetJacobianInequalityRoutine(