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_RCP.hpp"
14 #include "Ifpack.h"
15 #include "Ifpack_AdditiveSchwarz.h"
16 #include "BelosLinearProblem.hpp"
17 #include "BelosBlockGmresSolMgr.hpp"
18 #include "BelosEpetraAdapter.hpp"
19 #include <BelosSolverFactory.hpp>
20 #include "BelosBlockGmresSolMgr.hpp"
21 #include "Teuchos_StandardCatchMacros.hpp"
22 #include "Teuchos_ParameterList.hpp"
23 #include "Teuchos_XMLParameterListCoreHelpers.hpp"
24 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
25 #include "asmeSBVP.hpp"
26 
27 int main(int argc, char *argv[]){
28 
29  std::string xmlInFileName = "";
30 
31  Teuchos::CommandLineProcessor clp(false);
32  clp.setOption("xml-in-file",&xmlInFileName,"The XML file to read into a parameter list");
33  clp.setDocString("TO DO.");
34 
35  Teuchos::CommandLineProcessor::EParseCommandLineReturn
36  parse_return = clp.parse(argc,argv);
37  if( parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) {
38  std::cout << "\nEnd Result: TEST FAILED" << std::endl;
39  return parse_return;
40  }
41 
42 #ifdef HAVE_MPI
43 MPI_Init(&argc, &argv);
44  Epetra_MpiComm Comm(MPI_COMM_WORLD);
45 #else
46  Epetra_SerialComm Comm;
47 #endif
48 
49  Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::rcp(new Teuchos::ParameterList);
50  if(xmlInFileName.length()) {
51  Teuchos::updateParametersFromXmlFile(xmlInFileName, inoutArg(*paramList));
52  }
53 
54  if (Comm.MyPID()==0){
55  paramList->print(std::cout,2,true,true);
56  }
57 
58  Teuchos::RCP<asmeSBVP> interface = Teuchos::rcp(new asmeSBVP(Comm,*paramList));
59 
60  double deltaN = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"), "deltaN");
61  double deltaM4 = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"), "deltaM4");
62  double deltaM5 = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"), "deltaM5");
63  std::string path = Teuchos::getParameter<std::string>(paramList->sublist("Mesh"), "path");
64 
65  interface->_deltaN = deltaN;
66  interface->_deltaM4 = deltaM4;
67  interface->_deltaM5 = deltaM5;
68 
69  int * seed = new int [5];
70  double displacement = 1.0;
71 
72  for (unsigned int j=0; j<5000; ++j){
73  seed[0] = 5*j; seed[1] = 5*j+1; seed[2] = 5*j+2; seed[3] = 5*j+3; seed[4] = 5*j+4;
74  interface->solveOneRealization(displacement,seed);
75  std::string path1 = path + std::to_string(j) + ".mtx";
76  std::string path2 = path + std::to_string(j);
77  interface->print_solution(path1);
78  interface->recover_cauchy_stress(path2,seed);
79  interface->compute_deformation(*interface->solution,path2,true,false);
80  }
81 
82 #ifdef HAVE_MPI
83  MPI_Finalize();
84 #endif
85 return 0;
86 
87 }
for j
Definition: costFunction.m:42
int main(int argc, char *argv[])
Definition: main.cpp:23