From: Rene Gassmoeller Date: Mon, 4 Feb 2019 21:12:12 +0000 (-0800) Subject: Fix serialization of XDMFEntry class X-Git-Tag: v9.1.0-rc1~372^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb5fb7de671a7700ecef591d597acb696c5b31d4;p=dealii.git Fix serialization of XDMFEntry class --- diff --git a/include/deal.II/base/data_out_base.h b/include/deal.II/base/data_out_base.h index 8e05a6aacb..2a6da9fd79 100644 --- a/include/deal.II/base/data_out_base.h +++ b/include/deal.II/base/data_out_base.h @@ -26,6 +26,9 @@ #include +// To be able to serialize XDMFEntry +#include + #include #include #include @@ -3599,7 +3602,7 @@ public: serialize(Archive &ar, const unsigned int /*version*/) { ar &valid &h5_sol_filename &h5_mesh_filename &entry_time &num_nodes - &num_cells &dimension &attribute_dims; + &num_cells &dimension &space_dimension &attribute_dims; } /** diff --git a/tests/serialization/xdmf_entry.cc b/tests/serialization/xdmf_entry.cc new file mode 100644 index 0000000000..2a3c3b5948 --- /dev/null +++ b/tests/serialization/xdmf_entry.cc @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, 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 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// check serialization for XDMFEntry + +#include + +#include "serialization.h" + +void +test() +{ + const std::string mesh_filename = "mesh.h5"; + const std::string solution_filename = "solution.h5"; + + const double time = 0.5; + const unsigned int nodes = 128; + const unsigned int cells = 16; + const unsigned int dim = 2; + const unsigned int spacedim = 3; + + XDMFEntry entry1( + mesh_filename, solution_filename, time, nodes, cells, dim, spacedim); + XDMFEntry entry2; + + // save data to archive + std::ostringstream oss; + { + boost::archive::text_oarchive oa(oss, boost::archive::no_header); + oa << entry1; + // archive and stream closed when destructors are called + } + deallog << oss.str() << std::endl; + + // verify correctness of the serialization + { + std::istringstream iss(oss.str()); + boost::archive::text_iarchive ia(iss, boost::archive::no_header); + ia >> entry2; + } + + deallog << "XDMFEntry before serialization: " << std::endl + << std::endl + << entry1.get_xdmf_content(0) << std::endl; + + deallog << "XDMFEntry after de-serialization: " << std::endl + << std::endl + << entry2.get_xdmf_content(0) << std::endl; +} + + +int +main() +{ + initlog(); + deallog << std::setprecision(3); + + test(); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/xdmf_entry.output b/tests/serialization/xdmf_entry.output new file mode 100644 index 0000000000..fdeaefeca9 --- /dev/null +++ b/tests/serialization/xdmf_entry.output @@ -0,0 +1,36 @@ + +DEAL::0 0 1 11 solution.h5 7 mesh.h5 5.00000000000000000e-01 128 16 2 3 0 0 0 0 + +DEAL::XDMFEntry before serialization: +DEAL:: +DEAL:: + + +DEAL::XDMFEntry after de-serialization: +DEAL:: +DEAL:: + + +DEAL::OK