MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_BelosSmoother_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_BELOSSMOOTHER_DECL_HPP
47 #define MUELU_BELOSSMOOTHER_DECL_HPP
48 
50 
51 #include <Xpetra_Matrix_fwd.hpp>
52 #include <Xpetra_MultiVectorFactory_fwd.hpp>
53 
54 #include "MueLu_ConfigDefs.hpp"
55 
56 #if defined(HAVE_MUELU_BELOS)
57 
59 
60 #ifdef HAVE_XPETRA_TPETRA
61 #include "BelosTpetraAdapter.hpp"
62 #include <Tpetra_Operator.hpp>
63 #include <Tpetra_MultiVector.hpp>
64 #endif
65 
68 #include "MueLu_Level_fwd.hpp"
69 #include "MueLu_SmootherPrototype.hpp"
70 #include "MueLu_Utilities_fwd.hpp"
71 
72 #include <BelosSolverManager.hpp>
73 
74 
75 namespace MueLu {
76 
87  template <class Scalar = SmootherPrototype<>::scalar_type,
88  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
89  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
90  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
91  class BelosSmoother : public SmootherPrototype<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
92 #undef MUELU_BELOSSMOOTHER_SHORT
93 #include "MueLu_UseShortNames.hpp"
94 
95  public:
96 
98 
99  //TODO: update doc for Belos.
109 #ifndef _MSC_VER
110  // Avoid error C3772: invalid friend template declaration
111  template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
112  friend class BelosSmoother;
113 #endif
114 
115  BelosSmoother(const std::string type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
116 
118  virtual ~BelosSmoother() = default;
119 
121 
122  void SetParameterList(const Teuchos::ParameterList& paramList);
123 
125 
126 
127  void DeclareInput(Level &currentLevel) const;
128 
130 
132 
133 
139  void Setup(Level &currentLevel);
140 
149  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
150 
152 
154 
155 
157 
159 
161 
162 
164  std::string description() const;
165 
167  //using MueLu::Describable::describe; // overloading, not hiding
168  //void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
169  void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const;
170 
172 
174  // RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
175 
177  size_t getNodeSmootherComplexity() const;
178 
179  private:
180  void SetupBelos (Level& currentLevel);
181 
182  private:
183 
184  std::string type_;
185 
186 #ifdef HAVE_MUELU_TPETRA
187  typedef Tpetra::MultiVector<SC, LO, GO, NO> tMV;
188  typedef Tpetra::Operator<SC, LO, GO, NO> tOP;
191 #endif
192 
195 
196  }; // class BelosSmoother
197 
198 
199  #ifdef HAVE_MUELU_EPETRA
200 
201 # if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
202  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
203  // Stub specialization for missing Epetra template args
204  template<>
205  class BelosSmoother<double,int,int,Xpetra::EpetraNode> : public SmootherPrototype<double,int,int,Xpetra::EpetraNode> {
206  typedef double Scalar;
207  typedef int LocalOrdinal;
208  typedef int GlobalOrdinal;
210 #undef MUELU_BELOSSMOOTHER_SHORT
211 #include "MueLu_UseShortNames.hpp"
212 
213  public:
214 #ifndef _MSC_VER
215  // Avoid error C3772: invalid friend template declaration
216  template<class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
217  friend class BelosSmoother;
218 #endif
219 
220  BelosSmoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
221  MUELU_TPETRA_ETI_EXCEPTION("BelosSmoother<double,int,int,EpetraNode>","BelosSmoother<double,int,int,EpetraNode>","int");
222  };
223 
224  virtual ~BelosSmoother() { }
225 
226  void SetParameterList(const Teuchos::ParameterList& paramList) {}
227  void DeclareInput(Level &currentLevel) const {}
228  void Setup(Level &currentLevel) {}
229  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
230  RCP<SmootherPrototype> Copy() const { return Teuchos::null;}
231 
232  std::string description() const { return std::string(""); }
233  void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const {}
234 
236  size_t getNodeSmootherComplexity() const {size_t cplx=0; return cplx;};
237 
238  };
239 # endif
240 
241 #endif // HAVE_MUELU_EPETRA
242 
243 
244 } // namespace MueLu
245 
246 #define MUELU_BELOSSMOOTHER_SHORT
247 #endif // HAVE_MUELU_BELOS
248 #endif // MUELU_BELOSSMOOTHER_DECL_HPP
virtual ~BelosSmoother()=default
Destructor.
BelosSmoother(const std::string &type, const Teuchos::ParameterList &paramList=Teuchos::ParameterList(), const LocalOrdinal &overlap=0)
MueLu::DefaultLocalOrdinal LocalOrdinal
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< Matrix > A_
matrix, used in apply if solving residual equation
Class that encapsulates Belos smoothers.
Base class for smoother prototypes.
void Setup(Level &currentLevel)
Set up the smoother.
Tpetra::Operator< SC, LO, GO, NO > tOP
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
MueLu::DefaultNode Node
size_t getNodeSmootherComplexity() const
For diagnostic purposes.
RCP< SmootherPrototype > Copy() const
RCP< Belos::SolverManager< Scalar, tMV, tOP > > tSolver_
RCP< Belos::LinearProblem< Scalar, tMV, tOP > > tBelosProblem_
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
#define MUELU_TPETRA_ETI_EXCEPTION(cl, obj, go)
void SetupBelos(Level &currentLevel)
friend class BelosSmoother
Constructor.
void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply the preconditioner.
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
Kokkos::Compat::KokkosSerialWrapperNode EpetraNode
Tpetra::MultiVector< SC, LO, GO, NO > tMV
void Apply(MultiVector &X, const MultiVector &B, bool InitialGuessIsZero=false) const
Apply smoother.
void SetParameterList(const Teuchos::ParameterList &paramList)
Set parameters from a parameter list and return with default values.
void DeclareInput(Level &currentLevel) const
Input.
std::string description() const
Return a simple one-line description of this object.
std::string description() const
Return a simple one-line description of this object.