MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_Factory.hpp
Go to the documentation of this file.
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_FACTORY_HPP
11 #define MUELU_FACTORY_HPP
12 
13 #include <string>
14 #include <deque> // for _Deque_iterator, operator!=
15 #include <ostream> // for operator<<, etc
16 #include "Teuchos_ENull.hpp" // for ENull::null
17 #include "Teuchos_FilteredIterator.hpp" // for FilteredIterator, etc
18 #include "Teuchos_ParameterEntry.hpp" // for ParameterEntry
19 #include "Teuchos_ParameterList.hpp" // for ParameterList, etc
20 #include "Teuchos_RCPDecl.hpp" // for RCP
21 #include "Teuchos_RCPNode.hpp" // for operator<<
22 #include "Teuchos_StringIndexedOrderedValueObjectContainer.hpp"
23 #include "Teuchos_RCP.hpp"
24 
25 #include "MueLu_ConfigDefs.hpp"
26 #include "MueLu_FactoryBase.hpp"
29 #include "MueLu_Level.hpp"
30 
31 namespace MueLu {
32 
34  public:
36 
38  Factory();
39 
41  virtual ~Factory();
43 
45 
48  virtual void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
49 
51  const RCP<const FactoryBase> GetFactory(const std::string& varName) const;
52 
54 
55  // SetParameterList(...);
56 
57  // GetParameterList(...);
58 
60 
62 
63  protected:
64  void Input(Level& level, const std::string& varName) const;
65  // Similar to the other Input, but we have an alias (varParamName) to the generated data name (varName)
66  void Input(Level& level, const std::string& varName, const std::string& varParamName) const;
67 
68  template <class T>
69  T Get(Level& level, const std::string& varName) const {
70  return level.Get<T>(varName, GetFactory(varName).get());
71  }
72 
73  // Similar to the other Get, but we have an alias (varParamName) to the generated data name (varName)
74  template <class T>
75  T Get(Level& level, const std::string& varName, const std::string& varParamName) const {
76  return level.Get<T>(varName, GetFactory(varParamName).get());
77  }
78 
79  template <class T>
80  void Set(Level& level, const std::string& varName, const T& data) const {
81  return level.Set<T>(varName, data, this);
82  }
83 
84  template <class T>
85  bool IsType(Level& level, const std::string& varName) const {
86  return level.IsType<T>(varName, GetFactory(varName).get());
87  }
88 
89  bool IsAvailable(Level& level, const std::string& varName) const;
90 
91  public:
92  static void EnableTimerSync();
93  static void DisableTimerSync();
94 
95  protected:
96  static bool timerSync_;
97 
98 #ifdef HAVE_MUELU_DEBUG
99  public:
100  enum multipleCallCheckEnum{ENABLED, DISABLED, FIRSTCALL};
101 
102  void EnableMultipleCallCheck() const;
103  void DisableMultipleCallCheck() const;
104  void ResetDebugData() const;
105 
106  static void EnableMultipleCheckGlobally();
107  static void DisableMultipleCheckGlobally();
108 
109  protected:
110  mutable multipleCallCheckEnum multipleCallCheck_;
111  static multipleCallCheckEnum multipleCallCheckGlobal_;
112  mutable int lastLevelID_;
113 #else
114  public:
115  void EnableMultipleCallCheck() const;
116  void DisableMultipleCallCheck() const;
117  void ResetDebugData() const;
118  static void EnableMultipleCheckGlobally();
119  static void DisableMultipleCheckGlobally();
120 #endif
121 }; // class Factory
122 
123 } // namespace MueLu
124 
125 #define MUELU_FACTORY_SHORT
126 #endif // ifndef MUELU_FACTORY_HPP
void DisableMultipleCallCheck() const
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level-&gt;Get&lt; RCP&lt;Matrix&gt; &gt;(&quot;A&quot;, factory) if factory == NULL =&gt; use default factory.
virtual void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Configuration.
T Get(Level &level, const std::string &varName) const
static void DisableTimerSync()
RCP< ParameterList > RemoveFactoriesFromList(const ParameterList &list) const
static void DisableMultipleCheckGlobally()
bool IsType(Level &level, const std::string &varName) const
static void EnableTimerSync()
Factory()
Constructor.
Base class for factories (e.g., R, P, and A_coarse).
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
void EnableMultipleCallCheck() const
static bool timerSync_
void Set(Level &level, const std::string &varName, const T &data) const
virtual RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void ResetDebugData() const
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
bool IsAvailable(Level &level, const std::string &varName) const
bool IsType(const std::string &ename, const FactoryBase *factory=NoFactory::get())
T Get(Level &level, const std::string &varName, const std::string &varParamName) const
static void EnableMultipleCheckGlobally()
void Input(Level &level, const std::string &varName) const
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory()
virtual ~Factory()
Destructor.