MueLu Version of the Day
Loading...
Searching...
No Matches
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
31namespace MueLu {
32
34 public:
36
38 Factory();
39
41 virtual ~Factory();
43
45
46
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
53 RCP<ParameterList> RemoveFactoriesFromList(const ParameterList& list) const;
54
55 // SetParameterList(...);
56
57 // GetParameterList(...);
58
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
Base class for factories (e.g., R, P, and A_coarse).
void Input(Level &level, const std::string &varName) const
virtual void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Configuration.
static bool timerSync_
virtual ~Factory()
Destructor.
void ResetDebugData() const
void DisableMultipleCallCheck() const
T Get(Level &level, const std::string &varName) const
bool IsType(Level &level, const std::string &varName) const
static void EnableTimerSync()
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.
bool IsAvailable(Level &level, const std::string &varName) const
static void EnableMultipleCheckGlobally()
Factory()
Constructor.
const RCP< const FactoryBase > GetFactory(const std::string &varName) const
Default implementation of FactoryAcceptor::GetFactory()
RCP< ParameterList > RemoveFactoriesFromList(const ParameterList &list) const
static void DisableMultipleCheckGlobally()
void EnableMultipleCallCheck() const
static void DisableTimerSync()
T Get(Level &level, const std::string &varName, const std::string &varParamName) const
Class that holds all level-specific information.
bool IsType(const std::string &ename, const FactoryBase *factory=NoFactory::get())
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
Namespace for MueLu classes and methods.