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>
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 
66 #include "MueLu_Level_fwd.hpp"
67 #include "MueLu_SmootherPrototype.hpp"
68 #include "MueLu_Utilities_fwd.hpp"
69 
70 #include <BelosSolverManager.hpp>
71 
72 namespace MueLu {
73 
84 template <class Scalar = SmootherPrototype<>::scalar_type,
85  class LocalOrdinal = typename SmootherPrototype<Scalar>::local_ordinal_type,
86  class GlobalOrdinal = typename SmootherPrototype<Scalar, LocalOrdinal>::global_ordinal_type,
87  class Node = typename SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
88 class BelosSmoother : public SmootherPrototype<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
89 #undef MUELU_BELOSSMOOTHER_SHORT
90 #include "MueLu_UseShortNames.hpp"
91 
92  public:
94 
95  // TODO: update doc for Belos.
105 #ifndef _MSC_VER
106  // Avoid error C3772: invalid friend template declaration
107  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
108  friend class BelosSmoother;
109 #endif
110 
111  BelosSmoother(const std::string type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList());
112 
114  virtual ~BelosSmoother() = default;
115 
117 
118  void SetParameterList(const Teuchos::ParameterList& paramList);
119 
121 
122 
123  void DeclareInput(Level& currentLevel) const;
124 
126 
128 
129 
135  void Setup(Level& currentLevel);
136 
145  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const;
146 
148 
150 
151 
153 
155 
157 
158 
160  std::string description() const;
161 
163  // using MueLu::Describable::describe; // overloading, not hiding
164  // void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const
165  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const;
166 
168 
170  // RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > getPreconditioner(){return prec_;}
171 
173  size_t getNodeSmootherComplexity() const;
174 
175  private:
176  void SetupBelos(Level& currentLevel);
177 
178  private:
179  std::string type_;
180 
185 
188 
189 }; // class BelosSmoother
190 
191 #ifdef HAVE_MUELU_EPETRA
192 
193 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
194  (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
195 // Stub specialization for missing Epetra template args
196 template <>
197 class BelosSmoother<double, int, int, Xpetra::EpetraNode> : public SmootherPrototype<double, int, int, Xpetra::EpetraNode> {
198  typedef double Scalar;
199  typedef int LocalOrdinal;
200  typedef int GlobalOrdinal;
202 #undef MUELU_BELOSSMOOTHER_SHORT
203 #include "MueLu_UseShortNames.hpp"
204 
205  public:
206 #ifndef _MSC_VER
207  // Avoid error C3772: invalid friend template declaration
208  template <class Scalar2, class LocalOrdinal2, class GlobalOrdinal2, class Node2>
209  friend class BelosSmoother;
210 #endif
211 
212  BelosSmoother(const std::string& type, const Teuchos::ParameterList& paramList = Teuchos::ParameterList(), const LocalOrdinal& overlap = 0) {
213  MUELU_TPETRA_ETI_EXCEPTION("BelosSmoother<double,int,int,EpetraNode>", "BelosSmoother<double,int,int,EpetraNode>", "int");
214  };
215 
216  virtual ~BelosSmoother() {}
217 
218  void SetParameterList(const Teuchos::ParameterList& paramList) {}
219  void DeclareInput(Level& currentLevel) const {}
220  void Setup(Level& currentLevel) {}
221  void Apply(MultiVector& X, const MultiVector& B, bool InitialGuessIsZero = false) const {}
222  RCP<SmootherPrototype> Copy() const { return Teuchos::null; }
223 
224  std::string description() const { return std::string(""); }
225  void print(Teuchos::FancyOStream& out, const VerbLevel verbLevel = Default) const {}
226 
228  size_t getNodeSmootherComplexity() const {
229  size_t cplx = 0;
230  return cplx;
231  };
232 };
233 #endif
234 
235 #endif // HAVE_MUELU_EPETRA
236 
237 } // namespace MueLu
238 
239 #define MUELU_BELOSSMOOTHER_SHORT
240 #endif // HAVE_MUELU_BELOS
241 #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.
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.