From 87c3b27f4d572599d6f6592f51b599bacae734d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simone=20Bn=C3=A0?= <s.bn@cineca.it> Date: Fri, 12 Jun 2020 12:12:23 +0200 Subject: [PATCH] ENH: drop support for the Coeffs dictionary, already covered with the options dictionary --- src/petsc4Foam/solvers/petscSolver.C | 71 ++++------------------------ 1 file changed, 8 insertions(+), 63 deletions(-) diff --git a/src/petsc4Foam/solvers/petscSolver.C b/src/petsc4Foam/solvers/petscSolver.C index e080384..624c4d8 100644 --- a/src/petsc4Foam/solvers/petscSolver.C +++ b/src/petsc4Foam/solvers/petscSolver.C @@ -129,6 +129,7 @@ Foam::solverPerformance Foam::petscSolver::solve petscDict_.getOrDefault("verbose", false) ); + // set all petsc flags in the prefix db dictionary petscDictOptions = petscDict_.subOrEmptyDict("options"); PetscUtils::setFlags ( @@ -290,18 +291,6 @@ void Foam::petscSolver::buildKsp petscDict_.getOrDefault("verbose", false) ); - // Solver name from petsc dictionary - word solverName; - petscDict_.readIfPresent("solver", solverName); - - // Preconditioner name from petsc dictionary, or from parent - word precondName; - petscDict_.readIfPresent("preconditioner", precondName); - - // Sub-preconditioner name from petsc dictionary - word subPrecondName; - petscDict_.readIfPresent("sub_preconditioner", subPrecondName); - // Create parallel solver context KSPCreate(PETSC_COMM_WORLD, &ksp); @@ -315,52 +304,6 @@ void Foam::petscSolver::buildKsp PC pc; KSPGetPC(ksp, &pc); - if (!precondName.empty()) - { - PCSetType(pc, precondName.c_str()); - } - - if (!subPrecondName.empty()) - { - PetscUtils::setFlag - ( - prefix_ + "sub_pc_type_", - subPrecondName, - verbose - ); - PetscUtils::setFlags - ( - prefix_ + "sub_pc_" + subPrecondName + "_", - petscDict_.subOrEmptyDict(subPrecondName + "Coeffs"), - verbose - ); - PetscUtils::setFlags - ( - prefix_ + "sub_pc_factor_" , - petscDict_.subOrEmptyDict("factorCoeffs"), - verbose - ); - } - - PetscUtils::setFlags - ( - prefix_ + "pc_" + precondName + "_", - petscDict_.subOrEmptyDict(precondName + "Coeffs"), - verbose - ); - - // Set the linear solver - if (!solverName.empty()) - { - KSPSetType(ksp, solverName.c_str()); - } - PetscUtils::setFlags - ( - prefix_ + "ksp_" + solverName + "_", - petscDict_.subOrEmptyDict(solverName + "Coeffs"), - verbose - ); - // OpenFOAM relative tolerance -> tolerance_ KSPSetTolerances ( @@ -371,15 +314,19 @@ void Foam::petscSolver::buildKsp maxIter_ ); + // ksp set options from db + KSPSetFromOptions(ksp); + + KSPType ksptype; + KSPGetType(ksp, &ksptype); + const word solverName(ksptype); + // Use solution from the previous timestep if the solver is not 'preonly' if (solverName != "preonly") { KSPSetInitialGuessNonzero(ksp, PETSC_TRUE); } - // ksp set options from db - KSPSetFromOptions(ksp); - KSPSetUp(ksp); } @@ -410,8 +357,6 @@ void Foam::petscSolver::computeMatAllocation // Set the prefix for the options db (e.g. -eqn_p_) MatSetOptionsPrefix(Amat, prefix_.c_str()); - dictionary matDict = petscDict_.subOrEmptyDict("matCoeffs"); - PetscUtils::setFlags(prefix_ + "mat_", matDict); MatSetFromOptions(Amat); // On-processor non-zero entries, per row. -- GitLab