From: Pratik Nayak Date: Fri, 3 May 2019 14:32:14 +0000 (+0200) Subject: Fix changes suggested by @bangerth. X-Git-Tag: v9.1.0-rc1~134^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e71d748d593c58bc9a95820709836476af4f4514;p=dealii.git Fix changes suggested by @bangerth. + Add explanations for CGS,FCG and IR. + Fix the doxygen @param with [in,out] qualifications. + Add empty lines and fix a typo. + Change cerr to Assert. --- diff --git a/include/deal.II/lac/ginkgo_solver.h b/include/deal.II/lac/ginkgo_solver.h index 9f4116d0d9..a0e428d050 100644 --- a/include/deal.II/lac/ginkgo_solver.h +++ b/include/deal.II/lac/ginkgo_solver.h @@ -198,7 +198,7 @@ namespace GinkgoWrappers std::shared_ptr> system_matrix; /** - * The execution paradigm as a string to be set by the user . The choices + * The execution paradigm as a string to be set by the user. The choices * are between `omp`, `cuda` and `reference` and more details can be found * in Ginkgo's documentation. */ @@ -224,11 +224,13 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the CG solver from the CG factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the CG solver from the CG factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the CG solver. * - * @p exec_type The execution paradigm for the CG solver. + * @param[in] data The additional data required by the solver. */ SolverCG(SolverControl & solver_control, const std::string & exec_type, @@ -237,13 +239,15 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the CG solver from the CG factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the CG solver from the CG factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the CG solver. * - * @p exec_type The execution paradigm for the CG solver. + * @param[in] preconditioner The preconditioner for the solver. * - * @p preconditioner The preconditioner for the solver. + * @param[in] data The additional data required by the solver. */ SolverCG(SolverControl & solver_control, const std::string & exec_type, @@ -276,11 +280,13 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the Bicgstab solver from the Bicgstab factory which - * solves the linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the Bicgstab solver from the Bicgstab + * factory which solves the linear system. + * + * @param[in] exec_type The execution paradigm for the Bicgstab solver. * - * @p exec_type The execution paradigm for the Bicgstab solver. + * @param[in] data The additional data required by the solver. */ SolverBicgstab(SolverControl & solver_control, const std::string & exec_type, @@ -289,13 +295,15 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the Bicgstab solver from the Bicgstab factory which - * solves the linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the Bicgstab solver from the Bicgstab + * factory which solves the linear system. * - * @p exec_type The execution paradigm for the Bicgstab solver. + * @param[in] exec_type The execution paradigm for the Bicgstab solver. * - * @p preconditioner The preconditioner for the solver. + * @param[in] preconditioner The preconditioner for the solver. + * + * @param[in] data The additional data required by the solver. */ SolverBicgstab(SolverControl & solver_control, const std::string & exec_type, @@ -312,6 +320,9 @@ namespace GinkgoWrappers /** * An implementation of the solver interface using the Ginkgo CGS solver. * + * CGS or the conjugate gradient square method is an iterative type Krylov + * subspace method which is suitable for general systems. + * * @ingroup GinkgoWrappers */ template @@ -327,11 +338,13 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the CGS solver from the CGS factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the CGS solver from the CGS factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the CGS solver. * - * @p exec_type The execution paradigm for the CGS solver. + * @param[in] data The additional data required by the solver. */ SolverCGS(SolverControl & solver_control, const std::string & exec_type, @@ -340,13 +353,15 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the CGS solver from the CGS factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the CGS solver from the CGS factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the CGS solver. * - * @p exec_type The execution paradigm for the CGS solver. + * @param[in] preconditioner The preconditioner for the solver. * - * @p preconditioner The preconditioner for the solver. + * @param[in] data The additional data required by the solver. */ SolverCGS(SolverControl & solver_control, const std::string & exec_type, @@ -363,6 +378,18 @@ namespace GinkgoWrappers /** * An implementation of the solver interface using the Ginkgo FCG solver. * + * FCG or the flexible conjugate gradient method is an iterative type Krylov + * subspace method which is suitable for symmetric positive definite methods. + * + * Though this method performs very well for symmetric positive definite + * matrices, it is in general not suitable for general matrices. + * + * In contrast to the standard CG based on the Polack-Ribiere formula, the + * flexible CG uses the Fletcher-Reeves formula for creating the orthonormal + * vectors spanning the Krylov subspace. This increases the computational cost + * of every Krylov solver iteration but allows for non-constant + * preconditioners. + * * @ingroup GinkgoWrappers */ template @@ -378,11 +405,13 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the FCG solver from the FCG factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the FCG solver from the FCG factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the FCG solver. * - * @p exec_type The execution paradigm for the FCG solver. + * @param[in] data The additional data required by the solver. */ SolverFCG(SolverControl & solver_control, const std::string & exec_type, @@ -391,13 +420,15 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the FCG solver from the FCG factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the FCG solver from the FCG factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the FCG solver. * - * @p exec_type The execution paradigm for the FCG solver. + * @param[in] preconditioner The preconditioner for the solver. * - * @p preconditioner The preconditioner for the solver. + * @param[in] data The additional data required by the solver. */ SolverFCG(SolverControl & solver_control, const std::string & exec_type, @@ -440,11 +471,13 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the GMRES solver from the GMRES factory which solves - * the linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the GMRES solver from the GMRES factory + * which solves the linear system. + * + * @param[in] exec_type The execution paradigm for the GMRES solver. * - * @p exec_type The execution paradigm for the GMRES solver. + * @param[in] data The additional data required by the solver. */ SolverGMRES(SolverControl & solver_control, const std::string & exec_type, @@ -453,13 +486,15 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the GMRES solver from the GMRES factory which solves - * the linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the GMRES solver from the GMRES factory + * which solves the linear system. * - * @p exec_type The execution paradigm for the GMRES solver. + * @param[in] exec_type The execution paradigm for the GMRES solver. * - * @p preconditioner The preconditioner for the solver. + * @param[in] preconditioner The preconditioner for the solver. + * + * @param[in] data The additional data required by the solver. */ SolverGMRES(SolverControl & solver_control, const std::string & exec_type, @@ -476,6 +511,10 @@ namespace GinkgoWrappers /** * An implementation of the solver interface using the Ginkgo IR solver. * + * Iterative refinement (IR) is an iterative method that uses another coarse + * method to approximate the error of the current solution via the current + * residual. + * * @ingroup GinkgoWrappers */ template @@ -491,11 +530,13 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the IR solver from the IR factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the IR solver from the IR factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the IR solver. * - * @p exec_type The execution paradigm for the IR solver. + * @param[in] data The additional data required by the solver. */ SolverIR(SolverControl & solver_control, const std::string & exec_type, @@ -504,13 +545,15 @@ namespace GinkgoWrappers /** * Constructor. * - * @p solver_control The solver control object is then used to set the - * parameters and setup the IR solver from the IR factory which solves the - * linear system. + * @param[in,out] solver_control The solver control object is then used to + * set the parameters and setup the IR solver from the IR factory which + * solves the linear system. + * + * @param[in] exec_type The execution paradigm for the IR solver. * - * @p exec_type The execution paradigm for the IR solver. + * @param[in] inner_solver The Inner solver for the IR solver. * - * @p inner_solver The Inner solver for the IR solver. + * @param[in] data The additional data required by the solver. */ SolverIR(SolverControl & solver_control, const std::string & exec_type, diff --git a/source/lac/ginkgo_solver.cc b/source/lac/ginkgo_solver.cc index f79e10d29b..4415c83d76 100644 --- a/source/lac/ginkgo_solver.cc +++ b/source/lac/ginkgo_solver.cc @@ -50,10 +50,10 @@ namespace GinkgoWrappers } else { - std::cerr - << "exec_type needs to be one of the three strings: \"reference\", \"cuda\" or \"omp\", but provided with" - << exec_type << std::endl; - std::exit(-1); + Assert( + false, + ExcMessage( + " exec_type needs to be one of the three strings: \"reference\", \"cuda\" or \"omp\" ")); } using ResidualCriterionFactory = gko::stop::ResidualNormReduction<>; residual_criterion = ResidualCriterionFactory::build() @@ -69,6 +69,8 @@ namespace GinkgoWrappers .on(executor); } + + template void SolverBase::initialize_ginkgo_log() @@ -79,6 +81,8 @@ namespace GinkgoWrappers executor, gko::log::Logger::criterion_check_completed_mask); } + + template void SolverBase::apply(Vector & solution, @@ -199,6 +203,7 @@ namespace GinkgoWrappers } + template SolverControl & SolverBase::control() const @@ -207,6 +212,7 @@ namespace GinkgoWrappers } + template void SolverBase::initialize( @@ -280,6 +286,7 @@ namespace GinkgoWrappers } + template void SolverBase::solve(const SparseMatrix &matrix, @@ -291,8 +298,8 @@ namespace GinkgoWrappers } - /* ---------------------- SolverCG ------------------------ */ + /* ---------------------- SolverCG ------------------------ */ template SolverCG::SolverCG(SolverControl & solver_control, const std::string & exec_type, @@ -305,6 +312,8 @@ namespace GinkgoWrappers cg::build().with_criteria(this->combined_factory).on(this->executor); } + + template SolverCG::SolverCG( SolverControl & solver_control, @@ -322,8 +331,8 @@ namespace GinkgoWrappers } - /* ---------------------- SolverBicgstab ------------------------ */ + /* ---------------------- SolverBicgstab ------------------------ */ template SolverBicgstab::SolverBicgstab( SolverControl & solver_control, @@ -338,6 +347,8 @@ namespace GinkgoWrappers .on(this->executor); } + + template SolverBicgstab::SolverBicgstab( SolverControl & solver_control, @@ -354,8 +365,9 @@ namespace GinkgoWrappers .on(this->executor); } - /* ---------------------- SolverCGS ------------------------ */ + + /* ---------------------- SolverCGS ------------------------ */ template SolverCGS::SolverCGS(SolverControl & solver_control, const std::string &exec_type, @@ -368,6 +380,8 @@ namespace GinkgoWrappers cgs::build().with_criteria(this->combined_factory).on(this->executor); } + + template SolverCGS::SolverCGS( SolverControl & solver_control, @@ -384,8 +398,9 @@ namespace GinkgoWrappers .on(this->executor); } - /* ---------------------- SolverFCG ------------------------ */ + + /* ---------------------- SolverFCG ------------------------ */ template SolverFCG::SolverFCG(SolverControl & solver_control, const std::string &exec_type, @@ -398,6 +413,8 @@ namespace GinkgoWrappers fcg::build().with_criteria(this->combined_factory).on(this->executor); } + + template SolverFCG::SolverFCG( SolverControl & solver_control, @@ -414,14 +431,17 @@ namespace GinkgoWrappers .on(this->executor); } - /* ---------------------- SolverGMRES ------------------------ */ + + /* ---------------------- SolverGMRES ------------------------ */ template SolverGMRES::AdditionalData::AdditionalData( const unsigned int restart_parameter) : restart_parameter(restart_parameter) {} + + template SolverGMRES::SolverGMRES(SolverControl &solver_control, const std::string &exec_type, @@ -436,6 +456,8 @@ namespace GinkgoWrappers .on(this->executor); } + + template SolverGMRES::SolverGMRES( SolverControl & solver_control, @@ -453,8 +475,9 @@ namespace GinkgoWrappers .on(this->executor); } - /* ---------------------- SolverIR ------------------------ */ + + /* ---------------------- SolverIR ------------------------ */ template SolverIR::SolverIR(SolverControl & solver_control, const std::string & exec_type, @@ -467,6 +490,8 @@ namespace GinkgoWrappers ir::build().with_criteria(this->combined_factory).on(this->executor); } + + template SolverIR::SolverIR( SolverControl & solver_control, @@ -483,6 +508,8 @@ namespace GinkgoWrappers .on(this->executor); } + + // Explicit instantiations in GinkgoWrappers # define DEALII_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(_macro) \ template _macro(float, int32_t); \