TEUCHOS_UNIT_TEST( DefaultAddedLinearOp, defaultConstruct ) { typedef double Scalar; const RCP<DefaultAddedLinearOp<Scalar> > M = defaultAddedLinearOp<Scalar>(); TEST_ASSERT(is_null(M->range())); TEST_ASSERT(is_null(M->domain())); TEST_ASSERT(isFullyUninitialized(*M)); TEST_ASSERT(!isPartiallyInitialized(*M)); TEST_ASSERT(!isFullyInitialized(*M)); # if defined(HAVE_GCC_ABI_DEMANGLE) && defined(HAVE_TEUCHOS_DEMANGLE) const std::string M_description = M->description(); TEST_EQUALITY_CONST(M_description, "Thyra::DefaultAddedLinearOp<double>{numOps=0,rangeDim=0,domainDim=0}"); { std::ostringstream describe_msg; describe_msg << "'"; M->describe(*fancyOStream(rcpFromRef(describe_msg)), Teuchos::VERB_LOW); describe_msg << "'"; std::ostringstream expected_msg; expected_msg << "' " << M_description << "\n'"; TEST_EQUALITY_CONST( describe_msg.str(), expected_msg.str() ); } { std::ostringstream describe_msg; describe_msg << "'"; M->describe(*fancyOStream(rcpFromRef(describe_msg)), Teuchos::VERB_EXTREME); describe_msg << "'"; std::ostringstream expected_msg; expected_msg << "' " << M_description << "\n" << " Constituent LinearOpBase objects for M = Op[0]*...*Op[numOps-1]:\n'"; TEST_EQUALITY_CONST( describe_msg.str(), expected_msg.str() ); } # endif // defined(HAVE_GCC_ABI_DEMANGLE) && defined(HAVE_TEUCHOS_DEMANGLE) }
static void run(Teuchos::ParameterList &myMachPL, const Teuchos::RCP<const Teuchos::Comm<int> > &comm, const Teuchos::RCP<Node> &node) { using std::endl; ThreadedBlasKiller<Node>::kill(); typedef double Scalar; typedef int LO; //LocalOrdinal typedef int GO; //GlobalOrdinal typedef Tpetra::MultiVector<Scalar,LO,GO,Node> TMV; typedef Tpetra::Operator<Scalar,LO,GO,Node> TOP; typedef Belos::LinearProblem<Scalar,TMV,TOP> BLP; typedef Belos::SolverManager<Scalar,TMV,TOP> BSM; typedef Belos::MultiVecTraits<Scalar,TMV> BMVT; BMVT::mvTimesMatAddMvTimer_ = Teuchos::TimeMonitor::getNewTimer("Belos/Tpetra::MvTimesMatAddMv()"); BMVT::mvTransMvTimer_ = Teuchos::TimeMonitor::getNewTimer("Belos/Tpetra::MvTransMv()"); const bool IAmRoot = (comm->getRank() == 0); RCP<FancyOStream> fos = fancyOStream(rcpFromRef(std::cout)); fos->setShowProcRank(true); *fos << "Running test with Node == " << Teuchos::typeName(*node) << " on rank " << comm->getRank() << "/" << comm->getSize() << endl; int myWeight = myMachPL.get<int>("Node Weight",1); // The build_problem function is located in build_problem.hpp. // Note that build_problem calls build_precond and sets a preconditioner on the // linear-problem, if a preconditioner is specified. RCP<BLP> problem = build_problem<Scalar,LO,GO,Node>(BelosTpetraHybridDriverTest::plTestParams, comm, node, myWeight); // The build_solver function is located in build_solver.hpp: RCP<BSM> solver = build_solver<Scalar,TMV,TOP>(comm, BelosTpetraHybridDriverTest::plTestParams, problem); if (IAmRoot) *fos << solver->description() << endl; NodeDetails<Node>::clear(node); Belos::ReturnType ret = solver->solve(); if (IAmRoot) { *fos << "Converged in " << solver->getNumIters() << " iterations." << endl; } // RCP<TMV> R = rcp(new TMV(*problem->getRHS())); // problem->computeCurrResVec(&*R, &*problem->getLHS(), &*problem->getRHS()); // Array<ScalarTraits<Scalar>::magnitudeType> norms(R->getNumVectors()); // R->norm2(norms); // if (norms.size() < 1) { // throw std::runtime_error("ERROR: norms.size()==0 indicates R->getNumVectors()==0."); // } // if (IAmRoot) { // *fos << "2-Norm of 0th residual vec: " << norms[0] << endl; // } if (IAmRoot) { *fos << endl; } Teuchos::TimeMonitor::summarize(*fos,true,false,false); if (IAmRoot) { *fos << endl; } // print node details for (int i=0; i<comm->getSize(); ++i) { if (comm->getRank() == i) { NodeDetails<Node>::printDetails(fos,node.getConst()); } comm->barrier(); } }