Teuchos::RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > build_precond(Teuchos::ParameterList& test_params, const Teuchos::RCP<const Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node,LocalMatVec,LocalMatSolve> >& A) { Teuchos::Time timer("precond"); typedef Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tprec; Teuchos::RCP<Tprec> prec; Ifpack2::Factory factory; std::string prec_name("not specified"); Ifpack2::getParameter(test_params, "Ifpack2::Preconditioner", prec_name); prec = factory.create(prec_name, A); Teuchos::ParameterList tif_params; if (test_params.isSublist("Ifpack2")) { tif_params = test_params.sublist("Ifpack2"); } if (A->getRowMap()->getComm()->getRank() == 0) { std::cout << "Configuring/Initializing/Computing Ifpack2 preconditioner..." << std::endl; } prec->setParameters(tif_params); prec->initialize(); timer.start(); prec->compute(); timer.stop(); if (A->getRowMap()->getComm()->getRank() == 0) { std::cout << "... Finished Computing Ifpack2 preconditioner (time: "<<timer.totalElapsedTime() << "s)" << std::endl; } // typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType; // magnitudeType condest = prec->computeCondEst(Ifpack2::Cheap); // if (A->getRowMap()->getComm()->getRank() == 0) { // std::cout << "Condition estimate(cheap) for preconditioner on proc 0: " // << condest << std::endl; // } return prec; }
void print_tree (FILE *fp, struct predicate *node, int indent) { int i; if (node == NULL) return; for (i = 0; i < indent; i++) fprintf (fp, " "); fprintf (fp, "pred=["); print_predicate (fp, node); fprintf (fp, "] type=%s prec=%s", type_name (node->p_type), prec_name (node->p_prec)); fprintf (fp, " cost=%s rate=%#03.2g %sside effects ", cost_name (node->p_cost), node->est_success_rate, (node->side_effects ? "" : "no ")); if (node->need_stat || node->need_type || node->need_inum) { int comma = 0; fprintf (fp, "Needs "); if (node->need_stat) { fprintf (fp, "stat"); comma = 1; } if (node->need_inum) { fprintf (fp, "%sinode", comma ? "," : ""); comma = 1; } if (node->need_type) { fprintf (fp, "%stype", comma ? "," : ""); } } fprintf (fp, "\n"); for (i = 0; i < indent; i++) fprintf (fp, " "); if (NULL == node->pred_left && NULL == node->pred_right) { fprintf (fp, "no children.\n"); } else { if (node->pred_left) { fprintf (fp, "left:\n"); print_tree (fp, node->pred_left, indent + 1); } else { fprintf (fp, "no left.\n"); } for (i = 0; i < indent; i++) fprintf (fp, " "); if (node->pred_right) { fprintf (fp, "right:\n"); print_tree (fp, node->pred_right, indent + 1); } else { fprintf (fp, "no right.\n"); } } }