Commit 1e0015b3 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files
parents 6a705e50 1ded5c55
Pipeline #606 passed with stages
in 79 minutes and 29 seconds
...@@ -1051,11 +1051,7 @@ namespace AMDiS { namespace Parallel { ...@@ -1051,11 +1051,7 @@ namespace AMDiS { namespace Parallel {
} }
KSPCreate(domainComm, &ksp_schur_primal); KSPCreate(domainComm, &ksp_schur_primal);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp_schur_primal, mat_schur_primal, mat_schur_primal);
KSPSetOperators(ksp_schur_primal, mat_schur_primal, mat_schur_primal);
#else
KSPSetOperators(ksp_schur_primal, mat_schur_primal, mat_schur_primal, SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(ksp_schur_primal, "schur_primal_"); KSPSetOptionsPrefix(ksp_schur_primal, "schur_primal_");
KSPSetType(ksp_schur_primal, KSPGMRES); KSPSetType(ksp_schur_primal, KSPGMRES);
KSPSetFromOptions(ksp_schur_primal); KSPSetFromOptions(ksp_schur_primal);
...@@ -1075,11 +1071,7 @@ namespace AMDiS { namespace Parallel { ...@@ -1075,11 +1071,7 @@ namespace AMDiS { namespace Parallel {
// === Create KSP solver object and set appropriate solver options. === // === Create KSP solver object and set appropriate solver options. ===
KSPCreate(domainComm, &ksp_schur_primal); KSPCreate(domainComm, &ksp_schur_primal);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp_schur_primal, mat_schur_primal, mat_schur_primal);
KSPSetOperators(ksp_schur_primal, mat_schur_primal, mat_schur_primal);
#else
KSPSetOperators(ksp_schur_primal, mat_schur_primal, mat_schur_primal, SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(ksp_schur_primal, "schur_primal_"); KSPSetOptionsPrefix(ksp_schur_primal, "schur_primal_");
KSPSetType(ksp_schur_primal, KSPPREONLY); KSPSetType(ksp_schur_primal, KSPPREONLY);
PC pc_schur_primal; PC pc_schur_primal;
...@@ -1365,11 +1357,7 @@ namespace AMDiS { namespace Parallel { ...@@ -1365,11 +1357,7 @@ namespace AMDiS { namespace Parallel {
} }
KSPCreate(domainComm, &ksp_feti); KSPCreate(domainComm, &ksp_feti);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp_feti, mat_feti, mat_feti);
KSPSetOperators(ksp_feti, mat_feti, mat_feti);
#else
KSPSetOperators(ksp_feti, mat_feti, mat_feti, SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(ksp_feti, "feti_"); KSPSetOptionsPrefix(ksp_feti, "feti_");
KSPSetType(ksp_feti, KSPGMRES); KSPSetType(ksp_feti, KSPGMRES);
KSPSetTolerances(ksp_feti, 0, 1e-8, 1e+3, 1000); KSPSetTolerances(ksp_feti, 0, 1e-8, 1e+3, 1000);
...@@ -1382,9 +1370,9 @@ namespace AMDiS { namespace Parallel { ...@@ -1382,9 +1370,9 @@ namespace AMDiS { namespace Parallel {
Parameters::get(name + "->feti->monitor", monitor); Parameters::get(name + "->feti->monitor", monitor);
if (monitor) { if (monitor) {
if (stokesMode) if (stokesMode)
KSPMonitorSet(ksp_feti, PETSC_MONITOR_CAST(KSPMonitorFetiStokes), &fetiKspData, PETSC_NULL); petsc::ksp_monitor_set(ksp_feti, KSPMonitorFetiStokes);
else else
KSPMonitorSet(ksp_feti, PETSC_MONITOR_CAST(KSPMonitorTrueResidualNorm), PETSC_NULL, PETSC_NULL); petsc::ksp_monitor_set(ksp_feti, KSPMonitorTrueResidualNorm);
} }
...@@ -1443,11 +1431,7 @@ namespace AMDiS { namespace Parallel { ...@@ -1443,11 +1431,7 @@ namespace AMDiS { namespace Parallel {
(void(*)(void))petscMultMatFetiInexact); (void(*)(void))petscMultMatFetiInexact);
KSPCreate(domainComm, &ksp_feti); KSPCreate(domainComm, &ksp_feti);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp_feti, mat_feti, mat_feti);
KSPSetOperators(ksp_feti, mat_feti, mat_feti);
#else
KSPSetOperators(ksp_feti, mat_feti, mat_feti, SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(ksp_feti, "feti_"); KSPSetOptionsPrefix(ksp_feti, "feti_");
KSPSetType(ksp_feti, KSPGMRES); KSPSetType(ksp_feti, KSPGMRES);
KSPSetTolerances(ksp_feti, 0, 1e-8, 1e+3, 1000); KSPSetTolerances(ksp_feti, 0, 1e-8, 1e+3, 1000);
...@@ -1464,11 +1448,7 @@ namespace AMDiS { namespace Parallel { ...@@ -1464,11 +1448,7 @@ namespace AMDiS { namespace Parallel {
createVec(localDofMap, fetiInexactPreconData.tmp_vec_b0); createVec(localDofMap, fetiInexactPreconData.tmp_vec_b0);
KSPCreate(domainComm, &(fetiInexactPreconData.ksp_pc_feti)); KSPCreate(domainComm, &(fetiInexactPreconData.ksp_pc_feti));
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(fetiInexactPreconData.ksp_pc_feti, mat_lagrange, mat_lagrange);
KSPSetOperators(fetiInexactPreconData.ksp_pc_feti, mat_lagrange, mat_lagrange);
#else
KSPSetOperators(fetiInexactPreconData.ksp_pc_feti, mat_lagrange, mat_lagrange, SAME_NONZERO_PATTERN);
#endif
KSPGetPC(fetiInexactPreconData.ksp_pc_feti, KSPGetPC(fetiInexactPreconData.ksp_pc_feti,
&(fetiInexactPreconData.pc_feti)); &(fetiInexactPreconData.pc_feti));
createFetiPreconLumped(fetiInexactPreconData.pc_feti); createFetiPreconLumped(fetiInexactPreconData.pc_feti);
...@@ -1505,17 +1485,11 @@ namespace AMDiS { namespace Parallel { ...@@ -1505,17 +1485,11 @@ namespace AMDiS { namespace Parallel {
VecCreateMPI(meshDistributor->getMeshLevelData().getMpiComm(meshLevel), VecCreateMPI(meshDistributor->getMeshLevelData().getMpiComm(meshLevel),
localDofMap.getRankDofs(), localDofMap.getRankDofs(),
nGlobalOverallInterior, &(lumpedData->tmp_vec_b0)); nGlobalOverallInterior, &(lumpedData->tmp_vec_b0));
#if (PETSC_VERSION_MINOR >= 6)
MatCreateVecs(mat_duals_duals, PETSC_NULL, petsc::mat_create_vecs(mat_duals_duals, PETSC_NULL,
&(lumpedData->tmp_vec_duals0)); &(lumpedData->tmp_vec_duals0));
MatCreateVecs(mat_duals_duals, PETSC_NULL, petsc::mat_create_vecs(mat_duals_duals, PETSC_NULL,
&(lumpedData->tmp_vec_duals1)); &(lumpedData->tmp_vec_duals1));
#else
MatGetVecs(mat_duals_duals, PETSC_NULL,
&(lumpedData->tmp_vec_duals0));
MatGetVecs(mat_duals_duals, PETSC_NULL,
&(lumpedData->tmp_vec_duals1));
#endif
for (int component = 0; component < static_cast<int>(componentSpaces.size()); for (int component = 0; component < static_cast<int>(componentSpaces.size());
component++) { component++) {
...@@ -1607,11 +1581,7 @@ namespace AMDiS { namespace Parallel { ...@@ -1607,11 +1581,7 @@ namespace AMDiS { namespace Parallel {
("Stokes mode does not yet support the Dirichlet precondition!\n"); ("Stokes mode does not yet support the Dirichlet precondition!\n");
KSPCreate(PETSC_COMM_SELF, &ksp_interior); KSPCreate(PETSC_COMM_SELF, &ksp_interior);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp_interior, mat_interior_interior, mat_interior_interior);
KSPSetOperators(ksp_interior, mat_interior_interior, mat_interior_interior);
#else
KSPSetOperators(ksp_interior, mat_interior_interior, mat_interior_interior, SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(ksp_interior, "precon_interior_"); KSPSetOptionsPrefix(ksp_interior, "precon_interior_");
KSPSetType(ksp_interior, KSPPREONLY); KSPSetType(ksp_interior, KSPPREONLY);
PC pc_interior; PC pc_interior;
...@@ -1635,21 +1605,13 @@ namespace AMDiS { namespace Parallel { ...@@ -1635,21 +1605,13 @@ namespace AMDiS { namespace Parallel {
VecCreateMPI(meshDistributor->getMeshLevelData().getMpiComm(meshLevel), VecCreateMPI(meshDistributor->getMeshLevelData().getMpiComm(meshLevel),
localDofMap.getRankDofs(), localDofMap.getRankDofs(),
nGlobalOverallInterior, &(fetiDirichletPreconData.tmp_vec_b)); nGlobalOverallInterior, &(fetiDirichletPreconData.tmp_vec_b));
#if (PETSC_VERSION_MINOR >= 6)
MatCreateVecs(mat_duals_duals, PETSC_NULL, petsc::mat_create_vecs(mat_duals_duals, PETSC_NULL,
&(fetiDirichletPreconData.tmp_vec_duals0));
MatCreateVecs(mat_duals_duals, PETSC_NULL,
&(fetiDirichletPreconData.tmp_vec_duals1));
MatCreateVecs(mat_interior_interior, PETSC_NULL,
&(fetiDirichletPreconData.tmp_vec_interior));
#else
MatGetVecs(mat_duals_duals, PETSC_NULL,
&(fetiDirichletPreconData.tmp_vec_duals0)); &(fetiDirichletPreconData.tmp_vec_duals0));
MatGetVecs(mat_duals_duals, PETSC_NULL, petsc::mat_create_vecs(mat_duals_duals, PETSC_NULL,
&(fetiDirichletPreconData.tmp_vec_duals1)); &(fetiDirichletPreconData.tmp_vec_duals1));
MatGetVecs(mat_interior_interior, PETSC_NULL, petsc::mat_create_vecs(mat_interior_interior, PETSC_NULL,
&(fetiDirichletPreconData.tmp_vec_interior)); &(fetiDirichletPreconData.tmp_vec_interior));
#endif
TEST_EXIT_DBG(subDomainIsLocal) TEST_EXIT_DBG(subDomainIsLocal)
("Should not happen, check usage of localDofMap!\n"); ("Should not happen, check usage of localDofMap!\n");
...@@ -2509,13 +2471,8 @@ namespace AMDiS { namespace Parallel { ...@@ -2509,13 +2471,8 @@ namespace AMDiS { namespace Parallel {
Vec vecRhs, vecSol; Vec vecRhs, vecSol;
Vec vecRhsLagrange, vecSolLagrange; Vec vecRhsLagrange, vecSolLagrange;
#if (PETSC_VERSION_MINOR >= 6) petsc::mat_create_vecs(mat_lagrange, PETSC_NULL, &vecRhsLagrange);
MatCreateVecs(mat_lagrange, PETSC_NULL, &vecRhsLagrange); petsc::mat_create_vecs(mat_lagrange, PETSC_NULL, &vecSolLagrange);
MatCreateVecs(mat_lagrange, PETSC_NULL, &vecSolLagrange);
#else
MatGetVecs(mat_lagrange, PETSC_NULL, &vecRhsLagrange);
MatGetVecs(mat_lagrange, PETSC_NULL, &vecSolLagrange);
#endif
vecRhs = vecRhsLagrange; vecRhs = vecRhsLagrange;
vecSol = vecSolLagrange; vecSol = vecSolLagrange;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "parallel/PetscSolverGlobalBlockMatrix.h" #include "parallel/PetscSolverGlobalBlockMatrix.h"
#include "parallel/PetscHelper.h"
#include "parallel/StdMpi.h" #include "parallel/StdMpi.h"
#include "parallel/MpiHelper.h" #include "parallel/MpiHelper.h"
...@@ -150,11 +151,7 @@ namespace AMDiS { namespace Parallel { ...@@ -150,11 +151,7 @@ namespace AMDiS { namespace Parallel {
FUNCNAME("PetscSolverGlobalBlockMatrix::initSolver()"); FUNCNAME("PetscSolverGlobalBlockMatrix::initSolver()");
KSPCreate(domainComm, &ksp); KSPCreate(domainComm, &ksp);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp, getMatInterior(), getMatInterior());
KSPSetOperators(ksp, getMatInterior(), getMatInterior());
#else
KSPSetOperators(ksp, getMatInterior(), getMatInterior(), SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(ksp, kspPrefix.c_str()); KSPSetOptionsPrefix(ksp, kspPrefix.c_str());
KSPSetFromOptions(ksp); KSPSetFromOptions(ksp);
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
// #include "DirichletBC.h" // #include "DirichletBC.h"
#include "DOFVector.h" #include "DOFVector.h"
#include "parallel/PetscSolverGlobalMatrix.h" #include "parallel/PetscSolverGlobalMatrix.h"
#include "parallel/PetscHelper.h"
#include "parallel/StdMpi.h" #include "parallel/StdMpi.h"
#include "parallel/MpiHelper.h" #include "parallel/MpiHelper.h"
#include "solver/PetscTypes.h" #include "solver/PetscTypes.h"
...@@ -50,15 +51,15 @@ namespace AMDiS { namespace Parallel { ...@@ -50,15 +51,15 @@ namespace AMDiS { namespace Parallel {
if (params.matSolverPackage.find(kspSolver) != params.matSolverPackage.end()) { if (params.matSolverPackage.find(kspSolver) != params.matSolverPackage.end()) {
// direct solvers // direct solvers
petsc_options_insert_string(("-" + kspPrefix + "ksp_type preonly").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_type lu").c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_factor_mat_solver_package " + kspSolver).c_str()); petsc::options_insert_string(("-" + kspPrefix + "pc_factor_mat_solver_package " + kspSolver).c_str());
setMaxIterations(1); setMaxIterations(1);
zeroStartVector = true; zeroStartVector = true;
matSolverPackage = true; matSolverPackage = true;
} else if (params.emptyParam.find(kspSolver) == params.emptyParam.end() && solverName != "petsc") { } else if (params.emptyParam.find(kspSolver) == params.emptyParam.end() && solverName != "petsc") {
// other solvers // other solvers
petsc_options_insert_string(("-" + kspPrefix + "ksp_type " + kspSolver).c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_type " + kspSolver).c_str());
} }
// set the preconditioner // set the preconditioner
...@@ -70,17 +71,17 @@ namespace AMDiS { namespace Parallel { ...@@ -70,17 +71,17 @@ namespace AMDiS { namespace Parallel {
Parameters::get(name + "->right precon", precon); Parameters::get(name + "->right precon", precon);
if (!matSolverPackage && params.emptyParam.find(precon) == params.emptyParam.end()) { if (!matSolverPackage && params.emptyParam.find(precon) == params.emptyParam.end()) {
precon = (params.preconMap.find(precon) != params.preconMap.end() ? params.preconMap[precon] : precon); precon = (params.preconMap.find(precon) != params.preconMap.end() ? params.preconMap[precon] : precon);
petsc_options_insert_string(("-" + kspPrefix + "pc_type " + precon).c_str()); petsc::options_insert_string(("-" + kspPrefix + "pc_type " + precon).c_str());
} }
petsc_options_insert_string(("-" + kspPrefix + "ksp_max_it " + boost::lexical_cast<std::string>(getMaxIterations())).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_rtol " + boost::lexical_cast<std::string>(getRelative())).c_str());
petsc_options_insert_string(("-" + kspPrefix + "ksp_atol " + boost::lexical_cast<std::string>(getTolerance())).c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_atol " + boost::lexical_cast<std::string>(getTolerance())).c_str());
if (getInfo() >= 20) if (getInfo() >= 20)
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor_true_residual").c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_monitor_true_residual").c_str());
else if (getInfo() >= 10) else if (getInfo() >= 10)
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor").c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_monitor").c_str());
} }
if (!matSolverPackage) { if (!matSolverPackage) {
Parameters::get(name + "->use zero start vector", zeroStartVector); Parameters::get(name + "->use zero start vector", zeroStartVector);
...@@ -95,11 +96,7 @@ namespace AMDiS { namespace Parallel { ...@@ -95,11 +96,7 @@ namespace AMDiS { namespace Parallel {
PetscViewer viewer; PetscViewer viewer;
PetscViewerCreate(PETSC_COMM_WORLD, &viewer); PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
PetscViewerSetType(viewer, PETSCVIEWERASCII); PetscViewerSetType(viewer, PETSCVIEWERASCII);
#if (PETSC_VERSION_MINOR >= 7) petsc::options_view(viewer);
PetscOptionsView(PETSC_NULL, viewer);
#else
PetscOptionsView(viewer);
#endif
PetscViewerDestroy(&viewer); PetscViewerDestroy(&viewer);
} }
...@@ -333,11 +330,7 @@ namespace AMDiS { namespace Parallel { ...@@ -333,11 +330,7 @@ namespace AMDiS { namespace Parallel {
// === Create solver for the non primal (thus local) variables. === // === Create solver for the non primal (thus local) variables. ===
KSPCreate(domainComm, &kspInterior); KSPCreate(domainComm, &kspInterior);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(kspInterior, getMatInterior(), getMatInterior());
KSPSetOperators(kspInterior, getMatInterior(), getMatInterior());
#else
KSPSetOperators(kspInterior, getMatInterior(), getMatInterior(), SAME_NONZERO_PATTERN);
#endif
KSPSetOptionsPrefix(kspInterior, "interior_"); KSPSetOptionsPrefix(kspInterior, "interior_");
KSPSetType(kspInterior, KSPPREONLY); KSPSetType(kspInterior, KSPPREONLY);
KSPGetPC(kspInterior, &pcInterior); KSPGetPC(kspInterior, &pcInterior);
...@@ -460,11 +453,7 @@ namespace AMDiS { namespace Parallel { ...@@ -460,11 +453,7 @@ namespace AMDiS { namespace Parallel {
TEST_EXIT_DBG(coarseSpaceMap.empty())("Not supported!\n"); TEST_EXIT_DBG(coarseSpaceMap.empty())("Not supported!\n");
MSG("Remove nullspace from rhs vector.\n"); MSG("Remove nullspace from rhs vector.\n");
#if (PETSC_VERSION_MINOR >= 5) petsc::mat_nullspace_remove(matNullspace, getVecRhsInterior());
MatNullSpaceRemove(matNullspace, getVecRhsInterior());
#else
MatNullSpaceRemove(matNullspace, getVecRhsInterior(), PETSC_NULL);
#endif
} }
} else { } else {
TEST_EXIT(removeRhsNullspace == false) TEST_EXIT(removeRhsNullspace == false)
...@@ -617,11 +606,7 @@ namespace AMDiS { namespace Parallel { ...@@ -617,11 +606,7 @@ namespace AMDiS { namespace Parallel {
void PetscSolverGlobalMatrix::initSolver(KSP &ksp) void PetscSolverGlobalMatrix::initSolver(KSP &ksp)
{ {
KSPCreate(domainComm, &ksp); KSPCreate(domainComm, &ksp);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp, getMatInterior(), getMatInterior());
KSPSetOperators(ksp, getMatInterior(), getMatInterior());
#else
KSPSetOperators(ksp, getMatInterior(), getMatInterior(), SAME_NONZERO_PATTERN);
#endif
KSPSetTolerances(ksp, 0.0, 1e-8, PETSC_DEFAULT, PETSC_DEFAULT); KSPSetTolerances(ksp, 0.0, 1e-8, PETSC_DEFAULT, PETSC_DEFAULT);
KSPSetType(ksp, KSPBCGS); KSPSetType(ksp, KSPBCGS);
KSPSetOptionsPrefix(ksp, kspPrefix.c_str()); KSPSetOptionsPrefix(ksp, kspPrefix.c_str());
...@@ -897,11 +882,7 @@ namespace AMDiS { namespace Parallel { ...@@ -897,11 +882,7 @@ namespace AMDiS { namespace Parallel {
if (test) { if (test) {
Vec tmp; Vec tmp;
#if (PETSC_VERSION_MINOR >= 6) petsc::mat_create_vecs(getMatInterior(), &tmp, PETSC_NULL);
MatCreateVecs(getMatInterior(), &tmp, PETSC_NULL);
#else
MatGetVecs(getMatInterior(), &tmp, PETSC_NULL);
#endif
MatMult(getMatInterior(), nullSpaceBasis, tmp); MatMult(getMatInterior(), nullSpaceBasis, tmp);
PetscReal n; PetscReal n;
VecNorm(tmp, NORM_2, &n); VecNorm(tmp, NORM_2, &n);
...@@ -914,11 +895,7 @@ namespace AMDiS { namespace Parallel { ...@@ -914,11 +895,7 @@ namespace AMDiS { namespace Parallel {
MatNullSpaceCreate(domainComm, PETSC_FALSE, 1, &nullSpaceBasis, &matNullSpace); MatNullSpaceCreate(domainComm, PETSC_FALSE, 1, &nullSpaceBasis, &matNullSpace);
Mat amat, pmat; Mat amat, pmat;
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_get_operators(ksp, &amat, &pmat);
KSPGetOperators(ksp, &amat, &pmat);
#else
KSPGetOperators(ksp, &amat, &pmat, PETSC_NULL);
#endif
MatSetNullSpace(amat, matNullSpace); MatSetNullSpace(amat, matNullSpace);
MatNullSpaceDestroy(&matNullSpace); MatNullSpaceDestroy(&matNullSpace);
...@@ -931,11 +908,7 @@ namespace AMDiS { namespace Parallel { ...@@ -931,11 +908,7 @@ namespace AMDiS { namespace Parallel {
MatNullSpace matNullSpace; MatNullSpace matNullSpace;
MatNullSpaceCreate(domainComm, PETSC_TRUE, 0, PETSC_NULL, &matNullSpace); MatNullSpaceCreate(domainComm, PETSC_TRUE, 0, PETSC_NULL, &matNullSpace);
Mat amat, pmat; Mat amat, pmat;
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_get_operators(ksp, &amat, &pmat);
KSPGetOperators(ksp, &amat, &pmat);
#else
KSPGetOperators(ksp, &amat, &pmat, PETSC_NULL);
#endif
MatSetNullSpace(amat, matNullSpace); MatSetNullSpace(amat, matNullSpace);
MatNullSpaceDestroy(&matNullSpace); MatNullSpaceDestroy(&matNullSpace);
} }
......
...@@ -184,12 +184,8 @@ namespace AMDiS { namespace Parallel { ...@@ -184,12 +184,8 @@ namespace AMDiS { namespace Parallel {
// Create FGMRES based outer solver // Create FGMRES based outer solver
MSG("CREATE POS 1: %p\n", &ksp); MSG("CREATE POS 1: %p\n", &ksp);
KSPCreate(domainComm, &ksp); KSPCreate(domainComm, &ksp);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp, getMatInterior(), getMatInterior());
KSPSetOperators(ksp, getMatInterior(), getMatInterior()); petsc::ksp_monitor_set(ksp, KSPMonitorTrueResidualNorm);
#else
KSPSetOperators(ksp, getMatInterior(), getMatInterior(), SAME_NONZERO_PATTERN);
#endif
KSPMonitorSet(ksp, PETSC_MONITOR_CAST(KSPMonitorTrueResidualNorm), PETSC_NULL, PETSC_NULL);
petsc_helper::setSolver(ksp, "ch_", KSPFGMRES, PCSHELL, getRelative(), getTolerance(), getMaxIterations()); petsc_helper::setSolver(ksp, "ch_", KSPFGMRES, PCSHELL, getRelative(), getTolerance(), getMaxIterations());
setConstantNullSpace(ksp, componentSpaces[0]->getMesh()->getDim() , true); setConstantNullSpace(ksp, componentSpaces[0]->getMesh()->getDim() , true);
} }
...@@ -337,12 +333,7 @@ namespace AMDiS { namespace Parallel { ...@@ -337,12 +333,7 @@ namespace AMDiS { namespace Parallel {
///erstelle kspVelocity ///erstelle kspVelocity
KSPCreate((meshDistributor->getMpiComm(0)), &(matShellContext.kspVelocity)); KSPCreate((meshDistributor->getMpiComm(0)), &(matShellContext.kspVelocity));
petsc::ksp_set_operators(matShellContext.kspVelocity, matShellContext.velocityMat, matShellContext.velocityMat);
#if (PETSC_VERSION_MINOR >= 5)
KSPSetOperators(matShellContext.kspVelocity, matShellContext.velocityMat, matShellContext.velocityMat);
#else
KSPSetOperators(matShellContext.kspVelocity, matShellContext.velocityMat, matShellContext.velocityMat, SAME_NONZERO_PATTERN);
#endif
///regularisiere LaplaceMatrix ///regularisiere LaplaceMatrix
if (regularizeLaplace) if (regularizeLaplace)
...@@ -351,11 +342,7 @@ namespace AMDiS { namespace Parallel { ...@@ -351,11 +342,7 @@ namespace AMDiS { namespace Parallel {
rows[0]=0; rows[0]=0;
MatZeroRows(laplaceMatrixSolver->getMatInterior(), 1, rows, 0, PETSC_NULL, PETSC_NULL); MatZeroRows(laplaceMatrixSolver->getMatInterior(), 1, rows, 0, PETSC_NULL, PETSC_NULL);
KSPCreate((meshDistributor->getMpiComm(0)), &(matShellContext.kspLaplace)); KSPCreate((meshDistributor->getMpiComm(0)), &(matShellContext.kspLaplace));
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(matShellContext.kspLaplace, laplaceMatrixSolver->getMatInterior(), laplaceMatrixSolver->getMatInterior());
KSPSetOperators(matShellContext.kspLaplace, laplaceMatrixSolver->getMatInterior(), laplaceMatrixSolver->getMatInterior());
#else
KSPSetOperators(matShellContext.kspLaplace, laplaceMatrixSolver->getMatInterior(), laplaceMatrixSolver->getMatInterior(), SAME_NONZERO_PATTERN);
#endif
} }
else else
{ matShellContext.kspLaplace=laplaceMatrixSolver->getSolver(); { matShellContext.kspLaplace=laplaceMatrixSolver->getSolver();
......
...@@ -117,15 +117,11 @@ namespace AMDiS { namespace Parallel { ...@@ -117,15 +117,11 @@ namespace AMDiS { namespace Parallel {
MSG("CREATE POS 1: %p\n", &ksp); MSG("CREATE POS 1: %p\n", &ksp);
KSPCreate(domainComm, &ksp); KSPCreate(domainComm, &ksp);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(ksp, getMatInterior(), getMatInterior());
KSPSetOperators(ksp, getMatInterior(), getMatInterior());
#else
KSPSetOperators(ksp, getMatInterior(), getMatInterior(), SAME_NONZERO_PATTERN);
#endif
if (getInfo() >= 10) if (getInfo() >= 10)
KSPMonitorSet(ksp, PETSC_MONITOR_CAST(KSPMonitorDefault), PETSC_NULL, PETSC_NULL); petsc::ksp_monitor_set(ksp, KSPMonitorDefault);
else if (getInfo() >= 20) else if (getInfo() >= 20)
KSPMonitorSet(ksp, PETSC_MONITOR_CAST(KSPMonitorTrueResidualNorm), PETSC_NULL, PETSC_NULL); petsc::ksp_monitor_set(ksp, KSPMonitorTrueResidualNorm);
petsc_helper::setSolver(ksp, "ns_", KSPFGMRES, PCNONE, getRelative(), getTolerance(), getMaxIterations()); petsc_helper::setSolver(ksp, "ns_", KSPFGMRES, PCNONE, getRelative(), getTolerance(), getMaxIterations());
// Create null space information. // Create null space information.
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "parallel/PetscSolverSchur.h" #include "parallel/PetscSolverSchur.h"
#include "parallel/PetscHelper.h"
#include "parallel/StdMpi.h" #include "parallel/StdMpi.h"
#include "parallel/MpiHelper.h" #include "parallel/MpiHelper.h"
...@@ -293,11 +294,7 @@ namespace AMDiS { namespace Parallel { ...@@ -293,11 +294,7 @@ namespace AMDiS { namespace Parallel {
KSPCreate(domainComm, &kspInterior); KSPCreate(domainComm, &kspInterior);
#if (PETSC_VERSION_MINOR >= 5) petsc::ksp_set_operators(kspInterior, getMatInterior(), getMatInterior());
KSPSetOperators(kspInterior, getMatInterior(), getMatInterior());
#else
KSPSetOperators(kspInterior, getMatInterior(), getMatInterior(), SAME_NONZERO_PATTERN);
#endif
KSPSetTolerances(kspInterior, 0.0, 1e-8, PETSC_DEFAULT, PETSC_DEFAULT); KSPSetTolerances(kspInterior, 0.0, 1e-8, PETSC_DEFAULT, PETSC_DEFAULT);
KSPSetFromOptions(kspInterior); KSPSetFromOptions(kspInterior);
......
...@@ -47,30 +47,30 @@ namespace AMDiS { ...@@ -47,30 +47,30 @@ namespace AMDiS {
if (params.matSolverPackage[kspSolver]) { if (params.matSolverPackage[kspSolver]) {
// direct solvers // direct solvers
petsc_options_insert_string(("-" + kspPrefix + "ksp_type preonly").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_type lu").c_str());
petsc_options_insert_string(("-" + kspPrefix + "pc_factor_mat_solver_package " + (kspSolver != "direct" ? kspSolver : "umfpack")).c_str()); petsc::options_insert_string(("-" + kspPrefix + "pc_factor_mat_solver_package " + (kspSolver != "direct" ? kspSolver : "umfpack")).c_str());
oem.setMaxIterations(1); oem.setMaxIterations(1);
zeroStartVector = true; zeroStartVector = true;
matSolverPackage = true; matSolverPackage = true;
} else if (!params.emptyParam[kspSolver]) { } else if (!params.emptyParam[kspSolver]) {
// other solvers // other solvers
petsc_options_insert_string(("-" + kspPrefix + "ksp_type " + kspSolver).c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_type " + kspSolver).c_str());
} }
// set the preconditioner // set the preconditioner
setPrecon(); setPrecon();
if (oem.getInfo() >= 20) if (oem.getInfo() >= 20)
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor_true_residual").c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_monitor_true_residual").c_str());
else if (oem.getInfo() >= 10) else if (oem.getInfo() >= 10)
petsc_options_insert_string(("-" + kspPrefix + "ksp_monitor").c_str()); petsc::options_insert_string(("-" + kspPrefix + "ksp_monitor").c_str());
// command line string // command line string
std::string kspString = ""; std::string kspString = "";
Parameters::get(oem.getName() + "->ksp", kspString); Parameters::get(oem.getName() + "->ksp", kspString);
if (kspString != "")