Skip to content
Snippets Groups Projects
Commit 8342f113 authored by Van Dung Nguyen's avatar Van Dung Nguyen
Browse files

add PETSC_COMM_WORLD as defaut in linearSystemPETSc

parent 589f4a14
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@
template <class scalar>
class linearSystemPETSc : public linearSystem<scalar> {
protected:
MPI_Comm _comm;
int _blockSize; // for block Matrix
bool _isAllocated, _kspAllocated, _entriesPreAllocated;
Mat _a;
......@@ -55,7 +56,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
sparsityPattern _sparsity;
void _kspCreate();
public:
linearSystemPETSc();
linearSystemPETSc(MPI_Comm com = PETSC_COMM_WORLD);
virtual ~linearSystemPETSc();
void insertInSparsityPattern (int i, int j);
virtual bool isAllocated() const { return _isAllocated; }
......
......@@ -16,7 +16,7 @@ static void _try(int ierr)
template <class scalar>
void linearSystemPETSc<scalar>::_kspCreate()
{
_try(KSPCreate(PETSC_COMM_WORLD, &_ksp));
_try(KSPCreate(_comm, &_ksp));
PC pc;
_try(KSPGetPC(_ksp, &pc));
// set some default options
......@@ -34,8 +34,9 @@ void linearSystemPETSc<scalar>::_kspCreate()
}
template <class scalar>
linearSystemPETSc<scalar>::linearSystemPETSc()
linearSystemPETSc<scalar>::linearSystemPETSc(MPI_Comm com)
{
_comm = com;
_isAllocated = false;
_blockSize = 0;
_kspAllocated = false;
......@@ -103,7 +104,7 @@ template <class scalar>
void linearSystemPETSc<scalar>::allocate(int nbRows)
{
clear();
_try(MatCreate(PETSC_COMM_WORLD, &_a));
_try(MatCreate(_comm, &_a));
_try(MatSetSizes(_a, nbRows, nbRows, PETSC_DETERMINE, PETSC_DETERMINE));
// override the default options with the ones from the option
// database (if any)
......@@ -117,7 +118,7 @@ void linearSystemPETSc<scalar>::allocate(int nbRows)
_localSize = _localRowEnd - _localRowStart;
_try(MatGetSize(_a, &_globalSize, &nbColumns));
// preallocation option must be set after other options
_try(VecCreate(PETSC_COMM_WORLD, &_x));
_try(VecCreate(_comm, &_x));
_try(VecSetSizes(_x, nbRows, PETSC_DETERMINE));
// override the default options with the ones from the option
// database (if any)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment