42 #ifndef BELOS_UTIL_HPP
43 #define BELOS_UTIL_HPP
46 #ifdef HAVE_BELOS_AZTECOO
47 #include "az_aztec_defs.h"
52 enum ETranslateFromAztecStatus {
53 TRANSLATE_FROM_AZTEC_OK =0x00,
54 TRANSLATE_FROM_AZTEC_WARN =0x01,
55 TRANSLATE_FROM_AZTEC_ERROR =0x02};
57 std::pair< std::string, int >
59 const int * aztec_options,
60 const double * aztec_params
63 int econd = TRANSLATE_FROM_AZTEC_OK;
65 if(aztec_options == NULL || aztec_params == NULL ) {
66 return std::pair<std::string,int>(string(
"Belos_Translate_from_Aztec_Params:: Aztec Options or Parameters were null."),econd);
69 switch (aztec_options[AZ_solver]){
72 tpl.
set(
"Solver Name",
"Pseudoblock GMRES");
76 tpl.
set(
"Solver Name",
"Pseudoblock CG");
79 tpl.
set(
"Solver Name",
"BICGSTAB");
82 tpl.
set(
"Solver Name",
"TFQMR");
85 tpl.
set(
"Solver Name",
"FIXED POINT");
88 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_lu "<<std::endl;
89 econd |= TRANSLATE_FROM_AZTEC_ERROR;
92 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_cgs"<<std::endl;
93 econd |= TRANSLATE_FROM_AZTEC_ERROR;
96 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_slu"<<std::endl;
97 econd |= TRANSLATE_FROM_AZTEC_ERROR;
100 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_symmlq"<<std::endl;
101 econd |= TRANSLATE_FROM_AZTEC_ERROR;
104 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_GMRESR"<<std::endl;
105 econd |= TRANSLATE_FROM_AZTEC_ERROR;
109 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_analyze "<<std::endl;
110 econd |= TRANSLATE_FROM_AZTEC_ERROR;
112 case AZ_gmres_condnum:
113 error<<
" Translate_Params_Aztec_to_Belos:: uncaught solver name AZ_gmres_condnum."<<std::endl;
114 econd |= TRANSLATE_FROM_AZTEC_ERROR;
118 error <<
"Translate_Params_Aztec_to_Belos:: unknown solver enum "<<aztec_options[AZ_solver]<<std::endl;
119 econd |= TRANSLATE_FROM_AZTEC_ERROR;
126 switch (aztec_options[AZ_precond]) {
135 error<<
" Belos does not have built in preconditioners, Az_precond ignored."<<std::endl;
136 econd |= TRANSLATE_FROM_AZTEC_WARN;
139 switch(aztec_options[AZ_subdomain_solve]) {
149 error<<
" Belos does not have built in subdomain solvers, Az_subdomain_solve ignored."<<std::endl;
150 econd |= TRANSLATE_FROM_AZTEC_WARN;
154 switch(aztec_options[AZ_conv]) {
156 tpl.
set(
"Implicit Residual Scaling",
"Norm of Initial Residual");
159 tpl.
set(
"Implicit Residual Scaling",
"Norm of RHS");
162 tpl.
set(
"Implicit Residual Scaling",
"Norm of Preconditioned Initial Residual");
165 tpl.
set(
"Implicit Residual Scaling",
"None");
168 case AZ_expected_values:
170 error <<
"Belos_Translate_from_Aztec_Params: AZ_conv of AZ_sol or AZ_expected_values are not valid for belos. "<<std::endl;
171 econd |= TRANSLATE_FROM_AZTEC_ERROR;
180 switch(aztec_options[AZ_output]) {
191 tpl.
set(
"Output Frequency", -1);
194 tpl.
set(
"Output Frequency", 1);
199 tpl.
set(
"Output Frequency", -1);
202 tpl.
set(
"Output Frequency", -1);
207 const int freq = aztec_options[AZ_output];
208 tpl.
set(
"Output Frequency", freq);
213 tpl.
set(
"Verbosity", static_cast<int> (belosPrintOptions));
218 if (aztec_options[AZ_solver] == AZ_gmres) {
219 switch(aztec_options[AZ_orthog]) {
221 tpl.
set(
"Orthogonalization",
"ICGS");
224 tpl.
set(
"Orthogonalization",
"IMGS");
227 error<<
"Option AZ_orthog for GMRES not recognized "<<aztec_options[AZ_orthog]<<endl;
228 econd |= TRANSLATE_FROM_AZTEC_ERROR;
233 if(aztec_options[AZ_max_iter]!=0)
234 tpl.
set(
"Maximum Iterations",aztec_options[AZ_max_iter]);
238 if (aztec_options[AZ_solver] == AZ_gmres &&
239 aztec_options[AZ_kspace] !=0) {
240 tpl.
set(
"Num Blocks",aztec_options[AZ_kspace]);
244 tpl.
set(
"Convergence Tolerance",aztec_params[AZ_tol]);
245 for(
int i=AZ_drop ; i<= AZ_weights ; ++i) {
246 if(aztec_params[i]!=0 ){
247 error <<
" Aztec_Params at "<<i<<
" non zero and will be ignored"<<std::endl;
248 econd |= TRANSLATE_FROM_AZTEC_WARN;
254 return std::pair<std::string,int>(
error.str(),econd);
Collection of types and exceptions used within the Belos solvers.
MsgType
Available message types recognized by the linear solvers.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Belos header file which uses auto-configuration information to include necessary C++ headers...