MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_StratimikosSmoother_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_STRATIMIKOSSMOOTHER_DECL_HPP
47 #define MUELU_STRATIMIKOSSMOOTHER_DECL_HPP
48 
50 
52 #include <Xpetra_Matrix_fwd.hpp>
53 
54 #include "MueLu_ConfigDefs.hpp"
56 
57 #if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
58 
59 #include <Tpetra_CrsMatrix.hpp>
60 
62 #include "MueLu_Level_fwd.hpp"
63 #include "MueLu_SmootherPrototype.hpp"
64 #include "MueLu_Utilities_fwd.hpp"
65 
66 #include <Thyra_LinearOpWithSolveBase.hpp>
67 
68 namespace MueLu {
69 
80 template <class Scalar = SmootherPrototype<>::scalar_type,
81  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
82  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
83  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
84 class StratimikosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
85 #undef MUELU_STRATIMIKOSSMOOTHER_SHORT
86 #include "MueLu_UseShortNames.hpp"
87 
88  public:
90 
91  // TODO: update doc for Stratimikos.
101 #ifndef _MSC_VER
102  // Avoid error C3772: invalid friend template declaration
103  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
104  friend class StratimikosSmoother;
105 #endif
106 
107  StratimikosSmoother(const std::string type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList()){
108  TEUCHOS_TEST_FOR_EXCEPTION(true, Exceptions::RuntimeError, "Stratimikos only works for Scalar=double.")};
109 
111  virtual ~StratimikosSmoother() = default;
112 
114 
115  void SetParameterList(const Teuchos::ParameterList& paramList){};
116 
118 
119 
120  void DeclareInput(Level& currentLevel) const {};
121 
123 
125 
126 
132  void Setup(Level& currentLevel){};
133 
142  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {};
143 
145 
147 
148 
149  RCP<SmootherPrototype> Copy() const { return Teuchos::null; };
150 
152 
154 
155 
157  std::string description() const { return std::string(""); };
158 
160  // using MueLu::Describable::describe; // overloading, not hiding
161  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
162  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const {};
163 
165 
167  // RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
168 
170  size_t getNodeSmootherComplexity() const { return Teuchos::OrdinalTraits<size_t>::invalid(); };
171 
172 }; // class StratimikosSmoother
173 
174 template <class LocalOrdinal, class GlobalOrdinal, class Node>
175 struct StratimikosSmoother<double, LocalOrdinal, GlobalOrdinal, Node> : public SmootherPrototype<double, LocalOrdinal, GlobalOrdinal, Node> {
176  typedef double Scalar;
177 #undef MUELU_STRATIMIKOSSMOOTHER_SHORT
178 #include "MueLu_UseShortNames.hpp"
179 
180  StratimikosSmoother(const std::string type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
181 
183  virtual ~StratimikosSmoother() = default;
184 
186 
187  void SetParameterList(const Teuchos::ParameterList& paramList);
188 
190 
191 
192  void DeclareInput(Level& currentLevel) const;
193 
195 
197 
198 
204  void Setup(Level& currentLevel);
205 
214  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
215 
217 
219 
220 
221  RCP<SmootherPrototype> Copy() const;
222 
224 
226 
227 
229  std::string description() const;
230 
232  // using MueLu::Describable::describe; // overloading, not hiding
233  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
234  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
235 
237 
239  // RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
240 
242  size_t getNodeSmootherComplexity() const;
243 
244  private:
245  void SetupStratimikos(Level& currentLevel);
252  void ExperimentalDropVertConnections(RCP<Matrix>& filteredA, Level& currentLevel);
253 
255 
256  std::string type_;
257 
259 
261  RCP<Matrix> A_;
262 
263  bool recurMgOnFilteredA_ = false;
264 }; // class StratimikosSmoother
265 
266 } // namespace MueLu
267 
268 #define MUELU_STRATIMIKOSSMOOTHER_SHORT
269 #endif // HAVE_MUELU_STRATIMIKOS
270 #endif // MUELU_STRATIMIKOSSMOOTHER_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
MueLu::DefaultNode Node
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal