From 8342f1134d53257085c0a37c2a30dc0f9db85930 Mon Sep 17 00:00:00 2001 From: Van Dung Nguyen <vandung.nguyen@ulg.ac.be> Date: Wed, 14 Mar 2012 16:26:56 +0000 Subject: [PATCH] add PETSC_COMM_WORLD as defaut in linearSystemPETSc --- Solver/linearSystemPETSc.h | 3 ++- Solver/linearSystemPETSc.hpp | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h index 49af677346..176d8c5390 100644 --- a/Solver/linearSystemPETSc.h +++ b/Solver/linearSystemPETSc.h @@ -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; } diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp index e017cf133a..49d76db930 100644 --- a/Solver/linearSystemPETSc.hpp +++ b/Solver/linearSystemPETSc.hpp @@ -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) -- GitLab