Trilinos based (stochastic) FEM solvers
main.cpp
Go to the documentation of this file.
1 /*
2 Brian Staber (brian.staber@gmail.com)
3 */
4 
5 #include "Epetra_ConfigDefs.h"
6 #ifdef HAVE_MPI
7 #include "mpi.h"
8 #include "Epetra_MpiComm.h"
9 #else
10 #include "Epetra_SerialComm.h"
11 #endif
12 
13 #include "nrl_PCA_Likelihood.hpp"
14 #include <boost/random/mersenne_twister.hpp>
15 #include <boost/random/normal_distribution.hpp>
16 #include <boost/random/uniform_real_distribution.hpp>
17 #include <boost/math/special_functions/gamma.hpp>
18 
19 int main(int argc, char *argv[]){
20 
21  std::string xmlInFileName = "";
22 
23  Teuchos::CommandLineProcessor clp(false);
24  clp.setOption("xml-in-file",&xmlInFileName,"The XML file to read into a parameter list");
25  clp.setDocString("Compilation: make -f Makefile.os\n"
26  "Run: mpirun -np 28 ./trilinos_mpi --xml-in-file='nrl.aztec.linux.xml'");
27 
28  Teuchos::CommandLineProcessor::EParseCommandLineReturn
29  parse_return = clp.parse(argc,argv);
30  if( parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) {
31  std::cout << "\nEnd Result: TEST FAILED" << std::endl;
32  return parse_return;
33  }
34 
35 #ifdef HAVE_MPI
36  MPI_Init(&argc, &argv);
37  Epetra_MpiComm Comm(MPI_COMM_WORLD);
38 #else
39  Epetra_SerialComm Comm;
40 #endif
41 
42  Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::rcp(new Teuchos::ParameterList);
43  if(xmlInFileName.length()){
44  Teuchos::updateParametersFromXmlFile(xmlInFileName, inoutArg(*paramList));
45  }
46 
47  /*if (Comm.MyPID()==0){
48  std::cout << "****************\n";
49  std::cout << "Hyperparameters:\n";
50  std::cout << paramList->sublist("TIMooney");
51  std::cout << paramList->sublist("Shinozuka");
52  std::cout << "****************\n";
53  }*/
54 
55  Teuchos::RCP<nrl_PCA_Likelihood> RG =
56  Teuchos::rcp(new nrl_PCA_Likelihood(Comm,*paramList));
57 
58  Epetra_IntSerialDenseVector seeds(5);
59  Epetra_SerialDenseVector mean_parameters(5);
60  Epetra_SerialDenseVector exponents(2);
61  Epetra_SerialDenseVector correlation_lengths(2);
62  Epetra_SerialDenseVector coeff_of_variation(4);
63  Epetra_SerialDenseVector plyagls(4);
64 
65  //mean values of the random parameters G_1(x),...,G_5(x)
66  mean_parameters(0) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu1");
67  mean_parameters(1) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu2");
68  mean_parameters(2) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu3");
69  mean_parameters(3) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu4");
70  mean_parameters(4) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu5");
71  //mean_parameters.Scale(1.0e3);
72  //deterministic exponents beta_4 and beta_5
73  exponents(0) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"beta4");
74  exponents(1) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"beta5");
75  //correlation lengths of the Gaussian random field
76  correlation_lengths(0) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"lx");
77  correlation_lengths(1) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"ly");
78  //coefficients of variation of the random parameters G_1(x),...,G_4(x)
79  coeff_of_variation(0) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta1");
80  coeff_of_variation(1) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta2");
81  coeff_of_variation(2) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta3");
82  coeff_of_variation(3) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta4");
83  //ply angle
84  plyagls(0) = 15.0;
85  plyagls(1) = 30.0;
86  plyagls(2) = 60.0;
87  plyagls(3) = 75.0;
88 
89  int nmc = Teuchos::getParameter<int>(paramList->sublist("Shinozuka"),"nmc");
90 
91  for (unsigned int i=0; i<4; ++i){
92  for (unsigned int j=0; j<nmc; ++j){
93  seeds(0) = 5*(j+i*nmc)+0;
94  seeds(1) = 5*(j+i*nmc)+1;
95  seeds(2) = 5*(j+i*nmc)+2;
96  seeds(3) = 5*(j+i*nmc)+3;
97  seeds(4) = 5*(j+i*nmc)+4;
98  int flag = RG->rnd(j ,
99  seeds ,
100  mean_parameters ,
101  exponents ,
102  correlation_lengths,
103  coeff_of_variation ,
104  plyagls(i) ,
105  false ,
106  false ,
107  false ,
108  true );
109  }
110  }
111 
112 #ifdef HAVE_MPI
113  MPI_Finalize();
114 #endif
115 return 0;
116 }
for j
Definition: costFunction.m:42
optimParameters nmc
int main(int argc, char *argv[])
Definition: main.cpp:23
for i
Definition: costFunction.m:38