diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp index a3466d4a2f8741f4afa63c93a729b678016c002a..ebffba05199ae58bec52c7b66c5d9cdf5bc18eba 100644 --- a/Solver/linearSystemPETSc.cpp +++ b/Solver/linearSystemPETSc.cpp @@ -98,6 +98,8 @@ void linearSystemPETSc<fullMatrix<PetscScalar> >::allocate(int nbRows) } else { _try(MatSetType(_a, MATSEQBAIJ)); } + if (_parameters.count("petscPrefix")) + _try(MatAppendOptionsPrefix(_a, _parameters["petscPrefix"].c_str())); _try(MatSetFromOptions(_a)); _try(MatGetOwnershipRange(_a, &_localRowStart, &_localRowEnd)); _try(MatGetSize(_a, &_globalSize, &_localSize)); @@ -111,6 +113,8 @@ void linearSystemPETSc<fullMatrix<PetscScalar> >::allocate(int nbRows) _try(VecSetSizes(_x, nbRows * _blockSize, PETSC_DETERMINE)); // override the default options with the ones from the option // database (if any) + if (_parameters.count("petscPrefix")) + _try(VecAppendOptionsPrefix(_x, _parameters["petscPrefix"].c_str())); _try(VecSetFromOptions(_x)); _try(VecDuplicate(_x, &_b)); _isAllocated = true; diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h index 761a3c3a4fe6295ddecbd69eeb4253c79109587b..343ee7776c4108fe9b0b3456763852e89742119d 100644 --- a/Solver/linearSystemPETSc.h +++ b/Solver/linearSystemPETSc.h @@ -66,6 +66,8 @@ class linearSystemPETSc : public linearSystem<scalar> { _try(KSPSetTolerances(_ksp, 1.e-8, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT)); // override the default options with the ones from the option // database (if any) + if (linearSystemBase::_parameters.count("petscPrefix")) + _try(KSPAppendOptionsPrefix(_ksp, linearSystemBase::_parameters["petscPrefix"].c_str())); _try(KSPSetFromOptions(_ksp)); _kspAllocated = true; } @@ -124,6 +126,10 @@ class linearSystemPETSc : public linearSystem<scalar> { _try(MatSetSizes(_a, nbRows, nbRows, PETSC_DETERMINE, PETSC_DETERMINE)); // override the default options with the ones from the option // database (if any) + if (linearSystemBase::_parameters.count("petscOptions")) + _try(PetscOptionsInsertString(linearSystemBase::_parameters["petscOptions"].c_str())); + if (linearSystemBase::_parameters.count("petscPrefix")) + _try(MatAppendOptionsPrefix(_a, linearSystemBase::_parameters["petscPrefix"].c_str())); _try(MatSetFromOptions(_a)); _try(MatGetOwnershipRange(_a, &_localRowStart, &_localRowEnd)); _try(MatGetSize(_a, &_globalSize, &_localSize)); @@ -132,6 +138,8 @@ class linearSystemPETSc : public linearSystem<scalar> { _try(VecSetSizes(_x, nbRows, PETSC_DETERMINE)); // override the default options with the ones from the option // database (if any) + if (linearSystemBase::_parameters.count("petscPrefix")) + _try(VecAppendOptionsPrefix(_x, linearSystemBase::_parameters["petscPrefix"].c_str())); _try(VecSetFromOptions(_x)); _try(VecDuplicate(_x, &_b)); _isAllocated = true;