44 #include <ifp_parameters.h>
46 #ifdef HAVE_TEUCHOS_EXTENDED
47 #include <Teuchos_StrUtils.hpp>
53 Teuchos::map<std::string,parameter>& key_map()
55 static Teuchos::map<std::string,parameter> ifpack_key_map;
56 return( ifpack_key_map );
60 void initialize_string_map()
62 static bool already_initialized =
false;
63 if (already_initialized) {
67 Teuchos::map<std::string,parameter>& ifp_key_map = key_map();
69 ifp_key_map[
"LEVEL_FILL"] = level_fill;
70 ifp_key_map[
"LEVEL_OVERLAP"] = level_overlap;
71 ifp_key_map[
"ABSOLUTE_THRESHOLD"] = absolute_threshold;
72 ifp_key_map[
"RELATIVE_THRESHOLD"] = relative_threshold;
73 ifp_key_map[
"OVERLAP_MODE"] = overlap_mode;
74 ifp_key_map[
"DROP_TOLERANCE"] = drop_tolerance;
75 ifp_key_map[
"FILL_TOLERANCE"] = fill_tolerance;
76 ifp_key_map[
"RELAX_VALUE"] = relax_value;
77 ifp_key_map[
"USE_RECIPROCAL"] = use_reciprocal;
78 ifp_key_map[
"NUM_STEPS"] = num_steps;
80 already_initialized =
true;
84 std::string upper_case(
const std::string& s)
86 #ifdef HAVE_TEUCHOS_EXTENDED
87 std::string upp = Teuchos::StrUtils::allCaps(s);
90 for(
unsigned i=0; i<upp.length(); ++i) {
91 upp[i] = toupper(upp[i]);
99 void set_parameters(
const Teuchos::ParameterList& parameterlist,
100 param_struct& params,
101 bool cerr_warning_if_unused)
106 initialize_string_map();
108 Teuchos::map<std::string,parameter>& ifp_key_map = key_map();
110 Teuchos::ParameterList::ConstIterator
111 pl_iter = parameterlist.begin(),
112 pl_end = parameterlist.end();
114 for(; pl_iter != pl_end; ++pl_iter) {
115 std::string name = upper_case((*pl_iter).first);
117 const Teuchos::ParameterEntry& entry = (*pl_iter).second;
118 bool entry_used =
false;
120 Teuchos::map<std::string,parameter>::iterator result = ifp_key_map.find(name);
121 if (result != ifp_key_map.end()) {
123 double dummy_double = -99.9;
124 bool dummy_bool =
false;
127 parameter offset = (*result).second;
129 if (entry.isType<
double>()) {
130 if (offset < FIRST_INT_PARAM) {
131 params.double_params[offset] = entry.getValue(&dummy_double);
135 else if (entry.isType<
int>()) {
136 int int_val = entry.getValue(&dummy_int);
137 if (offset >= FIRST_INT_PARAM && offset <= LAST_INT_PARAM) {
138 params.int_params[offset-FIRST_INT_PARAM] = int_val;
141 else if (offset == use_reciprocal) {
142 params.use_reciprocal = int_val;
146 else if (entry.isType<
bool>()) {
147 params.use_reciprocal = entry.getValue(&dummy_bool);
151 params.overlap_mode = entry.getValue(&dummy_mode);
156 if (!entry_used && cerr_warning_if_unused) {
157 cerr <<
"Ifpack set_parameters warning: '"<<name<<
"' not used."<<endl;
Ifpack: a function class to define Ifpack preconditioners.