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"
17 #include "shinozukapp_2d.hpp"
18 
19 int main(int argc, char *argv[]){
20 
21  std::string xmlInFileName = "";
22  std::string extraXmlFile = "";
23  std::string xmlOutFileName = "paramList.out";
24 
25  Teuchos::CommandLineProcessor clp(false);
26  clp.setOption("xml-in-file",&xmlInFileName,"The XML file to read into a parameter list");
27  clp.setDocString("TO DO.");
28 
29  Teuchos::CommandLineProcessor::EParseCommandLineReturn
30  parse_return = clp.parse(argc,argv);
31  if( parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) {
32  std::cout << "\nEnd Result: TEST FAILED" << std::endl;
33  return parse_return;
34  }
35 
36 #ifdef HAVE_MPI
37  MPI_Init(&argc, &argv);
38  Epetra_MpiComm Comm(MPI_COMM_WORLD);
39 #else
40  Epetra_SerialComm Comm;
41 #endif
42 
43  Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::rcp(new Teuchos::ParameterList);
44  if(xmlInFileName.length()) {
45  Teuchos::updateParametersFromXmlFile(xmlInFileName, inoutArg(*paramList));
46  if (Comm.MyPID()==0){
47  paramList->print(std::cout,2,true,true);
48  }
49  }
50 
51  std::string mesh_file = Teuchos::getParameter<std::string>(paramList->sublist("Shinozuka"),"mesh_file");
52  mesh Mesh(Comm,mesh_file,1.0);
53  Epetra_Map StandardMap(-1,Mesh.n_local_nodes_without_ghosts,&Mesh.local_nodes_without_ghosts[0],0,Comm);
54 
55  int order = Teuchos::getParameter<int>(paramList->sublist("Shinozuka"), "order");
56  double l1 = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"), "lx");
57  double l2 = Teuchos::getParameter<double>(paramList->sublist("Shinozuka"), "ly");
58  double pa = 2.0*M_PI*60.0/360.0;
59 
60  Epetra_MultiVector V(StandardMap,5,"true");
61 
62  for (int i=0; i<5; ++i){
63  Teuchos::RCP<shinozuka_2d> RandomField = Teuchos::rcp(new shinozuka_2d(order,l1,l2));
64  RandomField->rotation = pa;
65  //Epetra_MultiVector V(StandardMap,1,"true");
66 
67  RandomField->rng.seed(i);
68  RandomField->generator(*V(i),Mesh);
69  }
70 
71  std::string path = "/home/s/staber/Trilinos_results/nrl/shinozuka_2d/";
72  int NumTargetElements = 0;
73  if (Comm.MyPID()==0){
74  NumTargetElements = Mesh.n_nodes;
75  }
76  Epetra_Map MapOnRoot(-1,NumTargetElements,0,Comm);
77  Epetra_Export ExportOnRoot(StandardMap,MapOnRoot);
78  Epetra_MultiVector lhs_root(MapOnRoot,5,true);
79 
80  lhs_root.PutScalar(0.0);
81  lhs_root.Export(V,ExportOnRoot,Insert);
82  std::string filename = path + "gaussian_fields_for_eng_constants.mtx";
83  int error = EpetraExt::MultiVectorToMatrixMarketFile(filename.c_str(),lhs_root,0,0,false);
84 
85 #ifdef HAVE_MPI
86  MPI_Finalize();
87 #endif
88 return 0;
89 
90 }
Definition: meshpp.hpp:49
filename
Definition: costFunction.m:44
int main(int argc, char *argv[])
Definition: main.cpp:23
for i
Definition: costFunction.m:38