Optika GUI Toolik Version of the Day
example/CustomFunctionExample/main.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //         Optika: A Tool For Developing Parameter Obtaining GUIs
00005 //                Copyright (2009) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the 
00008 // U.S. Government retains certain rights in this software.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 #include "Teuchos_ParameterList.hpp"
00029 #include "Teuchos_StandardParameterEntryValidators.hpp"
00030 #include "Teuchos_Array.hpp"  
00031 #include "Teuchos_Version.hpp"
00032 #include "Optika_GUI.hpp"
00033 #include "Teuchos_XMLParameterListHelpers.hpp"
00034 #include "Teuchos_FancyOStream.hpp"
00035 #include "Teuchos_VerboseObject.hpp"
00051 void customFunction(Teuchos::RCP<const Teuchos::ParameterList> currentParams);
00052 
00053 int main(int argc, char* argv[])
00054 {
00075   using Teuchos::RCP;
00076   using Teuchos::ParameterList;
00077   using Teuchos::StringValidator;
00078   using Teuchos::tuple;
00079   using Teuchos::Array;
00080   using Teuchos::rcp;
00081   RCP<ParameterList> My_List = rcp(new ParameterList);
00082 
00083   My_List->set(
00084     "Max Iters", 
00085     1550, 
00086     "Determines the maximum number of iterations in the solver");
00087   My_List->set(
00088     "Tolerance", 
00089     1e-10, 
00090     "The tolerance used for the convergence check");
00091   
00092   RCP<StringValidator> solverValidator = 
00093      rcp(new StringValidator(tuple<std::string>("GMRES", "CG", "TFQMR")));
00094   My_List->set( 
00095     "Solver", 
00096     "GMRES", 
00097     "The type of solver to use.", 
00098     solverValidator);
00099 
00100   Array<double> doubleArray( 10, 0.0 );
00101   My_List->set(
00102     "Initial Guess", 
00103     doubleArray, 
00104     "The initial guess as a RCP to an array object.");
00105 
00106   ParameterList& Prec_List = My_List->sublist(
00107     "Preconditioner",
00108     false,
00109     "Sublist that defines the preconditioner.");
00110 
00111   Prec_List.set("Type", "ILU", "The tpye of preconditioner to use");
00112   Prec_List.set(
00113     "Drop Tolerance",
00114     1e-3,
00115     "The tolerance below which entries from the "
00116     "factorization are left out of the factors.");
00117 
00124   Optika::getInput(My_List, Teuchos::null, &customFunction);
00125 
00126   RCP<Teuchos::FancyOStream> out = 
00127     Teuchos::VerboseObjectBase::getDefaultOStream();
00128   Teuchos::writeParameterListToXmlOStream(*My_List, *out);
00129   
00130   return 0;
00131 }
00132 
00144 void customFunction(Teuchos::RCP<const Teuchos::ParameterList> currentParams){
00145   std::cout << "The Solver Choosen was: " << 
00146     currentParams->get<std::string>("Solver") << std::endl;
00147 
00148   std::cout << "The Tolerence choosen was: " << 
00149     currentParams->get<double>("Tolerance") << std::endl; 
00150 
00151   std::cout << "The Preconditioner type was set to: " 
00152     << currentParams->sublist("Preconditioner").get<std::string>("Type") << 
00153     std::endl;
00154 }
00155 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines