Skip to content

Commit

Permalink
Apply clang format style changes (idaholab#28929)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmnobre committed Oct 24, 2024
1 parent 9868bf1 commit 1773e9d
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 34 deletions.
6 changes: 4 additions & 2 deletions framework/src/outputs/PetscOutput.C
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions framework/src/partitioner/PetscExternalPartitioner.C
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
17 changes: 10 additions & 7 deletions framework/src/systems/NonlinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,23 @@ 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,
(PetscErrorCode(*)(void))(void (*)(void)) &
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));
}
Expand Down
19 changes: 12 additions & 7 deletions framework/src/utils/PetscDMMoose.C
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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))
{
Expand All @@ -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"));
}
Expand All @@ -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"));
}
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 7 additions & 3 deletions framework/src/utils/PetscSupport.C
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())));
}
}

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions framework/src/utils/SlepcSupport.C
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions modules/navier_stokes/src/problems/NavierStokesProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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));
}
};

Expand Down Expand Up @@ -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));
}
}

Expand Down
15 changes: 10 additions & 5 deletions modules/optimization/src/executioners/OptimizeSolve.C
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));

Expand All @@ -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));

Expand All @@ -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(
Expand Down

0 comments on commit 1773e9d

Please sign in to comment.