47 #include "Epetra_MpiComm.h" 49 #include "Epetra_SerialComm.h" 52 #include "Epetra_Map.h" 53 #include "Epetra_CrsMatrix.h" 54 #include "Epetra_MultiVector.h" 66 int main (
int argc,
char **argv)
69 MPI_Init(&argc, &argv);
70 Epetra_MpiComm Comm(MPI_COMM_WORLD);
72 Epetra_SerialComm Comm;
77 int n = Comm.NumProc() * 4;
78 Epetra_Map Map(
n, 0, Comm);
79 Epetra_MultiVector x(Map, 2); x.Random();
80 Epetra_MultiVector b(Map, 2); x.Random();
81 Epetra_CrsMatrix Matrix(
Copy, Map, 0);
83 for (
int i = 0; i < Map.NumMyElements(); ++i)
87 Matrix.InsertGlobalValues(ii, 1, &one, &ii);
89 Matrix.FillComplete();
92 List.
set(
"int parameter", 10);
93 List.
set(
"double parameter", 10.0);
94 List.
set(
"std::string parameter",
"std::string");
102 std::vector<std::string> Content;
103 Content.push_back(
"This is an example of description");
104 Content.push_back(
"The description is as long as desired,");
105 Content.push_back(
"just put it in a std::vector of strings.");
107 XMLWriter.
Create(
"MyProblem");
108 XMLWriter.
Write(
"Author",
"myself and others");
109 XMLWriter.
Write(
"Date",
"May 2006");
110 XMLWriter.
Write(
"MyMap", Map);
111 XMLWriter.
Write(
"MyMatrix", Matrix);
112 XMLWriter.
Write(
"MyLHS", x);
113 XMLWriter.
Write(
"MyRHS", b);
114 XMLWriter.
Write(
"MyContent", Content);
115 XMLWriter.
Write(
"MyParameters", List);
125 Epetra_CrsMatrix* MyMatrix;
126 Epetra_MultiVector* MyLHS;
127 Epetra_MultiVector* MyRHS;
129 std::vector<std::string> Author;
130 std::vector<std::string> Date;
131 std::vector<std::string> MyContent;
133 XMLReader.
Read(
"Author", Author);
134 XMLReader.
Read(
"Date", Date);
135 XMLReader.
Read(
"MyMap", MyMap);
136 XMLReader.
Read(
"MyMatrix", MyMatrix);
137 XMLReader.
Read(
"MyLHS", MyLHS);
138 XMLReader.
Read(
"MyRHS", MyRHS);
139 XMLReader.
Read(
"MyContent", MyContent);
140 XMLReader.
Read(
"MyParameters", MyParameters);
143 std::cout << *MyMatrix;
146 if (Comm.MyPID() == 0)
148 int Msize = (int) MyContent.size();
149 for (
int i = 0; i < Msize; ++i)
150 std::cout << MyContent[i] << std::endl;
152 std::cout << MyParameters;
153 std::cout <<
"Author = " << Author[0] << std::endl;
154 std::cout <<
"Date = " << Date[0] << std::endl;
166 return(EXIT_SUCCESS);
class XMLWriter: A class for writing Trilinos objects to XML files.
void Read(const std::string &Label, Epetra_Map *&Map)
Reads the Epetra_Map stored with label Label.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
int main(int argc, char **argv)
void Create(const std::string &Label)
Creates the file, giving Label to the whole object.
void Close()
Closes the file. No Write operations can follow.
void Write(const std::string &Label, const Epetra_Map &Map)
Writes an Epetra_Map using label Label.
class XMLReader: A class for reading Epetra objects stored in XML files.