/****************************************************************************** * * AMDiS - Adaptive multidimensional simulations * * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved. * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis * * Authors: * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * This file is part of AMDiS * * See also license.opensource.txt in the distribution. * ******************************************************************************/ /** \file HypreSolver.h */ #ifndef AMDIS_HYPRE_SOLVER_H #define AMDIS_HYPRE_SOLVER_H #ifdef MTL_HAS_HYPRE #include "solver/MTL4Solver.h" #include "solver/ITL_Preconditioner.h" #include "MTL4Types.h" #include "solver/itl/hypre.hpp" #include #include namespace AMDiS { struct Hypre_Runner : MTL4Runner< MTLTypes::MTLMatrix, MTLTypes::MTLVector > { typedef MTLTypes::MTLMatrix MatrixType; typedef MTLTypes::MTLVector VectorType; typedef MTL4Runner< MatrixType, VectorType > super; Hypre_Runner(LinearSolver* oemPtr) : oem(*oemPtr), solver(NULL) { int cycleMode = 1, interpolation = 0; Parameters::get(oem.getName() + "->cycle mode", cycleMode); Parameters::get(oem.getName() + "->interpolation type", interpolation); config.maxIter(oem.getMaxIterations()); config.interpolation(interpolation); config.cycle(cycleMode); config.tolerance(oem.getTolerance()); config.printLevel(oem.getInfo()); } ~Hypre_Runner() { if (solver) { delete solver; solver = NULL; } } virtual void init(const typename super::BlockMatrix& A, const MatrixType& fullMatrix) { solver = new mtl::HypreSolverWrapper(fullMatrix); } virtual int solve(const MatrixType& A , VectorType& x, const VectorType& b) { int error = (*solver)(x, b, config); return error; } virtual void exit() { if (solver) { delete solver; solver = NULL; } } protected: LinearSolver& oem; mtl::HypreSolverWrapper *solver; mtl::AMGConfigurator config; }; /** * \ingroup Solver * \class AMDiS::HypreSolver * \brief * Wrapper for the external HYPRE-AMG solver */ typedef MTL4Solver< MTLTypes::MTLMatrix, MTLTypes::MTLVector, Hypre_Runner > HypreSolver; } // namespace AMDiS #endif // MTL_HAS_HYPRE #endif // AMDIS_HYPRE_SOLVER_H