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

dg : dgSW3dLinearSystemColumn ok in parallel

parent 6c327a84
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ template class linearSystemPETSc<std::complex<double> >; ...@@ -16,7 +16,7 @@ template class linearSystemPETSc<std::complex<double> >;
void linearSystemPETScBlockDouble::_kspCreate() { void linearSystemPETScBlockDouble::_kspCreate() {
KSPCreate(PETSC_COMM_WORLD, &_ksp); KSPCreate(_sequential ? PETSC_COMM_SELF : PETSC_COMM_WORLD, &_ksp);
if (this->_parameters.count("petscPrefix")) if (this->_parameters.count("petscPrefix"))
KSPAppendOptionsPrefix(_ksp, this->_parameters["petscPrefix"].c_str()); KSPAppendOptionsPrefix(_ksp, this->_parameters["petscPrefix"].c_str());
KSPSetFromOptions(_ksp); KSPSetFromOptions(_ksp);
...@@ -112,15 +112,16 @@ void linearSystemPETScBlockDouble::getFromSolution(int row, fullMatrix<double> & ...@@ -112,15 +112,16 @@ void linearSystemPETScBlockDouble::getFromSolution(int row, fullMatrix<double> &
void linearSystemPETScBlockDouble::allocate(int nbRows) void linearSystemPETScBlockDouble::allocate(int nbRows)
{ {
MPI_Comm comm = _sequential ? PETSC_COMM_SELF: PETSC_COMM_WORLD;
if (this->_parameters.count("petscOptions")) if (this->_parameters.count("petscOptions"))
PetscOptionsInsertString(this->_parameters["petscOptions"].c_str()); PetscOptionsInsertString(this->_parameters["petscOptions"].c_str());
_blockSize = strtol (_parameters["blockSize"].c_str(), NULL, 10); _blockSize = strtol (_parameters["blockSize"].c_str(), NULL, 10);
if (_blockSize == 0) if (_blockSize == 0)
Msg::Error ("'blockSize' parameters must be set for linearSystemPETScBlock"); Msg::Error ("'blockSize' parameters must be set for linearSystemPETScBlock");
clear(); clear();
MatCreate(PETSC_COMM_WORLD, &_a); MatCreate(comm, &_a);
MatSetSizes(_a,nbRows * _blockSize, nbRows * _blockSize, PETSC_DETERMINE, PETSC_DETERMINE); MatSetSizes(_a,nbRows * _blockSize, nbRows * _blockSize, PETSC_DETERMINE, PETSC_DETERMINE);
if (Msg::GetCommSize() > 1) { if (Msg::GetCommSize() > 1 && !_sequential) {
MatSetType(_a, MATMPIBAIJ); MatSetType(_a, MATMPIBAIJ);
} else { } else {
MatSetType(_a, MATSEQBAIJ); MatSetType(_a, MATSEQBAIJ);
...@@ -136,7 +137,7 @@ void linearSystemPETScBlockDouble::allocate(int nbRows) ...@@ -136,7 +137,7 @@ void linearSystemPETScBlockDouble::allocate(int nbRows)
_localRowEnd /= _blockSize; _localRowEnd /= _blockSize;
// override the default options with the ones from the option // override the default options with the ones from the option
// database (if any) // database (if any)
VecCreate(PETSC_COMM_WORLD, &_x); VecCreate(comm, &_x);
VecSetSizes(_x, nbRows * _blockSize, PETSC_DETERMINE); VecSetSizes(_x, nbRows * _blockSize, PETSC_DETERMINE);
// override the default options with the ones from the option // override the default options with the ones from the option
// database (if any) // database (if any)
...@@ -256,11 +257,12 @@ void linearSystemPETScBlockDouble::zeroSolution() ...@@ -256,11 +257,12 @@ void linearSystemPETScBlockDouble::zeroSolution()
} }
linearSystemPETScBlockDouble::linearSystemPETScBlockDouble() linearSystemPETScBlockDouble::linearSystemPETScBlockDouble(bool sequential)
{ {
_entriesPreAllocated = false; _entriesPreAllocated = false;
_isAllocated = false; _isAllocated = false;
_kspAllocated = false; _kspAllocated = false;
_sequential = sequential;
} }
double linearSystemPETScBlockDouble::normInfRightHandSide() const double linearSystemPETScBlockDouble::normInfRightHandSide() const
......
...@@ -87,6 +87,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > { ...@@ -87,6 +87,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > {
Vec _b, _x; Vec _b, _x;
KSP _ksp; KSP _ksp;
int _blockSize, _localRowStart, _localRowEnd, _globalSize, _localSize; int _blockSize, _localRowStart, _localRowEnd, _globalSize, _localSize;
bool _sequential;
public: public:
void _kspCreate(); void _kspCreate();
virtual void addToMatrix(int row, int col, const fullMatrix<double> &val); virtual void addToMatrix(int row, int col, const fullMatrix<double> &val);
...@@ -105,7 +106,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > { ...@@ -105,7 +106,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > {
void zeroSolution(); void zeroSolution();
double normInfRightHandSide() const; double normInfRightHandSide() const;
void insertInSparsityPattern (int i, int j); void insertInSparsityPattern (int i, int j);
linearSystemPETScBlockDouble(); linearSystemPETScBlockDouble(bool sequential = false);
}; };
#else #else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment