Debian Codegraph @

packages/muelu/src/MueCentral/MueLu_Factory.hpp

raw
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"
27 #include "MueLu_FactoryAcceptor.hpp"
28 #include "MueLu_ParameterListAcceptor.hpp"
29 #include "MueLu_Level.hpp"
30
31 namespace MueLu {
32
33 class Factory : public FactoryBase, public FactoryAcceptor, public ParameterListAcceptorImpl {
34 public:
35 //@{ Constructors/Destructors.
36
37 //! Constructor.
38 Factory();
39
40 //! Destructor.
41 virtual ~Factory();
42 //@}
43
44 //@{
45 //! Configuration
46
47 //! SetFactory is for expert users only. To change configuration of the preconditioner, use a factory manager.
48 virtual void SetFactory(const std::string& varName, const RCP<const FactoryBase>& factory);
49
50 //! Default implementation of FactoryAcceptor::GetFactory()
51 const RCP<const FactoryBase> GetFactory(const std::string& varName) const;
52
53 RCP<ParameterList> RemoveFactoriesFromList(const ParameterList& list) const;
54
55 // SetParameterList(...);
56
57 // GetParameterList(...);
58
59 //@}
60
61 virtual RCP<const ParameterList> GetValidParameterList() const;
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