Skip to content
Snippets Groups Projects
Commit 53bc9ee2 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

linearSystemPETSc : mechanism to pass petsc options (unfinished)

parent e6b5b528
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment