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  Teuchos::RCP<nrl_PCA_Likelihood> RG =
48  Teuchos::rcp(new nrl_PCA_Likelihood(Comm,*paramList));
49 
50  Epetra_IntSerialDenseVector seeds(5);
51  Epetra_SerialDenseVector mean_parameters(5);
52  Epetra_SerialDenseVector exponents(2);
53  Epetra_SerialDenseVector correlation_lengths(2);
54  Epetra_SerialDenseVector coeff_of_variation(4);
55  Epetra_SerialDenseVector plyagls(4);
56 
57  //mean values of the random parameters G_1(x),...,G_5(x)
58  mean_parameters(0) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu1");
59  mean_parameters(1) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu2");
60  mean_parameters(2) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu3");
61  mean_parameters(3) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu4");
62  mean_parameters(4) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"mu5");
63  //mean_parameters.Scale(1.0e3);
64  //deterministic exponents beta_4 and beta_5
65  exponents(0) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"beta4");
66  exponents(1) = Teuchos::getParameter<double>(paramList->sublist("TIMooney"),"beta5");
67  //correlation lengths of the Gaussian random field
68  correlation_lengths(0) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"lx");
69  correlation_lengths(1) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"ly");
70  //coefficients of variation of the random parameters G_1(x),...,G_4(x)
71  coeff_of_variation(0) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta1");
72  coeff_of_variation(1) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta2");
73  coeff_of_variation(2) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta3");
74  coeff_of_variation(3) = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"),"delta4");
75  //ply angle
76  plyagls(0) = 15.0;
77  plyagls(1) = 30.0;
78  plyagls(2) = 60.0;
79  plyagls(3) = 75.0;
80 
81  int nmc = Teuchos::getParameter<int>(paramList->sublist("Shinozuka"),"nmc");
82 
83  for (unsigned int i=0; i<4; ++i){
84  for (unsigned int j=0; j<nmc; ++j){
85  seeds(0) = 5*(j+i*nmc)+0;
86  seeds(1) = 5*(j+i*nmc)+1;
87  seeds(2) = 5*(j+i*nmc)+2;
88  seeds(3) = 5*(j+i*nmc)+3;
89  seeds(4) = 5*(j+i*nmc)+4;
90  int flag = RG->rnd(j ,
91  seeds ,
92  mean_parameters ,
93  exponents ,
94  correlation_lengths,
95  coeff_of_variation ,
96  plyagls(i) ,
97  false ,
98  true ,
99  true ,
100  false );
101  }
102  }
103 
104 #ifdef HAVE_MPI
105  MPI_Finalize();
106 #endif
107 return 0;
108 }
for j
Definition: costFunction.m:42
optimParameters nmc
int main(int argc, char *argv[])
Definition: main.cpp:23
for i
Definition: costFunction.m:38