MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_AdaptiveSaMLParameterListInterpreter_decl.hpp
Go to the documentation of this file.
1 /*
2  * MueLu_AdaptiveSaMLParamterListInterpreter_decl.hpp
3  *
4  * Created on: Jan 28, 2013
5  * Author: tobias
6  */
7 
8 #ifndef MUELU_ADAPTIVESAMLPARAMTERLISTINTERPRETER_DECL_HPP_
9 #define MUELU_ADAPTIVESAMLPARAMTERLISTINTERPRETER_DECL_HPP_
10 
12 
13 #include <Xpetra_Matrix_fwd.hpp>
15 #include <Xpetra_Operator_fwd.hpp>
16 
17 #include "MueLu_ConfigDefs.hpp"
20 
21 #include "MueLu_Hierarchy_fwd.hpp"
23 
25 #include "MueLu_SaPFactory_fwd.hpp"
26 #include "MueLu_PgPFactory_fwd.hpp"
31 #include "MueLu_RAPFactory_fwd.hpp"
37 
38 namespace MueLu {
39 
40 /*
41  Utility that from an existing Teuchos::ParameterList creates a new list, in
42  which level-specific parameters are replaced with sublists.
43 
44  Currently, level-specific parameters that begin with "smoother:"
45  or "aggregation:" are placed in sublists. Coarse options are also placed
46  in a coarse list.
47 
48  Example:
49  Input:
50  smoother: type (level 0) = symmetric Gauss-Seidel
51  smoother: sweeps (level 0) = 1
52  Output:
53  smoother: list (level 0) ->
54  smoother: type = symmetric Gauss-Seidel
55  smoother: sweeps = 1
56 */
57 // This function is a copy of ML_CreateSublists to avoid dependency on ML
58 // Throw exception on error instead of exit()
59 // void CreateSublists(const ParameterList &List, ParameterList &newList);
60 
67 template <class Scalar = DefaultScalar,
70  class Node = DefaultNode>
71 class AdaptiveSaMLParameterListInterpreter : public HierarchyManager<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
72 #undef MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_SHORT
73 #include "MueLu_UseShortNames.hpp"
74 
75  public:
77 
78 
81  : nullspace_(NULL)
82  , blksize_(1) {}
83 
92  AdaptiveSaMLParameterListInterpreter(Teuchos::ParameterList& paramList, std::vector<RCP<FactoryBase> > factoryList = std::vector<RCP<FactoryBase> >(0));
93 
101  AdaptiveSaMLParameterListInterpreter(const std::string& xmlFileName, std::vector<RCP<FactoryBase> > factoryList = std::vector<RCP<FactoryBase> >(0));
102 
105 
107 
109 
110  void SetParameterList(const Teuchos::ParameterList& paramList);
111 
113 
115 
117  virtual void SetupHierarchy(Hierarchy& H) const;
118 
120 
122 
124 
125 
131  void AddTransferFactory(const RCP<FactoryBase>& factory);
132 
134  size_t NumTransferFactories() const;
136 
137  private:
143  void SetupInitHierarchy(Hierarchy& H) const;
144 
146  void AddInitFactoryManager(int startLevel, int numDesiredLevel, RCP<FactoryManagerBase> manager) {
147  const int lastLevel = startLevel + numDesiredLevel - 1;
148  if (init_levelManagers_.size() < lastLevel + 1) init_levelManagers_.resize(lastLevel + 1);
149 
150  for (int iLevel = startLevel; iLevel <= lastLevel; iLevel++) {
151  init_levelManagers_[iLevel] = manager;
152  }
153  }
154 
157  Teuchos::RCP<FactoryManagerBase> InitLvlMngr(int levelID, int lastLevelID) const {
158  // Please not that the order of the 'if' statements is important.
159 
160  if (levelID == -1) return Teuchos::null; // when this routine is called with levelID == '-1', it means that we are processing the finest Level (there is no finer level)
161  if (levelID == lastLevelID + 1) return Teuchos::null; // when this routine is called with levelID == 'lastLevelID+1', it means that we are processing the last level (ie: there is no nextLevel...)
162 
163  if (0 == init_levelManagers_.size()) { // default factory manager.
164  // the default manager is shared across levels, initialized only if needed and deleted with the HierarchyManager.
165  static RCP<FactoryManagerBase> defaultMngr = rcp(new FactoryManager());
166  return defaultMngr;
167  }
168  if (levelID >= init_levelManagers_.size()) return init_levelManagers_[init_levelManagers_.size() - 1]; // last levelManager is used for all the remaining levels.
169 
170  return init_levelManagers_[levelID]; // throw exception if out of bound.
171  }
172 
175  double* nullspace_;
176 
179 
184  std::vector<RCP<FactoryBase> > TransferFacts_;
185 
189 
191 
194  virtual void SetupOperator(Operator& Op) const;
195 
197  int blksize_;
199 
200 }; // class AdaptiveSaMLParameterListInterpreter
201 
202 } // namespace MueLu
203 
204 #define MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_SHORT
205 #endif /* MUELU_ADAPTIVESAMLPARAMTERLISTINTERPRETER_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
int nullspaceDim_
nullspace can be embedded in the ML parameter list
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
MueLu::DefaultNode Node
Teuchos::RCP< FactoryManagerBase > InitLvlMngr(int levelID, int lastLevelID) const
void AddTransferFactory(const RCP< FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories for RAPFactory.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
size_t NumTransferFactories() const
Returns number of transfer factories.
void AddInitFactoryManager(int startLevel, int numDesiredLevel, RCP< FactoryManagerBase > manager)
internal routine to add a new factory manager used for the initialization phase
Provides methods to build a multigrid hierarchy and apply multigrid cycles.