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 "Teuchos_CommandLineProcessor.hpp"
14 #include "Teuchos_StandardCatchMacros.hpp"
15 #include "Teuchos_ParameterList.hpp"
16 #include "Teuchos_XMLParameterListCoreHelpers.hpp"
18 #include "newtonRaphson.hpp"
19 #include <boost/math/special_functions/gamma.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  }
49 
50  if (Comm.MyPID()==0){
51  paramList->print(std::cout,2,true,true);
52  }
53 
54  Teuchos::RCP<dirichletStripElongation_StochasticPolyconvexHGO> my_interface = Teuchos::rcp(new dirichletStripElongation_StochasticPolyconvexHGO(Comm,*paramList));
55 
56  std::ifstream parameters_file_1, parameters_file_2, parameters_file_3, parameters_file_4;
57  std::string path = Teuchos::getParameter<std::string>(paramList->sublist("Mesh"), "path_to_gmrf");
58  parameters_file_1.open(path+"w1.txt");
59  parameters_file_2.open(path+"w2.txt");
60  parameters_file_3.open(path+"w3.txt");
61  parameters_file_4.open(path+"w4.txt");
62 
63  unsigned int n_cells_p1_med = 68553;
64  unsigned int n_nodes_p1_med = 16729;
65 
66  int error;
67  std::string path_p1 = Teuchos::getParameter<std::string>(paramList->sublist("Mesh"), "path_to_p1_connectivity");
68  my_interface->get_media(n_cells_p1_med,n_nodes_p1_med,path_p1);
69  if (parameters_file_1.is_open() && parameters_file_2.is_open() && parameters_file_3.is_open() && parameters_file_4.is_open()){
70 
71  for (unsigned nmc=0; nmc<3; ++nmc){
72  for (int i=0; i<n_nodes_p1_med; ++i){
73  parameters_file_1 >> my_interface->w1_gmrf(i);
74  parameters_file_2 >> my_interface->w2_gmrf(i);
75  parameters_file_3 >> my_interface->w3_gmrf(i);
76  parameters_file_4 >> my_interface->w4_gmrf(i);
77  }
78  Teuchos::RCP<newtonRaphson> Newton = Teuchos::rcp(new newtonRaphson(*my_interface,*paramList));
79  Newton->setParameters(*paramList);
80  Newton->Initialization();
81  error = Newton->Solve_with_Aztec(true);
82  if (!error){
83  std::string filename1 = path + "disp_realization" + std::to_string(nmc) + ".mtx";
84  Newton->print_newton_solution(filename1);
85  std::string filename2 = path + "stress_realization" + std::to_string(nmc);
86  my_interface->compute_center_cauchy_stress(*Newton->x,filename2);
87  }
88  }
89  Comm.Barrier();
90  parameters_file_1.close();
91  parameters_file_2.close();
92  parameters_file_3.close();
93  parameters_file_4.close();
94  }
95  else{
96  std::cout << "Couldn't open one of the parameters_file.\n";
97  }
98 
99 #ifdef HAVE_MPI
100  MPI_Finalize();
101 #endif
102 return 0;
103 
104 }
optimParameters nmc
int main(int argc, char *argv[])
Definition: main.cpp:23
for i
Definition: costFunction.m:38