// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == TU Dresden == // == == // == Institut für Wissenschaftliches Rechnen == // == Zellescher Weg 12-14 == // == 01069 Dresden == // == germany == // == == // ============================================================================ // == == // == https://gforge.zih.tu-dresden.de/projects/amdis/ == // == == // ============================================================================ /** \file ITL_OEMSolver.h */ #ifndef AMDIS_ITL_OEM_SOLVER_H #define AMDIS_ITL_OEM_SOLVER_H #include #include "OEMSolver.h" #include "ITL_Preconditioner.h" #include "SolverMatrix.h" #include "DOFVector.h" #include "SystemVector.h" #include "DOFMatrix.h" #include "Parameters.h" #include #include namespace AMDiS { /** * \ingroup Solver * *\brief * Template for using solvers from ITL in AMDiS. */ template class ITL_OEMSolver : public OEMSolver { typedef ITL_Preconditioner > id_t; public: /// The constructor reads needed parameters and sets solvers \ref name. ITL_OEMSolver(::std::string name) : OEMSolver(name) {} ~ITL_OEMSolver() {} /// Solves the system iteratively // This function is virtual because derived class calls solver with parameter virtual int solveSystem(const DOFMatrix::base_matrix_type& A, mtl::dense_vector& x, const mtl::dense_vector& b) { itl::cyclic_iteration iter(b, this->max_iter, this->relative, this->tolerance, this->print_cycle); #if 0 std::cout << "A is " << num_rows(A) << " x " << num_cols(A) << ", one_norm(A) = " << one_norm(A) << ", b is " << num_rows(b) << ", one_norm(b) = " << one_norm(b) << ", x is " << num_rows(x) << ", one_norm(x) = " << one_norm(x) << "\n"; if (one_norm(x) > 1e100) x= 0.0; #endif error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter); iterations= iter.iterations(); return error; } /// Creator class used in the OEMSolverMap. class Creator : public OEMSolverCreator { public: virtual ~Creator() {} /// Returns a new CGSolver object. OEMSolver* create() { return new ITL_OEMSolver(this->name); } }; }; /** * \ingroup Solver * *\brief * Template for using solvers from ITL that have one run-time parameter in AMDiS. */ template class ITL_OEMSolver_para : public OEMSolver // ITL_OEMSolver { typedef DOFMatrix::value_type value_type; public: /// The constructor reads needed parameters and sets solvers \ref name. ITL_OEMSolver_para(::std::string name) : OEMSolver(name), ell(OEMSolver::max_iter) { GET_PARAMETER(0, name + "->ell", "%d", &ell); } ~ITL_OEMSolver_para() {} /// Set parameter of iterative solver void setEll(int p) { ell= p; } /// Solves the system iteratively int solveSystem(const DOFMatrix::base_matrix_type& A, mtl::dense_vector& x, const mtl::dense_vector& b) { itl::cyclic_iteration iter(b, this->max_iter, this->relative, this->tolerance, this->print_cycle); error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell); iterations= iter.iterations(); return error; } class Creator : public OEMSolverCreator { public: virtual ~Creator() {} /// Returns a new CGSolver object. OEMSolver* create() { return new ITL_OEMSolver_para(this->name); } }; private: /// parameter for bicgstab_ell iterative solver int ell; }; } // namespace AMDiS #endif // AMDIS_ITL_OEM_SOLVER_H