Trilinos based (stochastic) FEM solvers
main.cpp
Go to the documentation of this file.
1 #include "Epetra_ConfigDefs.h"
2 #ifdef HAVE_MPI
3 #include "mpi.h"
4 #include "Epetra_MpiComm.h"
5 #else
6 #include "Epetra_SerialComm.h"
7 #endif
8 
9 #include "Teuchos_CommandLineProcessor.hpp"
10 #include "Teuchos_StandardCatchMacros.hpp"
11 #include "Teuchos_ParameterList.hpp"
12 #include "Teuchos_XMLParameterListCoreHelpers.hpp"
13 
14 #include <boost/random/mersenne_twister.hpp>
15 #include <boost/random/uniform_real_distribution.hpp>
16 #include <boost/math/special_functions/erf.hpp>
17 #include <boost/random/normal_distribution.hpp>
18 #include <boost/math/special_functions/gamma.hpp>
19 #include <boost/math/special_functions/beta.hpp>
20 
21 int main(int argc, char *argv[]){
22 
23  std::string xmlInFileName = "";
24  std::string extraXmlFile = "";
25  std::string xmlOutFileName = "paramList.out";
26 
27  Teuchos::CommandLineProcessor clp(false);
28  clp.setOption("xml-in-file",&xmlInFileName,"The XML file to read into a parameter list");
29  clp.setDocString("TO DO.");
30 
31  Teuchos::CommandLineProcessor::EParseCommandLineReturn
32  parse_return = clp.parse(argc,argv);
33  if( parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) {
34  std::cout << "\nEnd Result: TEST FAILED" << std::endl;
35  return parse_return;
36  }
37 
38 #ifdef HAVE_MPI
39  MPI_Init(&argc, &argv);
40  Epetra_MpiComm Comm(MPI_COMM_WORLD);
41 #else
42  Epetra_SerialComm Comm;
43 #endif
44 
45  Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::rcp(new Teuchos::ParameterList);
46  if(xmlInFileName.length()) {
47  Teuchos::updateParametersFromXmlFile(xmlInFileName, inoutArg(*paramList));
48  if (Comm.MyPID()==0){
49  paramList->print(std::cout,2,true,true);
50  }
51  }
52 
53  double a = -6.0;
54  double b = 6.0;
55  int n = 10;
56  double v;
57 
58  double alpha = 1.0/(0.1*0.1);
59  double beta = 1771.0*0.1*0.1;
60  for (int i=0; i<n; ++i){
61  v = a + (b-a)*double(i)/double(n-1);
62  double erfx = boost::math::erf<double>(v/std::sqrt(2.0));
63  double y = (1.0/2.0)*(1.0 + erfx);
64  double yinv = boost::math::gamma_p_inv<double,double>(alpha,y);
65  double g = yinv*beta;
66 
67  std::cout << v << std::setw(15) << g << "\n";
68  }
69 
70  /*double mean = 0.0;
71  double stan = 1.0;
72  boost::random::normal_distribution<> w(mean,stan);
73  boost::random::mt19937 rng;
74  rng.seed(std::time(0));
75  for (unsigned int i=0; i<10; ++i){
76  double x = w(rng);
77  double erfarg = (x-mean)/(stan*std::sqrt(2.0));
78  double erfx = boost::math::erf<double>(erfarg);
79  double y = (1.0/2.0)*(1.0 + erfx);
80  double yinv = boost::math::gamma_p_inv<double,double>(1.0/(0.1*0.1),y);
81  double z = yinv*10.0*0.1*0.1;
82  double z2 = boost::math::ibeta_inv<double,double,double>(5.0,4.0,y);
83  std::cout << x << std::setw(20) << y << std::setw(20) << z << std::setw(20) << z2 << "\n";
84  }*/
85 
86 
87 #ifdef HAVE_MPI
88  MPI_Finalize();
89 #endif
90 return 0;
91 
92 }
int main(int argc, char *argv[])
Definition: main.cpp:23
modelParameters beta
Definition: run_station15.m:10
for i
Definition: costFunction.m:38