// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == crystal growth group == // == == // == Stiftung caesar == // == Ludwig-Erhard-Allee 2 == // == 53175 Bonn == // == germany == // == == // ============================================================================ // == == // == http://www.caesar.de/cg/AMDiS == // == == // ============================================================================ /** \file SolverMatrix.h */ #ifndef AMDIS_SOLVERMATRIX_H #define AMDIS_SOLVERMATRIX_H #include "DOFMatrix.h" namespace AMDiS { /** * \brief Helper class to provide complete matrix for ITL solvers and preconditioners */ // General case undefined ! template class SolverMatrix { }; // DOFMatrix, i.e. ScalarProblem template <> class SolverMatrix { public : SolverMatrix() : matrix(0) {} void setMatrix(const DOFMatrix& A) { matrix= &A.getBaseMatrix(); } const DOFMatrix::base_matrix_type& getMatrix() const { return *matrix; } private: const DOFMatrix::base_matrix_type* matrix; }; // VectorProblem template <> class SolverMatrix > { public : void setMatrix(const Matrix& A) { int ns= A.getSize(); std::vector block_starts(ns+1); block_starts[0]= 0; for (int i= 0; i < ns; ++i) block_starts[i+1]= block_starts[i] + A[i][i]->getFESpace()->getAdmin()->getUsedSize(); matrix.change_dim(block_starts[ns], block_starts[ns]); set_to_zero(matrix); DOFMatrix::inserter_type ins(matrix); for (int rb= 0; rb < ns; ++rb) for (int cb= 0; cb < ns; ++cb) if (A[rb][cb]) ins[block_starts[rb]][block_starts[cb]] << A[rb][cb]->getBaseMatrix(); } const DOFMatrix::base_matrix_type& getMatrix() const { return matrix; } private: DOFMatrix::base_matrix_type matrix; }; } // namespace AMDiS #endif // AMDIS_SOLVERMATRIX_H