MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_FactoryManager_decl.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_FACTORYMANAGER_DECL_HPP
11 #define MUELU_FACTORYMANAGER_DECL_HPP
12 
13 #include "MueLu_ConfigDefs.hpp"
16 
27 #include "MueLu_RAPFactory_fwd.hpp"
30 #include "MueLu_SaPFactory_fwd.hpp"
41 
44 
45 namespace MueLu {
46 
66 template <class Scalar = DefaultScalar,
69  class Node = DefaultNode>
71 #undef MUELU_FACTORYMANAGER_SHORT
72 #include "MueLu_UseShortNames.hpp"
73 
74  public:
76 
77 
80 
82  FactoryManager(const std::map<std::string, RCP<const FactoryBase> >& factoryTable);
83 
85  virtual ~FactoryManager();
86 
88 
90 
91 
99  void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
100 
106  const RCP<const FactoryBase> GetFactory(const std::string& varName) const;
107 
113  const RCP<FactoryBase> GetFactoryNonConst(const std::string& varName);
114 
116  // Return true if Factory associated with varName is registered
117  bool hasFactory(const std::string& varName) const;
118 
120  const RCP<const FactoryBase> GetDefaultFactory(const std::string& varName) const;
121 
122  void SetKokkosRefactor(const bool useKokkos) {
123  useKokkos_ = useKokkos;
124  }
125 
126  bool GetKokkosRefactor() const { return useKokkos_; }
127 
129 
130  void Clean() const { defaultFactoryTable_.clear(); }
131 
132 #ifdef HAVE_MUELU_DEBUG
133  void ResetDebugData() const;
134 #endif
135 
136  void Print() const;
137 
138  private:
140 
141 
147  const RCP<const FactoryBase> SetAndReturnDefaultFactory(const std::string& varName, const RCP<const FactoryBase>& factory) const;
149 
157  std::map<std::string, RCP<const FactoryBase> > factoryTable_;
158 
165  mutable std::map<std::string, RCP<const FactoryBase> > defaultFactoryTable_;
166 
169 
170 }; // class
171 
172 } // namespace MueLu
173 
174 #define MUELU_FACTORYMANAGER_SHORT
175 #endif // MUELU_FACTORYMANAGER_DECL_HPP
This class specifies the default factory that should generate some data on a Level if the data does n...
MueLu::DefaultLocalOrdinal LocalOrdinal
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
void SetKokkosRefactor(const bool useKokkos)
const RCP< const FactoryBase > GetDefaultFactory(const std::string &varName) const
bool hasFactory(const std::string &varName) const
Check.
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Get factory associated with a particular data name.
MueLu::DefaultNode Node
const RCP< const FactoryBase > SetAndReturnDefaultFactory(const std::string &varName, const RCP< const FactoryBase > &factory) const
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that provides default factories within Needs class.
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
const RCP< FactoryBase > GetFactoryNonConst(const std::string &varName)
Get factory associated with a particular data name (NONCONST version)
virtual ~FactoryManager()
Destructor.
std::map< std::string, RCP< const FactoryBase > > factoryTable_
User-defined factories.
std::map< std::string, RCP< const FactoryBase > > defaultFactoryTable_
Table that holds default factories.
bool useKokkos_
Whether or not to use kokkos factories.