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