Debian Codegraph @

packages/muelu/src/Transfers/Energy-Minimization/MueLu_Constraint_decl.hpp

raw
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_CONSTRAINT_DECL_HPP
11 #define MUELU_CONSTRAINT_DECL_HPP
12
13 #include <Teuchos_SerialDenseMatrix.hpp>
14
15 #include <Xpetra_MultiVector_fwd.hpp>
16 #include <Xpetra_Matrix_fwd.hpp>
17 #include <Xpetra_CrsGraph_fwd.hpp>
18
19 #include "MueLu_ConfigDefs.hpp"
20 #include "MueLu_BaseClass.hpp"
21
22 namespace MueLu {
23
24 //! @brief Constraint space information for the potential prolongator
25 /*!
26 This class implements an idea of the constrained space. In energy
27 minimization, constrained space is used simultaneously with the iterative
28 method to construct the final prolongator. The space has two different
29 constraints.
30
31 \section pattern_constraint Nonzero pattern constraint
32
33 Nonzero pattern constraint means that the final prolongator must have the
34 provided nonzero pattern. This is achieved on each step of the iterative
35 method by restricting the graph of the temporary prolongator to the desired
36 pattern. It is implemented in the Apply function. \note We do not update
37 the graph of the provided temporary prolongator as this is a very expensive
38 procedure. Rather, we extract its values and replace some of the values of
39 the matrix with the correct graph.
40
41 \section space_constraint Coarse space approximation constraint
42
43 Generally, the coarse space constraint is presented by some matrix (X or Q)
44 (see, for instance, the article by Mandel, Brezina and Vanek '99. It is
45 well known that this matrix can be permuted to have a block diagonal form,
46 where each block corresponds to a row in the prolongator. Specifically, let
47 P be the prolongator, and Q be the constraint matrix. Then the constraint
48 is generally written as \f$Q P = B,\f$ where B is the fine nullspace
49 multivector. Q is a block diagonal matrix, \f$Q = diag(Q_1, ..., Q_n)\f$, where n
50 is the number of rows in P. Each block Q_i is of size NSDim x nnz_i, where
51 NSDim is the number of fine nullspace vectors, and nnz_i is the number of
52 nonzero elements in the i-th row of P.
53
54 To constrain the potential prolongator (with correct sparsity pattern, i.e.
55 after the application of the nonzero pattern constraint), one updates its
56 values as
57
58 \f[P = P - Q^H(QQ^H)^{-1}QP.\f]
59
60 Because of the block diagonal form of Q, this can be done row-by-row.
61 \note For efficiency reasons, we store \f[(QQ^H)^{-1}\f] in the XXtInv_
62 array. These matrices are dense, but have small size (NSDim x NSDim).
63 */
64
65 template <class Scalar = DefaultScalar,
66 class LocalOrdinal = DefaultLocalOrdinal,
67 class GlobalOrdinal = DefaultGlobalOrdinal,
68 class Node = DefaultNode>
69 class Constraint : public BaseClass {
70 #undef MUELU_CONSTRAINT_SHORT
71 #include "MueLu_UseShortNames.hpp"
72 public:
73 /*!
74 @class Constraint class.
75 @brief Class which contains the constraint space details
76 */
77
78 //! @name Setup methods.
79 //@{
80
81 /*! Setup constraint.
82 \param B -- Fine nullspace vectors
83 \param Bc -- Coarse nullspace vectors
84 \param Ppattern -- Nonzero sparsity pattern for the prolongator
85 */
86 void Setup(const MultiVector& B, const MultiVector& Bc, RCP<const CrsGraph> Ppattern);
87
88 //@}
89
90 //! @name Apply methods.
91 //@{
92
93 //! Apply constraint.
94 void Apply(const Matrix& P, Matrix& Projected) const;
95
96 //@}
97
98 RCP<const CrsGraph> GetPattern() const {
99 return Ppattern_;
100 }
101
102 private:
103 RCP<MultiVector> X_; //!< Overlapped coarse nullspace
104 RCP<const CrsGraph> Ppattern_; //!< Nonzero sparsity pattern
105 ArrayRCP<Teuchos::SerialDenseMatrix<LO, SC> > XXtInv_; //!< Array storing \f$(Q_i Q_i^H)^{-1}\f$
106 };
107
108 } // namespace MueLu
109
110 #define MUELU_CONSTRAINT_SHORT
111 #endif // MUELU_CONSTRAINT_DECL_HPP