110 void insert(
int row,
int col,
double val);
144 template <
int rows,
int columns>
148 int rowIndices[ stencil.rows() ];
149 std::iota(rowIndices, rowIndices + stencil.rows(), row);
152 int colIndices[ stencil.cols() ];
153 std::iota(colIndices, colIndices + stencil.cols(), col);
156 MatSetValues(
_A, stencil.rows(), rowIndices, stencil.cols(), colIndices, stencil.data(), ADD_VALUES );
Class to capture all of the PETSc objects needed by some experiements.
PreconditionerType
Enum class to allow us to customise different different petsc preconditioner types.
void printMatrix(std::string filename)
Overload to print the matrix to file.
LinearEquationSystem()
Trivial constructor.
static tarch::logging::Log _log
KSPSolverType
Enum class to allow us to customise different different petsc solver types.
void printRhs()
Overload to print the rhs to terminal.
void printX()
Overload to print the solution to terminal.
void insertMatrix(int row, int col, const tarch::la::Matrix< rows, columns, double > &stencil)
Method to insert a tarch::la::Matrix into the PETSc matrix.
void init(int dofs)
method to intialise the matrix and two vectors each we _dofs entries
void insert(int row, double val)
Overload to insert val into the rhs vector, at given row position.
PCType getPreconditionerTypeFromEnum(PreconditionerType type)
double get(int i) const
Getter method to inspect the value of the solution vector at a given index.
int getDoFs() const
Returns number of DoFs in the system.
void insert(int row, int col, double val)
Overload to insert val into the matrix, at given row, column position.
virtual ~LinearEquationSystem()
KSPType getKSPSolverTypeFromEnum(KSPSolverType type)
void increment(int row, double val)
Overload to increment existing val in the rhs vector, at given row position.
void printX(std::string filename)
Overload to print the solution to terminal.
void increment(int row, int col, double val)
Overload to increment existing val in the matrix, at given row, column position.
void cleanUpPetscObjects()
Method to clean up PETSc objects.
void solve(PreconditionerType pctype=PreconditionerType::None, KSPSolverType ksptype=KSPSolverType::GMRES)
Method to hand over to petsc and solve.
void printMatrix()
Overload to print the matrix to terminal.
void printRhs(std::string filename)
Overload to print the rhs to file.