Commit 24b520f6 authored by Praetorius, Simon's avatar Praetorius, Simon

added implementation for PetscOptionsInsertString with switch on PETSC_VERSION

parent a72ec8f7
......@@ -49,7 +49,7 @@ namespace AMDiS { namespace Parallel {
Parameters::get(name + "->ksp", kspStr);
if (kspStr != "")
PetscOptionsInsertString(kspStr.c_str());
petsc_options_insert_string(kspStr.c_str());
Parameters::get(name + "->remove rhs null space", removeRhsNullspace);
Parameters::get(name + "->has constant null space", hasConstantNullspace);
......
......@@ -50,15 +50,15 @@ namespace AMDiS { namespace Parallel {
if (params.matSolverPackage.find(kspSolver) != params.matSolverPackage.end()) {
// direct solvers
PetscOptionsInsertString(("-" + kspPrefix + "ksp_type preonly").c_str());
PetscOptionsInsertString(("-" + kspPrefix + "pc_type lu").c_str());
PetscOptionsInsertString(("-" + kspPrefix + "pc_factor_mat_solver_package " + kspSolver).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_type preonly").c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_type lu").c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_factor_mat_solver_package " + kspSolver).c_str());
setMaxIterations(1);
zeroStartVector = true;
matSolverPackage = true;
} else if (params.emptyParam.find(kspSolver) == params.emptyParam.end() && solverName != "petsc") {
// other solvers
PetscOptionsInsertString(("-" + kspPrefix + "ksp_type " + kspSolver).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_type " + kspSolver).c_str());
}
// set the preconditioner
......@@ -70,17 +70,17 @@ namespace AMDiS { namespace Parallel {
Parameters::get(name + "->right precon", precon);
if (!matSolverPackage && params.emptyParam.find(precon) == params.emptyParam.end()) {
precon = (params.preconMap.find(precon) != params.preconMap.end() ? params.preconMap[precon] : precon);
PetscOptionsInsertString(("-" + kspPrefix + "pc_type " + precon).c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_type " + precon).c_str());
}
PetscOptionsInsertString(("-" + kspPrefix + "ksp_max_it " + boost::lexical_cast<std::string>(getMaxIterations())).c_str());
PetscOptionsInsertString(("-" + kspPrefix + "ksp_rtol " + boost::lexical_cast<std::string>(getRelative())).c_str());
PetscOptionsInsertString(("-" + kspPrefix + "ksp_atol " + boost::lexical_cast<std::string>(getTolerance())).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_max_it " + boost::lexical_cast<std::string>(getMaxIterations())).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_rtol " + boost::lexical_cast<std::string>(getRelative())).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_atol " + boost::lexical_cast<std::string>(getTolerance())).c_str());
if (getInfo() >= 20)
PetscOptionsInsertString(("-" + kspPrefix + "ksp_monitor_true_residual").c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor_true_residual").c_str());
else if (getInfo() >= 10)
PetscOptionsInsertString(("-" + kspPrefix + "ksp_monitor").c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor").c_str());
}
if (!matSolverPackage) {
Parameters::get(name + "->use zero start vector", zeroStartVector);
......
......@@ -58,7 +58,7 @@ namespace AMDiS {
virtual void init(PC pc, const SolverMatrix<Matrix<DOFMatrix*> >& A, const MatrixType& fullMatrix)
{
PetscOptionsInsertString(("-" + prefix + "pc_type " + name).c_str());
petsc_options_insert_string(("-" + prefix + "pc_type " + name).c_str());
PCSetFromOptions(pc);
}
......
......@@ -47,30 +47,30 @@ namespace AMDiS {
if (params.matSolverPackage[kspSolver]) {
// direct solvers
PetscOptionsInsertString(("-" + kspPrefix + "ksp_type preonly").c_str());
PetscOptionsInsertString(("-" + kspPrefix + "pc_type lu").c_str());
PetscOptionsInsertString(("-" + kspPrefix + "pc_factor_mat_solver_package " + (kspSolver != "direct" ? kspSolver : "umfpack")).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_type preonly").c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_type lu").c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_factor_mat_solver_package " + (kspSolver != "direct" ? kspSolver : "umfpack")).c_str());
oem.setMaxIterations(1);
zeroStartVector = true;
matSolverPackage = true;
} else if (!params.emptyParam[kspSolver]) {
// other solvers
PetscOptionsInsertString(("-" + kspPrefix + "ksp_type " + kspSolver).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_type " + kspSolver).c_str());
}
// set the preconditioner
setPrecon();
if (oem.getInfo() >= 20)
PetscOptionsInsertString(("-" + kspPrefix + "ksp_monitor_true_residual").c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor_true_residual").c_str());
else if (oem.getInfo() >= 10)
PetscOptionsInsertString(("-" + kspPrefix + "ksp_monitor").c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor").c_str());
// command line string
std::string kspString = "";
Parameters::get(oem.getName() + "->ksp", kspString);
if (kspString != "")
PetscOptionsInsertString(kspString.c_str());
petsc_options_insert_string(kspString.c_str());
}
......
......@@ -31,6 +31,7 @@
#include <petsc.h>
#include <petscmat.h>
#include <petscvec.h>
#include <options.h>
namespace AMDiS {
......@@ -143,6 +144,17 @@ namespace AMDiS {
template< typename Mapper >
void operator>>(const PetscVectorNested& dest, VecMap<SystemVector, Mapper>& rhs);
PetscErrorCode petsc_options_insert_string(const char in_str[])
{
#if (PETSC_VERSION_MINOR >= 7)
return PetscOptionsInsertString(NULL, in_str);
#else
return PetscOptionsInsertString(in_str);
#endif
}
} // end namespace AMDiS
#include "solver/PetscTypes.hh"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment