64 Solver_Belos::Solver_Belos()
65 : tolerance_(1.e-6), maxIters_(500), useTranspose_(false), paramlist_(),
68 ml_prec_(NULL), ml_defaults_set_(false),
69 ml_aztec_options_(NULL), ml_aztec_params_(NULL),
72 dbgprefix_(
"SlvBelos: ")
77 ml_aztec_options_ =
new int[AZ_OPTIONS_SIZE];
78 ml_aztec_params_ =
new double[AZ_PARAMS_SIZE];
83 Solver_Belos::~Solver_Belos()
86 delete [] ml_aztec_options_;
87 delete [] ml_aztec_params_;
93 void Solver_Belos::setUseML(
bool useml)
101 if (paramlist_.get() == NULL) {
105 return( *paramlist_ );
112 int& iterationsTaken,
115 std::string krylov_solver_name;
121 if (ml_aztec_options_ == NULL)
122 ml_aztec_options_ =
new int[AZ_OPTIONS_SIZE];
123 if (ml_aztec_params_ == NULL)
124 ml_aztec_params_ =
new double[AZ_PARAMS_SIZE];
126 if (!ml_defaults_set_ && useML_) {
128 ML_Epetra::SetDefaults(
"SA", mlparams, ml_aztec_options_,ml_aztec_params_);
130 *paramlist = mlparams;
131 ml_defaults_set_ =
true;
146 Trilinos_Helpers::get_Epetra_pointers(feiA, feix, feib,
147 crsA, epetra_op, x, b);
153 if (epetra_op == 0 || x == 0 || b == 0) {
154 fei::console_out() <<
"Solver_Belos::solve Error, couldn't obtain Epetra objects"
155 <<
" from fei container-objects."<<
FEI_ENDL;
160 if (preconditioningMatrix != NULL) {
165 if (snl_epetra_crs != NULL) {
168 else if (snl_epetra_vbr != NULL) {
172 fei::console_out() <<
"Solver_Belos::solve: ERROR getting epetra row matrix"
173 <<
" from preconditioningMatrix."<<
FEI_ENDL;
178 if (precond != NULL) {
182 bool needNewPreconditioner =
false;
186 needNewPreconditioner =
true;
189 if (needNewPreconditioner) {
213 Belos::SolverFactory<double,Epetra_MultiVector,Epetra_Operator> belos_factory;
214 belos_solver_manager_ = belos_factory.create(krylov_solver_name, paramlist);
218 belos_lin_prob->setProblem();
220 belos_solver_manager_->setProblem(belos_lin_prob);
222 belos_solver_manager_->solve();
225 iterationsTaken = belos_solver_manager_->getNumIters();
237 if (olevel >= 3 || param2 ==
"MATRIX_FILES" || param2 ==
"ALL") {
242 if (!param1.empty()) {
243 osstr << param1 <<
"/";
247 osstr <<
"x_Belos.vec";
258 const char*
const* solverParams,
259 int& iterationsTaken,
262 std::vector<std::string> stdstrings;
268 return( solve(linearSystem, preconditioningMatrix, paramset,
269 iterationsTaken, status) );
276 if (ml_aztec_options_ == NULL) {
277 ml_aztec_options_ =
new int[AZ_OPTIONS_SIZE];
279 if (ml_aztec_params_ == NULL) {
280 ml_aztec_params_ =
new double[AZ_PARAMS_SIZE];
283 if (!ml_defaults_set_) {
285 ML_Epetra::SetDefaults(
"SA", mlparams,ml_aztec_options_,ml_aztec_params_);
287 *paramlist_ = mlparams;
288 ml_defaults_set_ =
true;
291 if (ml_prec_ != NULL) {
292 delete ml_prec_; ml_prec_ = NULL;
295 ml_prec_ =
new ML_Epetra::MultiLevelPreconditioner(*A, *paramlist_,
true);
void char_ptrs_to_strings(int numStrings, const char *const *charstrings, std::vector< std::string > &stdstrings)
virtual int writeToFile(const char *filename, bool matrixMarketFormat=true)=0
virtual fei::SharedPtr< fei::Matrix > getMatrix()
virtual int SetUseTranspose(bool UseTranspose)=0
virtual void markState()=0
virtual fei::SharedPtr< fei::Vector > getRHS()
int getStringParamValue(const char *name, std::string ¶mValue) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
fei::SharedPtr< T > getMatrix()
void copy_parameterset(const fei::ParameterSet ¶mset, Teuchos::ParameterList ¶mlist)
virtual bool changedSinceMark()=0
ParameterList & setParameters(const ParameterList &source)
std::ostream & console_out()
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
#define FEI_OSTRINGSTREAM
virtual fei::SharedPtr< fei::Vector > getSolutionVector()
int getIntParamValue(const char *name, int ¶mValue) const