1 #include "Epetra_ConfigDefs.h" 4 #include "Epetra_MpiComm.h" 6 #include "Epetra_SerialComm.h" 9 #include "Teuchos_CommandLineProcessor.hpp" 10 #include "Teuchos_StandardCatchMacros.hpp" 11 #include "Teuchos_ParameterList.hpp" 12 #include "Teuchos_XMLParameterListCoreHelpers.hpp" 15 int main(
int argc,
char *argv[]){
17 std::string xmlInFileName =
"";
18 std::string extraXmlFile =
"";
19 std::string xmlOutFileName =
"paramList.out";
21 Teuchos::CommandLineProcessor clp(
false);
22 clp.setOption(
"xml-in-file",&xmlInFileName,
"The XML file to read into a parameter list");
23 clp.setDocString(
"TO DO.");
25 Teuchos::CommandLineProcessor::EParseCommandLineReturn
26 parse_return = clp.parse(argc,argv);
27 if( parse_return != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL ) {
28 std::cout <<
"\nEnd Result: TEST FAILED" << std::endl;
33 MPI_Init(&argc, &argv);
34 Epetra_MpiComm Comm(MPI_COMM_WORLD);
36 Epetra_SerialComm Comm;
39 Teuchos::RCP<Teuchos::ParameterList> paramList = Teuchos::rcp(
new Teuchos::ParameterList);
40 if(xmlInFileName.length()) {
41 Teuchos::updateParametersFromXmlFile(xmlInFileName, inoutArg(*paramList));
43 paramList->print(std::cout,2,
true,
true);
47 std::string mesh_file = Teuchos::getParameter<std::string>(paramList->sublist(
"Shinozuka"),
"mesh_file");
48 mesh Mesh(Comm,mesh_file);
49 Epetra_Map StandardMap(-1,Mesh.n_local_nodes_without_ghosts,&Mesh.local_nodes_without_ghosts[0],0,Comm);
51 int order = Teuchos::getParameter<int>(paramList->sublist(
"Shinozuka"),
"order");
52 int nmc = Teuchos::getParameter<int>(paramList->sublist(
"Shinozuka"),
"nmc");
53 double L1 = Teuchos::getParameter<double>(paramList->sublist(
"Shinozuka"),
"lx");
54 double L2 = Teuchos::getParameter<double>(paramList->sublist(
"Shinozuka"),
"ly");
55 double L3 = Teuchos::getParameter<double>(paramList->sublist(
"Shinozuka"),
"lz");
57 Teuchos::RCP<shinozuka> RandomField = Teuchos::rcp(
new shinozuka(order,L1,L2,L3));
59 Epetra_Vector V(StandardMap);
60 Epetra_Vector W(StandardMap);
61 Epetra_Vector scdOrderMoment(StandardMap);
64 scdOrderMoment.PutScalar(0.0);
65 double convScdOrderMoment = 0.0;
66 double GRFNorm2 = 0.0;
69 std::cout << std::setw(10) <<
"(||E{V.*V}||)\n";
71 for (
unsigned int j=1;
j<=
nmc; ++
j){
72 RandomField->rng.seed(
j);
73 RandomField->generator(V,Mesh);
75 W.Multiply(1.0,V,V,0.0);
76 scdOrderMoment.Update(1.0/
double(
j),W,(
double(
j)-1.0)/
double(
j));
77 scdOrderMoment.Norm2(&convScdOrderMoment);
81 std::cout << std::setw(10) << convScdOrderMoment/std::sqrt(Mesh.n_nodes) <<
"\n";
84 convScdOrderMoment = convScdOrderMoment/std::sqrt(Mesh.n_nodes);
93 std::string path =
"/Users/brian/Documents/GitHub/Trilinos_results/examples/shinozuka/";
94 int NumTargetElements = 0;
96 NumTargetElements = Mesh.n_nodes;
98 Epetra_Map MapOnRoot(-1,NumTargetElements,0,Comm);
99 Epetra_Export ExportOnRoot(StandardMap,MapOnRoot);
100 Epetra_MultiVector lhs_root(MapOnRoot,
true);
102 lhs_root.PutScalar(0.0);
103 lhs_root.Export(V,ExportOnRoot,Insert);
104 std::string
filename = path +
"shinozuka_gaussian.mtx";
105 int error = EpetraExt::MultiVectorToMatrixMarketFile(filename.c_str(),lhs_root,0,0,
false);
int main(int argc, char *argv[])