Optika GUI Toolik  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
example/CustomFunctionExample/main.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Optika: A Tool For Developing Parameter Obtaining GUIs
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com)
38 //
39 // ***********************************************************************
40 // @HEADER
43 #include "Teuchos_Array.hpp"
44 #include "Teuchos_Version.hpp"
45 #include "Optika_GUI.hpp"
47 #include "Teuchos_FancyOStream.hpp"
65 
66 int main(int argc, char* argv[])
67 {
88  using Teuchos::RCP;
91  using Teuchos::tuple;
92  using Teuchos::Array;
93  using Teuchos::rcp;
94  RCP<ParameterList> My_List = rcp(new ParameterList);
95 
96  My_List->set(
97  "Max Iters",
98  1550,
99  "Determines the maximum number of iterations in the solver");
100  My_List->set(
101  "Tolerance",
102  1e-10,
103  "The tolerance used for the convergence check");
104 
105  RCP<StringValidator> solverValidator =
106  rcp(new StringValidator(tuple<std::string>("GMRES", "CG", "TFQMR")));
107  My_List->set(
108  "Solver",
109  "GMRES",
110  "The type of solver to use.",
111  solverValidator);
112 
113  Array<double> doubleArray( 10, 0.0 );
114  My_List->set(
115  "Initial Guess",
116  doubleArray,
117  "The initial guess as a RCP to an array object.");
118 
119  ParameterList& Prec_List = My_List->sublist(
120  "Preconditioner",
121  false,
122  "Sublist that defines the preconditioner.");
123 
124  Prec_List.set("Type", "ILU", "The tpye of preconditioner to use");
125  Prec_List.set(
126  "Drop Tolerance",
127  1e-3,
128  "The tolerance below which entries from the "
129  "factorization are left out of the factors.");
130 
138 
139  RCP<Teuchos::FancyOStream> out =
140  Teuchos::VerboseObjectBase::getDefaultOStream();
141  Teuchos::writeParameterListToXmlOStream(*My_List, *out);
142 
143  return 0;
144 }
145 
158  std::cout << "The Solver Choosen was: " <<
159  currentParams->get<std::string>("Solver") << std::endl;
160 
161  std::cout << "The Tolerence choosen was: " <<
162  currentParams->get<double>("Tolerance") << std::endl;
163 
164  std::cout << "The Preconditioner type was set to: "
165  << currentParams->sublist("Preconditioner").get<std::string>("Type") <<
166  std::endl;
167 }
168 
T & get(ParameterList &l, const std::string &name)
A collection of functions and an Object that serve as the primary interface to the Optika package all...
void customFunction(Teuchos::RCP< const Teuchos::ParameterList > currentParams)
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void getInput(RCP< ParameterList > validParameters, RCP< DependencySheet > dependencySheet, void(*customFunc)(RCP< const ParameterList >))
Retreives the input for a Teuchos Parameter List using a GUI. Note the Parameter List will be edited...
Definition: Optika_GUI.cpp:47
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int main(int argc, char *argv[])