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 // ***********************************************************************
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_FACTORYMANAGER_DECL_HPP
47 #define MUELU_FACTORYMANAGER_DECL_HPP
48 
49 #include "MueLu_ConfigDefs.hpp"
52 
63 #include "MueLu_RAPFactory_fwd.hpp"
66 #include "MueLu_SaPFactory_fwd.hpp"
77 
80 
81 namespace MueLu {
82 
102 template <class Scalar = DefaultScalar,
105  class Node = DefaultNode>
107 #undef MUELU_FACTORYMANAGER_SHORT
108 #include "MueLu_UseShortNames.hpp"
109 
110  public:
112 
113 
116  SetIgnoreUserData(false); // set IgnorUserData flag to false (default behaviour)
117  useKokkos_ = !Node::is_serial;
118  }
119 
121  FactoryManager(const std::map<std::string, RCP<const FactoryBase> >& factoryTable) {
122  factoryTable_ = factoryTable;
123  SetIgnoreUserData(false); // set IgnorUserData flag to false (default behaviour) //TODO: use parent class constructor instead
124  useKokkos_ = !Node::is_serial;
125  }
126 
128  virtual ~FactoryManager() {}
129 
131 
133 
134 
142  void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
143 
149  const RCP<const FactoryBase> GetFactory(const std::string& varName) const;
150 
156  const RCP<FactoryBase> GetFactoryNonConst(const std::string& varName);
157 
159  // Return true if Factory associated with varName is registered
160  bool hasFactory(const std::string& varName) const;
161 
163  const RCP<const FactoryBase> GetDefaultFactory(const std::string& varName) const;
164 
165  void SetKokkosRefactor(const bool useKokkos) {
166  useKokkos_ = useKokkos;
167  }
168 
169  bool GetKokkosRefactor() const { return useKokkos_; }
170 
172 
173  void Clean() const { defaultFactoryTable_.clear(); }
174 
175 #ifdef HAVE_MUELU_DEBUG
176  void ResetDebugData() const;
177 #endif
178 
179  void Print() const;
180 
181  private:
183 
184 
190  const RCP<const FactoryBase> SetAndReturnDefaultFactory(const std::string& varName, const RCP<const FactoryBase>& factory) const;
192 
200  std::map<std::string, RCP<const FactoryBase> > factoryTable_;
201 
208  mutable std::map<std::string, RCP<const FactoryBase> > defaultFactoryTable_;
209 
212 
213 }; // class
214 
215 } // namespace MueLu
216 
217 #define MUELU_FACTORYMANAGER_SHORT
218 #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
virtual ~FactoryManager()
Destructor.
void SetIgnoreUserData(bool bIgnoreUserData=false)
set IgnoreUserData flag
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)
std::map< std::string, RCP< const FactoryBase > > factoryTable_
User-defined factories.
std::map< std::string, RCP< const FactoryBase > > defaultFactoryTable_
Table that holds default factories.
FactoryManager(const std::map< std::string, RCP< const FactoryBase > > &factoryTable)
Constructor used by HierarchyFactory (temporary, will be removed)
bool useKokkos_
Whether or not to use kokkos factories.