Skip to content
Snippets Groups Projects
Commit 85a4bb90 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

ifdef HAVE_MPI to remove warnings

parent 45fb0c09
No related branches found
No related tags found
No related merge requests found
#ifdef HAVE_PETSC #if defined(HAVE_PETSC)
#include <petsc.h> #include <petsc.h>
#include <petscksp.h> #include <petscksp.h>
#include "linearSystemPETSc.h" #include "linearSystemPETSc.h"
static void _try(int ierr) static void _try(int ierr)
{ {
CHKERRABORT(PETSC_COMM_WORLD, ierr); CHKERRABORT(PETSC_COMM_WORLD, ierr);
...@@ -79,6 +79,7 @@ linearSystemPETSc<scalar>::~linearSystemPETSc() ...@@ -79,6 +79,7 @@ linearSystemPETSc<scalar>::~linearSystemPETSc()
template <class scalar> template <class scalar>
void linearSystemPETSc<scalar>::_assembleMatrixIfNeeded() void linearSystemPETSc<scalar>::_assembleMatrixIfNeeded()
{ {
#if defined(HAVE_MPI)
if (_comm == PETSC_COMM_WORLD){ if (_comm == PETSC_COMM_WORLD){
if (Msg::GetCommSize() > 1){ if (Msg::GetCommSize() > 1){
int value = _valuesNotAssembled ? 1 : 0; int value = _valuesNotAssembled ? 1 : 0;
...@@ -89,7 +90,7 @@ void linearSystemPETSc<scalar>::_assembleMatrixIfNeeded() ...@@ -89,7 +90,7 @@ void linearSystemPETSc<scalar>::_assembleMatrixIfNeeded()
} }
} }
} }
#endif
if (_valuesNotAssembled) { if (_valuesNotAssembled) {
_try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
_try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY));
...@@ -179,7 +180,7 @@ void linearSystemPETSc<scalar>::allocate(int nbRows) ...@@ -179,7 +180,7 @@ void linearSystemPETSc<scalar>::allocate(int nbRows)
_try(MatSetFromOptions(_a)); _try(MatSetFromOptions(_a));
//since PETSc 3.3 GetOwnershipRange and MatGetSize cannot be called before MatXXXSetPreallocation //since PETSc 3.3 GetOwnershipRange and MatGetSize cannot be called before MatXXXSetPreallocation
_localSize = nbRows; _localSize = nbRows;
#ifdef HAVE_MPI #if defined(HAVE_MPI)
if (commSize > 1){ if (commSize > 1){
_localRowStart = 0; _localRowStart = 0;
if (Msg::GetCommRank() != 0) { if (Msg::GetCommRank() != 0) {
...@@ -327,6 +328,7 @@ void linearSystemPETSc<scalar>::getFromSolution(int row, scalar &val) const ...@@ -327,6 +328,7 @@ void linearSystemPETSc<scalar>::getFromSolution(int row, scalar &val) const
template <class scalar> template <class scalar>
void linearSystemPETSc<scalar>::zeroMatrix() void linearSystemPETSc<scalar>::zeroMatrix()
{ {
#if defined(HAVE_MPI)
if (_comm == PETSC_COMM_WORLD){ if (_comm == PETSC_COMM_WORLD){
if (Msg::GetCommSize() > 1){ if (Msg::GetCommSize() > 1){
int value = _entriesPreAllocated ? 1 : 0; int value = _entriesPreAllocated ? 1 : 0;
...@@ -337,6 +339,7 @@ void linearSystemPETSc<scalar>::zeroMatrix() ...@@ -337,6 +339,7 @@ void linearSystemPETSc<scalar>::zeroMatrix()
} }
} }
} }
#endif
if (_isAllocated && _entriesPreAllocated) { if (_isAllocated && _entriesPreAllocated) {
_assembleMatrixIfNeeded(); _assembleMatrixIfNeeded();
_try(MatZeroEntries(_a)); _try(MatZeroEntries(_a));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment