EpetraExt::XMLWriter Class Reference

class XMLWriter: A class for writing Trilinos objects to XML files. More...

#include <EpetraExt_XMLWriter.h>

List of all members.

Constructor and destructor.

 XMLWriter (const Epetra_Comm &Comm, const string &FileName)
 ctor
 ~XMLWriter ()
 dtor
void Create (const string &Label)
 Creates the file, giving Label to the whole object.
void Close ()
 Closes the file. No Write operations can follow.

Read operations

void Write (const string &Label, const Epetra_Map &Map)
 Writes an Epetra_Map using label Label.
void Write (const string &Label, const Epetra_RowMatrix &Matrix)
 Writes an Epetra_RowMatrix using label Label.
void Write (const string &Label, const Epetra_MultiVector &MultiVector)
 Writes an Epetra_MultiVector using label Label.
void Write (const string &Label, const vector< string > &Content)
 Writes the vector of string's using label Label.
void Write (const string &Label, const string &Text)
 Writes input string using label Label.
void Write (const string &Label, Teuchos::ParameterList &List)
 Writes a Teuchos::ParameterList using label Label.

Private Attributes

const Epetra_CommComm_
 Epetra communicator.
string FileName_
 Name of the file.
bool IsOpen_
 If true, the file has been successfully opened.


Detailed Description

class XMLWriter: A class for writing Trilinos objects to XML files.

Class EpetraExt::XMLWriter writes several Trilinos objects in an XML-compatible format. The list of supported objects contains:

All objects can be read and written, with the exception of Epetra_RowMatrix objects, that can only be written to files.

An example of usage is reported in file epetraext/example/inout/XML_IO.cpp.

Writing objects goes as follows. Let Map, Matrix, LHS and RHS an Epetra_Map, Epetra_CrsMatrix, and two Epetra_MultiVector's, respectively. First, we define an XMLWriter object

EpetraExt::XMLWriter XMLWriter(Comm, "data.xml");
and we open the file using MyProblem label:
XMLWriter.Create("MyProblem");
Writing objects simply goes as
XMLWriter.Write("MyMap", Map);
XMLWriter.Write("MyMatrix", Matrix);
XMLWriter.Write("MyLHS", LHS);
XMLWriter.Write("MyRHS", RHS);
A Teuchos::ParameterList (List), a string, and a vector<string> can be written as
XMLWriter.Write("MyParameters", List);
XMLWriter.Write("Author", "myself and others");
XMLWriter.Write("Date", "May 2006");
Finally, we close the file
XMLWriter.Close();
Note that only processor 0 writes the Teuchos::ParameterList, string, and vector<string>.

The written file is as follows:

<ObjectCollection Label="MyProblem">
<Text Label="Author">
myself and others
</Text>
<Text Label="Date">
May 2006
</Text>
<Map Label="MyMap" NumElements="4" IndexBase="0" NumProc="1" ElementsOnProc0="4">
<Proc ID="0">
0
1
2
3
</Proc>
</Map>
<PointMatrix Label="MyMatrix" Rows="4" Columns="4" Nonzeros="4" Type="double" StartingIndex="0">
0 0 1
1 1 1
2 2 1
3 3 1
</PointMatrix>
<MultiVector Label="MyLHS" Length="4" NumVectors="2" Type="double">
-0.232996 -0.893077 
0.0388327 0.0594004 
0.661931 0.342299 
-0.930856 -0.984604 
</MultiVector>
<MultiVector Label="MyRHS" Length="4" NumVectors="2" Type="double">
0 0 
0 0 
0 0 
0 0 
</MultiVector>
<Text Label="MyContent">
This is an example of description
The description is as long as desired,
just put it in a vector of strings.
</Text>
<List Label="MyParameters">
<ParameterList>
<Parameter name="double parameter" type="double" value="10"/>
<Parameter name="int parameter" type="int" value="10"/>
<Parameter name="string parameter" type="string" value="string"/>
</ParameterList>
</List>
</ObjectCollection>

This class requires Teuchos to be configured with the option --enable-teuchos-expat.

Author:
Marzio Sala, D-INFK/ETHZ
Date:
Last updated on 10-May-06.

Definition at line 124 of file EpetraExt_XMLWriter.h.


Constructor & Destructor Documentation

EpetraExt::XMLWriter::XMLWriter const Epetra_Comm Comm,
const string &  FileName
 

ctor

Definition at line 21 of file EpetraExt_XMLWriter.cpp.

EpetraExt::XMLWriter::~XMLWriter  )  [inline]
 

dtor

Definition at line 132 of file EpetraExt_XMLWriter.h.


Member Function Documentation

void EpetraExt::XMLWriter::Create const string &  Label  ) 
 

Creates the file, giving Label to the whole object.

Definition at line 29 of file EpetraExt_XMLWriter.cpp.

void EpetraExt::XMLWriter::Close  ) 
 

Closes the file. No Write operations can follow.

Definition at line 42 of file EpetraExt_XMLWriter.cpp.

void EpetraExt::XMLWriter::Write const string &  Label,
const Epetra_Map Map
 

Writes an Epetra_Map using label Label.

Definition at line 180 of file EpetraExt_XMLWriter.cpp.

void EpetraExt::XMLWriter::Write const string &  Label,
const Epetra_RowMatrix Matrix
 

Writes an Epetra_RowMatrix using label Label.

Definition at line 77 of file EpetraExt_XMLWriter.cpp.

void EpetraExt::XMLWriter::Write const string &  Label,
const Epetra_MultiVector MultiVector
 

Writes an Epetra_MultiVector using label Label.

Definition at line 133 of file EpetraExt_XMLWriter.cpp.

void EpetraExt::XMLWriter::Write const string &  Label,
const vector< string > &  Content
 

Writes the vector of string's using label Label.

Definition at line 56 of file EpetraExt_XMLWriter.cpp.

void EpetraExt::XMLWriter::Write const string &  Label,
const string &  Text
[inline]
 

Writes input string using label Label.

Definition at line 156 of file EpetraExt_XMLWriter.h.

void EpetraExt::XMLWriter::Write const string &  Label,
Teuchos::ParameterList &  List
 

Writes a Teuchos::ParameterList using label Label.

Definition at line 248 of file EpetraExt_XMLWriter.cpp.


Member Data Documentation

const Epetra_Comm& EpetraExt::XMLWriter::Comm_ [private]
 

Epetra communicator.

Definition at line 169 of file EpetraExt_XMLWriter.h.

string EpetraExt::XMLWriter::FileName_ [private]
 

Name of the file.

Definition at line 171 of file EpetraExt_XMLWriter.h.

bool EpetraExt::XMLWriter::IsOpen_ [private]
 

If true, the file has been successfully opened.

Definition at line 173 of file EpetraExt_XMLWriter.h.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:32:05 2008 for EpetraExt Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1