MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_MasterList.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_MASTERLIST_HPP
11#define MUELU_MASTERLIST_HPP
12
13#include <sstream>
14#include <map>
15
16#include <Teuchos_ParameterList.hpp>
17#include <Teuchos_ParameterEntry.hpp>
18#include <Teuchos_any.hpp>
19
20namespace MueLu {
21
34template <typename T, typename U>
35class DefaultProblemStrings;
36
38 public:
40 static Teuchos::RCP<const Teuchos::ParameterList> List();
42 static Teuchos::RCP<Teuchos::ParameterList> GetProblemSpecificList(std::string const& problemType);
43
45 template <typename T>
46 static const T& getDefault(const std::string& name) {
47 return List()->get<T>(name);
48 }
49
51 static const Teuchos::ParameterEntry& getEntry(const std::string& name) {
52 return List()->getEntry(name);
53 }
54
58 template <typename T>
59 static std::string generateXMLParameterString(const std::string& name, T data) {
60 Teuchos::ParameterEntry entry = getEntry(name);
61 std::stringstream ss;
62 // TODO: check whether getAny().typeName() matches the typeid(T)
63 // One could use a technique as described here: http://stackoverflow.com/questions/4484982/how-to-convert-typename-t-to-string-in-c
64 ss << "<Parameter name=\"" << name << "\" type=\"" << entry.getAny().typeName() << "\" value=\"" << data << "\"/>";
65 return ss.str();
66 }
67
69 static std::string ML2MueLu(const std::string& name) {
70 std::map<std::string, std::string>::iterator it;
71 it = ML2MueLuLists_.find(name);
72 if (it != ML2MueLuLists_.end())
73 return it->second;
74 else
75 return "";
76 }
77
78 static std::string interpretParameterName(const std::string& name, const std::string& value);
79
80 private:
84
86 static Teuchos::RCP<Teuchos::ParameterList> masterList_;
88 static const std::string stringList_;
90 static Teuchos::RCP<Teuchos::ParameterList> problemSpecificList_;
92 static std::string problemType_;
94 static std::map<std::string, std::string> DefaultProblemTypeLists_;
96 static std::map<std::string, std::string> ML2MueLuLists_;
97};
98
103template <typename T, typename U>
105 public:
106 DefaultProblemStrings(const T& key, const U& val) {
107 map_[key] = val;
108 }
109
110 DefaultProblemStrings<T, U>& operator()(const T& key, const U& val) {
111 map_[key] = val;
112 return *this;
113 }
114
115 operator std::map<T, U>() const {
116 return map_;
117 }
118
119 private:
120 std::map<T, U> map_;
121};
122
123} // namespace MueLu
124
125#endif
Helper class to initialize DefaultProblemTypeLists_ in class MasterList.
DefaultProblemStrings(const T &key, const U &val)
DefaultProblemStrings< T, U > & operator()(const T &key, const U &val)
Static class that holds the complete list of valid MueLu parameters.
static std::string problemType_
The problem type associated with the current problem-specific ParameterList.
static Teuchos::RCP< Teuchos::ParameterList > GetProblemSpecificList(std::string const &problemType)
Return default parameter settings for the specified problem type.
MasterList(const MasterList &)
static const std::string stringList_
String equivalent of the masterList_.
static Teuchos::RCP< Teuchos::ParameterList > masterList_
A ParameterList that holds all valid parameters and their default values.
static std::string ML2MueLu(const std::string &name)
Translate ML parameter to corresponding MueLu parameter.
static std::string generateXMLParameterString(const std::string &name, T data)
Create xml string for given MueLu parameter (easy xml input format)
static const T & getDefault(const std::string &name)
Returns default value on the "master" list for a parameter with the specified name and type.
static Teuchos::RCP< Teuchos::ParameterList > problemSpecificList_
A ParameterList that holds all valid parameters and their default values for a particular problem typ...
static Teuchos::RCP< const Teuchos::ParameterList > List()
Return a "master" list of all valid parameters and their default values.
static std::string interpretParameterName(const std::string &name, const std::string &value)
static std::map< std::string, std::string > DefaultProblemTypeLists_
Map of string equivalents of the problemSpecificList_. The first entry is the problem type,...
MasterList & operator=(const MasterList &)
static std::map< std::string, std::string > ML2MueLuLists_
Map of ML parameter strings to corresponding MueLu parametes.
static const Teuchos::ParameterEntry & getEntry(const std::string &name)
Returns default entry from the "master" list corresponding to the specified name.
Namespace for MueLu classes and methods.