<commit_before>//-----------------------------------------------------------------------------
//    $Id$
//    Version: $Name$ 
//
//    Copyright (C) 2006, 2007 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//-----------------------------------------------------------------------------

#include "../tests.h"
#include <base/data_out_base.h>
#include <base/logstream.h>

#include <vector>
#include <iomanip>
#include <fstream>
#include <string>

#include "patches.h"

// test DataOutReader::merge

void cat_file(const char * filename)
{
  std::ifstream in(filename);
  while (in)
    {
      std::string s;
      std::getline(in, s);
      deallog.get_file_stream() << s << "\n";
    }
}

template <int dim, int spacedim>
void check(const char * name, DataOutBase::Deal_II_IntermediateFlags flags,
	   std::ostream& out)
{
  const unsigned int np = 1;
  
  std::vector<DataOutBase::Patch<dim, spacedim> > patches(np);
  
  create_patches(patches);
  
  std::vector<std::string> names(5);
  names[0] = "x1";
  names[1] = "x2";
  names[2] = "x3";
  names[3] = "x4";
  names[4] = "i";
  std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > vectors;
  
  DataOutBase::write_deal_II_intermediate(patches, names, vectors, flags, out);

  DataOutReader<dim,spacedim> data;
  {
    std::ifstream input(name);    
    data.read (input);
  }  
  DataOutReader<dim,spacedim> additional_data;
  {
    std::ifstream input(name);
    additional_data.read (input);
  }
   
  data.merge (additional_data);

  {
    std::ofstream out2( "data_out_reader_01/outfile");
    data.write_deal_II_intermediate (out2);
  }  

  cat_file("data_out_reader_01/outfile");
}


template<int dim, int spacedim>
void check_all(std::ostream& log)
{
  char name[100];
  const char* format = "data_out_reader_01/%d%d.d2";
  DataOutBase::Deal_II_IntermediateFlags flags;
    {
      sprintf(name, format, dim, spacedim, "");

      std::ofstream out(name);

      check<dim,spacedim>(name, flags, out);
    }
}

int main()
{
  std::ofstream logfile("data_out_reader_01/output");
  deallog.attach(logfile);

  //  check_all<1,1>(logfile);
  //  check_all<1,2>(logfile);
  check_all<2,2>(logfile);
  //  check_all<2,3>(logfile);
  //  check_all<3,3>(logfile);  
}
<commit_msg>Simplify testcase. No need to have a temporary file.<commit_after>//-----------------------------------------------------------------------------
//    $Id$
//    Version: $Name$ 
//
//    Copyright (C) 2006, 2007 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//-----------------------------------------------------------------------------

#include "../tests.h"
#include <base/data_out_base.h>
#include <base/logstream.h>

#include <vector>
#include <iomanip>
#include <fstream>
#include <string>

#include "patches.h"

// test DataOutReader::merge

void cat_file(const char * filename)
{
  std::ifstream in(filename);
  while (in)
    {
      std::string s;
      std::getline(in, s);
      deallog.get_file_stream() << s << "\n";
    }
}

template <int dim, int spacedim>
void check()
{
  const unsigned int np = 1;
  
  std::vector<DataOutBase::Patch<dim, spacedim> > patches(np);
  
  create_patches(patches);
  
  std::vector<std::string> names(5);
  names[0] = "x1";
  names[1] = "x2";
  names[2] = "x3";
  names[3] = "x4";
  names[4] = "i";
  std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > vectors;
  
  std::ostringstream old_data;
  DataOutBase::write_deal_II_intermediate(patches, names, vectors, 
					  DataOutBase::Deal_II_IntermediateFlags(),
					  old_data);

  DataOutReader<dim,spacedim> data;
  {
    std::istringstream input(old_data.str());
    data.read (input);
  }  
  DataOutReader<dim,spacedim> additional_data;
  {
    std::istringstream input(old_data.str());
    additional_data.read (input);
  }
   
  data.merge (additional_data);

  {
    std::ofstream out2( "data_out_reader_01/outfile");
    data.write_deal_II_intermediate (out2);
  }  

  cat_file("data_out_reader_01/outfile");
}


int main()
{
  std::ofstream logfile("data_out_reader_01/output");
  deallog.attach(logfile);

  //  check<1,1>();
  //  check<1,2>();
  check<2,2>();
  //  check<2,3>();
  //  check<3,3>();  
}

{'fraction_non_alphanumeric': 0.21462570315880572, 'fraction_numerical': 0.017741237559498052, 'mean_word_length': 2.669047619047619, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4604737', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1613, 'n_words': 330}