MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_AdaptiveSaMLParameterListInterpreter_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/*
11 * MueLu_AdaptiveSaMLParamterListInterpreter_decl.hpp
12 *
13 * Created on: Jan 28, 2013
14 * Author: tobias
15 */
16
17#ifndef MUELU_ADAPTIVESAMLPARAMTERLISTINTERPRETER_DECL_HPP_
18#define MUELU_ADAPTIVESAMLPARAMTERLISTINTERPRETER_DECL_HPP_
19
20#include <Teuchos_ParameterList.hpp>
21
22#include <Xpetra_Matrix_fwd.hpp>
23#include <Xpetra_MultiVector_fwd.hpp>
24#include <Xpetra_Operator_fwd.hpp>
25
26#include "MueLu_ConfigDefs.hpp"
27#include "MueLu_HierarchyManager.hpp"
29
32
46
47namespace MueLu {
48
49/*
50 Utility that from an existing Teuchos::ParameterList creates a new list, in
51 which level-specific parameters are replaced with sublists.
52
53 Currently, level-specific parameters that begin with "smoother:"
54 or "aggregation:" are placed in sublists. Coarse options are also placed
55 in a coarse list.
56
57 Example:
58 Input:
59 smoother: type (level 0) = symmetric Gauss-Seidel
60 smoother: sweeps (level 0) = 1
61 Output:
62 smoother: list (level 0) ->
63 smoother: type = symmetric Gauss-Seidel
64 smoother: sweeps = 1
65*/
66// This function is a copy of ML_CreateSublists to avoid dependency on ML
67// Throw exception on error instead of exit()
68// void CreateSublists(const ParameterList &List, ParameterList &newList);
69
76template <class Scalar = DefaultScalar,
79 class Node = DefaultNode>
80class AdaptiveSaMLParameterListInterpreter : public HierarchyManager<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
81#undef MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_SHORT
83
84 public:
86
87
92
101 AdaptiveSaMLParameterListInterpreter(Teuchos::ParameterList& paramList, std::vector<RCP<FactoryBase> > factoryList = std::vector<RCP<FactoryBase> >(0));
102
110 AdaptiveSaMLParameterListInterpreter(const std::string& xmlFileName, std::vector<RCP<FactoryBase> > factoryList = std::vector<RCP<FactoryBase> >(0));
111
114
116
118
119 void SetParameterList(const Teuchos::ParameterList& paramList);
120
122
124
126 virtual void SetupHierarchy(Hierarchy& H) const;
127
129
131
133
134
140 void AddTransferFactory(const RCP<FactoryBase>& factory);
141
143 size_t NumTransferFactories() const;
145
146 private:
152 void SetupInitHierarchy(Hierarchy& H) const;
153
155 void AddInitFactoryManager(int startLevel, int numDesiredLevel, RCP<FactoryManagerBase> manager) {
156 const int lastLevel = startLevel + numDesiredLevel - 1;
157 if (init_levelManagers_.size() < lastLevel + 1) init_levelManagers_.resize(lastLevel + 1);
158
159 for (int iLevel = startLevel; iLevel <= lastLevel; iLevel++) {
160 init_levelManagers_[iLevel] = manager;
161 }
162 }
163
166 Teuchos::RCP<FactoryManagerBase> InitLvlMngr(int levelID, int lastLevelID) const {
167 // Please not that the order of the 'if' statements is important.
168
169 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)
170 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...)
171
172 if (0 == init_levelManagers_.size()) { // default factory manager.
173 // the default manager is shared across levels, initialized only if needed and deleted with the HierarchyManager.
174 static RCP<FactoryManagerBase> defaultMngr = rcp(new FactoryManager());
175 return defaultMngr;
176 }
177 if (levelID >= init_levelManagers_.size()) return init_levelManagers_[init_levelManagers_.size() - 1]; // last levelManager is used for all the remaining levels.
178
179 return init_levelManagers_[levelID]; // throw exception if out of bound.
180 }
181
184 double* nullspace_;
185
188
193 std::vector<RCP<FactoryBase> > TransferFacts_;
194
197 Array<RCP<FactoryManagerBase> > init_levelManagers_;
198
200
203 virtual void SetupOperator(Operator& Op) const;
204
208
209}; // class AdaptiveSaMLParameterListInterpreter
210
211} // namespace MueLu
212
213#define MUELU_ADAPTIVESAMLPARAMETERLISTINTERPRETER_SHORT
214#endif /* MUELU_ADAPTIVESAMLPARAMTERLISTINTERPRETER_DECL_HPP_ */
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
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
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Teuchos::RCP< FactoryManagerBase > InitLvlMngr(int levelID, int lastLevelID) const
int nullspaceDim_
nullspace can be embedded in the ML parameter list
void AddTransferFactory(const RCP< FactoryBase > &factory)
Add transfer factory in the end of list of transfer factories for RAPFactory.
This class specifies the default factory that should generate some data on a Level if the data does n...
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Namespace for MueLu classes and methods.
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar