| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// MueLu: A package for multigrid based preconditioning |
| 4 |
// |
| 5 |
// Copyright 2012 NTESS and the MueLu contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef MUELU_CGSOLVER_DECL_HPP |
| 11 |
#define MUELU_CGSOLVER_DECL_HPP |
| 12 |
|
| 13 |
#include <Xpetra_Matrix_fwd.hpp> |
| 14 |
#include <Xpetra_CrsMatrixWrap_fwd.hpp> |
| 15 |
#include <Xpetra_CrsMatrixFactory_fwd.hpp> |
| 16 |
|
| 17 |
#include "MueLu_ConfigDefs.hpp" |
| 18 |
#include "MueLu_SolverBase.hpp" |
| 19 |
#include "MueLu_Constraint_fwd.hpp" |
| 20 |
#include "MueLu_Utilities_fwd.hpp" |
| 21 |
|
| 22 |
namespace MueLu { |
| 23 |
|
| 24 |
/*! |
| 25 |
@class CGSolver class. |
| 26 |
@brief Implements conjugate gradient algorithm for energy-minimization |
| 27 |
|
| 28 |
This is CG applied to the problem |
| 29 |
\f[ \min_P \frac12 \sum_i (p_i)^T A p_i \f] |
| 30 |
subject to |
| 31 |
\f[ P(i,j) = 0 \quad \mbox{if} \; (i,j) \mbox{ is not in SparsityPattern} \f] |
| 32 |
and |
| 33 |
\f[ P cnull = fnull. \f] |
| 34 |
|
| 35 |
\note |
| 36 |
For now we assume, that matrices have real values. The case of complex values is not explored. |
| 37 |
*/ |
| 38 |
|
| 39 |
template <class Scalar = DefaultScalar, |
| 40 |
class LocalOrdinal = DefaultLocalOrdinal, |
| 41 |
class GlobalOrdinal = DefaultGlobalOrdinal, |
| 42 |
class Node = DefaultNode> |
| 43 |
class CGSolver : public SolverBase<Scalar, LocalOrdinal, GlobalOrdinal, Node> { |
| 44 |
#undef MUELU_CGSOLVER_SHORT |
| 45 |
#include "MueLu_UseShortNames.hpp" |
| 46 |
|
| 47 |
public: |
| 48 |
//! @name Constructors / destructors |
| 49 |
//@{ |
| 50 |
|
| 51 |
/*! Constructor |
| 52 |
\param Its -- Number of performed iterations |
| 53 |
*/ |
| 54 |
CGSolver(size_t Its); |
| 55 |
|
| 56 |
//@} |
| 57 |
|
| 58 |
//! @name Iterate methods. |
| 59 |
//@{ |
| 60 |
|
| 61 |
//! Iterate |
| 62 |
void Iterate(const Matrix& A, const Constraint& C, const Matrix& P0, RCP<Matrix>& P) const; |
| 63 |
|
| 64 |
//@} |
| 65 |
|
| 66 |
private: |
| 67 |
size_t nIts_; //!< Number of performed iterations |
| 68 |
}; |
| 69 |
|
| 70 |
} // namespace MueLu |
| 71 |
|
| 72 |
#define MUELU_CGSOLVER_SHORT |
| 73 |
#endif // MUELU_CGSOLVER_DECL_HPP |