Tpetra Matrix/Vector Services Version of the Day
RTIInlineCG.cpp
00001 #include "RTIInlineCG.hpp"
00002 
00003 int main(int argc, char *argv[])
00004 {
00005   using Tpetra::global_size_t;
00006   using Teuchos::RCP;
00007   using Teuchos::rcp;
00008   using Teuchos::Comm;
00009   using Teuchos::ParameterList;
00010 
00011   // 
00012   // Get the communicator
00013   //
00014   Teuchos::oblackholestream blackhole;
00015   Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
00016   auto comm = Tpetra::DefaultPlatform::getDefaultPlatform().getComm();
00017   const int myImageID = comm->getRank();
00018 
00019   //
00020   // Get example parameters from command-line processor
00021   //  
00022   bool verbose = (myImageID==0);
00023   std::string xmlfile;
00024   std::string machineFile;
00025 
00026   Teuchos::CommandLineProcessor cmdp(false,true);
00027   cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
00028   cmdp.setOption("param-file", &xmlfile,"XML file for solver parameters");
00029   cmdp.setOption("machine-file",&machineFile,"Filename for XML machine description file.");
00030   if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
00031     return -1;
00032   }
00033 
00034   // 
00035   // read machine file and initialize platform
00036   // 
00037   RCP<Teuchos::ParameterList> machinePL = Teuchos::parameterList();
00038   std::string defaultMachine(
00039     " <ParameterList>                                                               "
00040     "   <ParameterList name='%1=0'>                                                 "
00041     "     <Parameter name='NodeType'     type='string' value='Kokkos::SerialNode'/> "
00042     "   </ParameterList>                                                            "
00043     " </ParameterList>                                                              "
00044   );
00045   Teuchos::updateParametersFromXmlString(defaultMachine,machinePL.getRawPtr());
00046   if (machineFile != "") Teuchos::updateParametersFromXmlFile(machineFile,machinePL.getRawPtr());
00047 
00048   // 
00049   // create the platform object
00050   // 
00051   Tpetra::HybridPlatform platform(comm,*machinePL);
00052 
00053   //
00054   // instantiate a driver on the scalar stack
00055   //
00056   CGDriver<double> driver;
00057   // hand output stream to driver
00058   if (verbose) driver.out = Teuchos::getFancyOStream(Teuchos::rcp(&std::cout,false));
00059   else         driver.out = Teuchos::getFancyOStream(Teuchos::rcp(new Teuchos::oblackholestream()));
00060 
00061   //
00062   // get the solver parameters
00063   // 
00064   RCP<Teuchos::ParameterList> params = Teuchos::parameterList();
00065   // default solver stack parameters
00066   std::string xmlString(
00067     " <ParameterList>                                                  \n"
00068     "   <Parameter name='tolerance' value='5e-15' type='double'/>      \n"
00069     "   <Parameter name='verbose' value='1' type='int'/>               \n"
00070     "   <Parameter name='kappa' value='100' type='double'/>            \n"
00071     "   <Parameter name='size'  value='100' type='int'/>               \n"
00072     "   <Parameter name='numIters' value='100' type='int'/>            \n"
00073     " </ParameterList>                                                 \n"
00074   );
00075   Teuchos::updateParametersFromXmlString(xmlString,params.getRawPtr());
00076   if (xmlfile != "") Teuchos::updateParametersFromXmlFile(xmlfile,params.getRawPtr());
00077   // hand solver parameters to driver
00078   driver.params = params;
00079 
00080   // 
00081   // run the driver
00082   // 
00083   platform.runUserCode(driver);
00084 
00085   //
00086   // Print result
00087   if (driver.testPassed) {
00088     *driver.out << "End Result: TEST PASSED" << std::endl;
00089   }
00090 
00091   return 0;
00092 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines