Hi,

my quick and dirty solution (see below) based on rapidxml works now reliably, 
but you are right: It is an unnecessary effort parsing such a simple xml file. 
It would be enough to write the whole file every time anew (but then you have 
to store the timesteps somewhere else).
I will have a look on "write_pvtu_record" in "data_out_base.cc" in the next 
weeks.

Concerning the meta-data: with "part= " it should be possible to specify different parts 
of a geometry or mesh for each timestep and with "group=" you can arrange geometries in 
different groups - but I am no expert in all this. It is just what I found on the net.
As described here (http://www.elmerfem.org/?p=223) the listing within the ".pvd" file 
should work with ".pvtu" files for every time-step as well (a kind of wrapper-wrapper).

I am not sure if this "part" and "group" stuff is relevant and should be included in a 
possible "write_pvd_record" at all? Otherwise I think a dummy value for both will do it.

Regards,

Marco



Maybe someone can make use of it:

#include "rapidxml.hpp"
#include "rapidxml_print.hpp"

//main class

template<int dim>
  class XXXXX
  {
    public:....

    private:....

           voidinitialize_output ();
           void output_time (const std::string&filename);
           rapidxml::xml_document<>  doc;
           double time;  //current integration time

      .....

  }

//before starting time-integration

template<int dim>
     void XXXXX<dim>::initialize_output ()
     {
          rapidxml::xml_node<>* decl = 
doc.allocate_node(rapidxml::node_declaration);
          decl->append_attribute(doc.allocate_attribute("version", "1.0"));
          doc.append_node(decl);

          rapidxml::xml_node<>* root = doc.allocate_node(rapidxml::node_element, 
doc.allocate_string("VTKFile"));
          root->append_attribute(doc.allocate_attribute("type","Collection"));
          root->append_attribute(doc.allocate_attribute("version","0.1"));
          
root->append_attribute(doc.allocate_attribute("ByteOrder","LittleEndian"));
          doc.append_node(root);

          rapidxml::xml_node<>* collection =  doc.allocate_node(rapidxml::node_element, 
doc.allocate_string("Collection"));
          root->append_node(collection);

          std::ofstream file("solution.pvd");
          file<<  doc;
          file.close();
          doc.clear();
     }

//for each timestep

template<int dim>
     void XXXXX<dim>::output_time (const std::string&filename)
     {
          std::stringstream NumberString;
          NumberString<<  time;
          std::string timestep_pvd = NumberString.str();

          std::fstream file;
          file.open("solution.pvd",std::ios::in);

          std::string input_xml;
          std::string line;

          while(std::getline(file,line))
                input_xml += line;

          file.close();

          std::vector<char>  xml_copy(input_xml.begin(), input_xml.end());
          xml_copy.push_back('\0');

          doc.parse<rapidxml::parse_declaration_node | 
rapidxml::parse_no_data_nodes>(&xml_copy[0]);

          rapidxml::xml_node<>* dataset =  doc.allocate_node(rapidxml::node_element, 
doc.allocate_string("DataSet"));
          dataset->append_attribute(doc.allocate_attribute("timestep", 
timestep_pvd.c_str()));
          dataset->append_attribute(doc.allocate_attribute("group",""));
          dataset->append_attribute(doc.allocate_attribute("part","0"));
          dataset->append_attribute(doc.allocate_attribute("file", 
filename.c_str()));
          
doc.first_node("VTKFile")->first_node("Collection")->append_node(dataset);

          file.open("solution.pvd",std::ios::out);
          file<<  doc;
          file.close();
          doc.clear();
     }




_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to