Loading...
Searching...
No Matches
XMLFile.h
// Copyright (C) 2011 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Anders Logg, 2011.
//
// First added: 2009-03-03
// Last changed: 2011-09-17
#ifndef __XMLFILE_H
#define __XMLFILE_H
#include <map>
#include <ostream>
#include <string>
#include <vector>
#include <memory>
#include <dolfin/common/types.h>
#include <dolfin/common/MPI.h>
#include "GenericFile.h"
namespace pugi
{
class xml_document;
class xml_node;
}
namespace dolfin
{
class Function;
class GenericVector;
class Mesh;
class Parameters;
class Table;
template<typename T> class Array;
template<typename T> class MeshFunction;
template<typename T> class MeshValueCollection;
class XMLFile : public GenericFile
{
public:
XMLFile(MPI_Comm mpi_comm, const std::string filename);
XMLFile(std::ostream& s);
~XMLFile();
void read(Mesh& input);
void write(const Mesh& output);
void read(GenericVector& input);
void read_vector(std::vector<double>& input,
std::vector<dolfin::la_index>& indices);
void write(const GenericVector& output);
void read(Parameters& input);
void write(const Parameters& output);
void read(Table& input);
void write(const Table& output);
void read(Function& input);
void write(const Function& output);
void read(MeshFunction<std::size_t>& input)
{ read_mesh_function(input, "uint"); }
void write(const MeshFunction<std::size_t>& output)
{ write_mesh_function(output, "uint"); }
void read(MeshFunction<int>& input)
{ read_mesh_function(input, "int"); }
void write(const MeshFunction<int>& output)
{ write_mesh_function(output, "int"); }
void read(MeshFunction<double>& input)
{ read_mesh_function(input, "double"); }
void write(const MeshFunction<double>& output)
{ write_mesh_function(output, "double"); }
void read(MeshFunction<bool>& input)
{ read_mesh_function(input, "bool"); }
void write(const MeshFunction<bool>& input)
{ write_mesh_function(input, "bool"); }
void read(MeshValueCollection<std::size_t>& input)
{ read_mesh_value_collection(input, "uint"); }
void write(const MeshValueCollection<std::size_t>& output)
{ write_mesh_value_collection(output, "uint"); }
void read(MeshValueCollection<int>& input)
{ read_mesh_value_collection(input, "int"); }
void write(const MeshValueCollection<int>& output)
{ write_mesh_value_collection(output, "int"); }
void read(MeshValueCollection<double>& input)
{ read_mesh_value_collection(input, "double"); }
void write(const MeshValueCollection<double>& output)
{ write_mesh_value_collection(output, "double"); }
void read(MeshValueCollection<bool>& input)
{ read_mesh_value_collection(input, "bool"); }
void write(const MeshValueCollection<bool>& input)
{ write_mesh_value_collection(input, "bool"); }
private:
// Read MeshFunction
template<typename T> void read_mesh_function(MeshFunction<T>& t,
const std::string type) const;
// Write MeshFunction
template<typename T> void write_mesh_function(const MeshFunction<T>& t,
const std::string type);
// Read MeshValueCollection
template<typename T>
void read_mesh_value_collection(MeshValueCollection<T>& t,
const std::string type) const;
// Write MeshValueCollection
template<typename T>
void write_mesh_value_collection(const MeshValueCollection<T>& t,
const std::string type);
// Load/open XML doc (from file)
void load_xml_doc(pugi::xml_document& xml_doc) const;
// Save XML doc (to file or stream)
void save_xml_doc(const pugi::xml_document& xml_doc) const;
// Get DOLFIN XML node
const pugi::xml_node get_dolfin_xml_node(pugi::xml_document& xml_doc) const;
static pugi::xml_node write_dolfin(pugi::xml_document& doc);
std::shared_ptr<std::ostream> outstream;
// MPI communicator
dolfin::MPI::Comm _mpi_comm;
};
}
#endif
dolfin::Array
Definition Array.h:42
dolfin::Function
Definition Function.h:66
dolfin::GenericFile::GenericFile
GenericFile(std::string filename, std::string filetype)
Constructor.
Definition GenericFile.cpp:33
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::MPI::Comm
Definition MPI.h:77
dolfin::MeshFunction
Definition MeshFunction.h:58
dolfin::MeshValueCollection
Definition MeshValueCollection.h:51
dolfin::Mesh
Definition Mesh.h:84
dolfin::Parameters
Definition Parameters.h:95
dolfin::Table
Definition Table.h:50
dolfin::XMLFile::read
void read(MeshValueCollection< std::size_t > &input)
MeshValueCollection (std::size_t) input.
Definition XMLFile.h:124
dolfin::XMLFile::write
void write(const MeshFunction< int > &output)
MeshFunction (int) output.
Definition XMLFile.h:106
dolfin::XMLFile::read
void read(MeshValueCollection< double > &input)
MeshValueCollection (double) input.
Definition XMLFile.h:138
dolfin::XMLFile::read
void read(MeshFunction< int > &input)
MeshFunction (int) input.
Definition XMLFile.h:103
dolfin::XMLFile::read
void read(Mesh &input)
Mesh input.
Definition XMLFile.cpp:76
dolfin::XMLFile::write
void write(const MeshFunction< bool > &input)
MeshFunction (bool) output.
Definition XMLFile.h:120
dolfin::XMLFile::write
void write(const MeshFunction< std::size_t > &output)
MeshFunction (uint) output.
Definition XMLFile.h:99
dolfin::XMLFile::read
void read(MeshFunction< std::size_t > &input)
MeshFunction (uint) input.
Definition XMLFile.h:96
dolfin::XMLFile::write
void write(const MeshValueCollection< std::size_t > &output)
MeshValueCollection (std::size_t) output.
Definition XMLFile.h:127
dolfin::XMLFile::read
void read(MeshFunction< bool > &input)
MeshFunction (bool) input.
Definition XMLFile.h:117
dolfin::XMLFile::read_vector
void read_vector(std::vector< double > &input, std::vector< dolfin::la_index > &indices)
Vector input.
Definition XMLFile.cpp:165
dolfin::XMLFile::XMLFile
XMLFile(MPI_Comm mpi_comm, const std::string filename)
Constructor.
Definition XMLFile.cpp:58
dolfin::XMLFile::read
void read(MeshValueCollection< bool > &input)
MeshValueCollection (bool) input.
Definition XMLFile.h:145
dolfin::XMLFile::read
void read(MeshValueCollection< int > &input)
MeshValueCollection (int) input.
Definition XMLFile.h:131
dolfin::XMLFile::write
void write(const MeshValueCollection< int > &output)
MeshValueCollection (int) output.
Definition XMLFile.h:134
dolfin::XMLFile::read
void read(MeshFunction< double > &input)
MeshFunction (double) input.
Definition XMLFile.h:110
dolfin::XMLFile::write
void write(const Mesh &output)
Mesh output.
Definition XMLFile.cpp:113
dolfin::XMLFile::write
void write(const MeshFunction< double > &output)
MeshFunction (double) output.
Definition XMLFile.h:113
dolfin::XMLFile::write
void write(const MeshValueCollection< double > &output)
MeshValueCollection (double) output.
Definition XMLFile.h:141
dolfin::XMLFile::write
void write(const MeshValueCollection< bool > &input)
MeshValueCollection (bool) output.
Definition XMLFile.h:148
dolfin
Definition adapt.h:30