3 #include "Tpetra_CrsMatrix.hpp" 
    4 #include "Thyra_Ifpack2PreconditionerFactory.hpp" 
   11 typedef map_type::local_ordinal_type 
LO;
 
   12 typedef map_type::global_ordinal_type 
GO;
 
   15 typedef Tpetra::Operator<ST, LO, GO> 
op_type;
 
   21   const Tpetra::global_size_t numGlobalElements = 100;
 
   23   const GO indexBase = 0;
 
   24   auto map = 
rcp (
new map_type (numGlobalElements, indexBase, comm));
 
   26   const LO numMyElements = map->getNodeNumElements ();
 
   27   auto myGlobalElements = map->getNodeElementList ();
 
   30   for (
LO lclRow = 0; lclRow < numMyElements; ++lclRow) {
 
   31     const GO gblInd = map->getGlobalElement (lclRow);
 
   32     const ST val = 
static_cast<ST> (1.0) / 
static_cast<ST> (gblInd + 1);
 
   33     A->insertGlobalValues (gblInd,
 
   34                            Teuchos::tuple (gblInd),
 
   35                            Teuchos::tuple (val));
 
   42 main (
int argc, 
char *argv[])
 
   44   using Teuchos::outArg;
 
   53   auto out = Teuchos::VerboseObjectBase::getDefaultOStream ();
 
   55   const int myRank = comm->getRank ();
 
   57   *out << 
"Creating matrix" << endl;
 
   62   catch (std::exception& e) {
 
   64     std::ostringstream os;
 
   65     os << 
"Proc " << myRank << 
": create_matrix(comm) threw an " 
   66       "exception: " << e.what () << endl;
 
   71     std::ostringstream os;
 
   72     os << 
"Proc " << myRank << 
": create_matrix(comm) threw an " 
   73       "exception not a subclass of std::exception." << endl;
 
   77   reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
 
   78   if (gblSuccess != 1) {
 
   80       *out << 
"create_matrix(comm) threw an exception on some process." 
   83     *out << 
"End Result: TEST FAILED" << endl;
 
   92   reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
 
   93   if (gblSuccess != 1) {
 
   95       *out << 
"The result of create_matrix(comm) is null on at least one " 
   98     *out << 
"End Result: TEST FAILED" << endl;
 
  102   *out << 
"Creating vectors" << endl;
 
  108   *out << 
"Creating Stratimikos linear solver builder" << endl;
 
  114   catch (std::exception& e) {
 
  116     std::ostringstream os;
 
  117     os << 
"Proc " << myRank << 
": builder.setParameterList(p) threw an " 
  118       "exception: " << e.what () << endl;
 
  123     std::ostringstream os;
 
  124     os << 
"Proc " << myRank << 
": builder.setParameterList(p) threw an " 
  125       "exception not a subclass of std::exception." << endl;
 
  129   reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
 
  130   if (gblSuccess != 1) {
 
  132       *out << 
"builder.setParameterList(p) threw an exception on some process." 
  135     *out << 
"End Result: TEST FAILED" << endl;
 
  139   *out << 
"Calling builder.createLinearSolveStrategy" << endl;
 
  143   *out << 
"Calling Thyra::createConstLinearOp" << endl;
 
  151   if (thyraA.is_null ()) {
 
  155   reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
 
  156   if (gblSuccess != 1) {
 
  158       *out << 
"The result of Thyra::createConstLinearOp is null on at least " 
  159         "one process." << endl;
 
  161     *out << 
"End Result: TEST FAILED" << endl;
 
  165   *out << 
"Creating Thyra Ifpack2 factory" << endl;
 
  167     rcp (
new Thyra::Ifpack2PreconditionerFactory<crs_matrix_type> ());
 
  169   *out << 
"Creating Ifpack2 preconditioner using factory" << endl;
 
  170   typedef Thyra::PreconditionerBase<ST> prec_type;
 
  173     prec = factory->createPrec ();
 
  175   catch (std::exception& e) {
 
  177     std::ostringstream os;
 
  178     os << 
"Proc " << myRank << 
": factory->createPrec() threw an " 
  179       "exception: " << e.what () << endl;
 
  184     std::ostringstream os;
 
  185     os << 
"Proc " << myRank << 
": factory->createPrec() threw an " 
  186       "exception not a subclass of std::exception." << endl;
 
  190   reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
 
  191   if (gblSuccess != 1) {
 
  193       *out << 
"factory->createPrec() threw an exception on some process." 
  196     *out << 
"End Result: TEST FAILED" << endl;
 
  205   reduceAll<int, int> (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
 
  206   if (gblSuccess != 1) {
 
  208       *out << 
"The result of factory->createPrec() is null on at least one " 
  211     *out << 
"End Result: TEST FAILED" << endl;
 
  215   Thyra::initializePrec (*factory, thyraA, prec.
ptr ()); 
 
  217   *out << 
"End Result: TEST PASSED" << endl;
 
map_type::local_ordinal_type LO
 
int main(int argc, char *argv[])
 
Tpetra::Map< int, int > map_type
 
Tpetra::CrsMatrix< ST, LO, GO > crs_matrix_type
 
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
 
Tpetra::Vector< ST, LO, GO > vec_type
 
void setParameterList(RCP< ParameterList > const ¶mList)
 
RCP< const LinearOpBase< Scalar > > createConstLinearOp(const RCP< const Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator, const RCP< const VectorSpaceBase< Scalar > > rangeSpace=Teuchos::null, const RCP< const VectorSpaceBase< Scalar > > domainSpace=Teuchos::null)
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
RCP< Thyra::LinearOpWithSolveFactoryBase< double > > createLinearSolveStrategy(const std::string &linearSolveStrategyName) const 
 
bool is_null(const RCP< T > &p)
 
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
 
Teuchos::RCP< const crs_matrix_type > create_matrix(const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
 
Concrete subclass of Thyra::LinearSolverBuilderBase for creating LinearOpWithSolveFactoryBase objects...
 
map_type::global_ordinal_type GO
 
Tpetra::Operator< ST, LO, GO > op_type