#include #include #include #include "petscMatrix.h" using std::cout; using std::endl; using std::runtime_error; petscMatrix::petscMatrix() { ; } petscMatrix::petscMatrix(PetscInt rowSz, PetscInt colSz, char t) throw(runtime_error) { try{ switch(t) { case('d'): // dense matType = t; m = rowSz; n = colSz; case('D'): // dense matType = t; m = rowSz; n = colSz; case('s'): //sparse matType = t; m = rowSz; n = colSz; A = 0; MatCreate(MPI_COMM_SELF, &A); MatSetSizes(A, m, n, 0, 0); MatSetType(A,MATSEQAIJ); case('S'): //sparse matType = t; m = rowSz; n = colSz; default: throw runtime_error("Matrix type not recognized\nMatrix not initialized\nExiting..."); } } catch(runtime_error &e) { cout << e.what() << endl; exit(1); } } int petscMatrix::createMatrix() { try{ PetscErrorCode ierr; switch(matType) { case('d'): // dense case('D'): // dense case('s'): //sparse case('S'): //sparse ierr = MatCreateSeqAIJ(PETSC_COMM_WORLD, m, n, 0, PETSC_NULL, &A); CHKERRQ(ierr); default: throw runtime_error("Matrix type not recognized\nMatrix not initialized\nExiting..."); } } catch(runtime_error &e) { cout << e.what() << endl; exit(1); } }