}
}
+ /**
+ * Convert between the enum specified inside VtkFlags and the preprocessor
+ * constant defined by boost::iostreams::zlib.
+ */
+ int
+ get_boost_zlib_compression_level(
+ const DataOutBase::VtkFlags::ZlibCompressionLevel level)
+ {
+ switch (level)
+ {
+ case (DataOutBase::VtkFlags::no_compression):
+ return boost::iostreams::zlib::no_compression;
+ case (DataOutBase::VtkFlags::best_speed):
+ return boost::iostreams::zlib::best_speed;
+ case (DataOutBase::VtkFlags::best_compression):
+ return boost::iostreams::zlib::best_compression;
+ case (DataOutBase::VtkFlags::default_compression):
+ return boost::iostreams::zlib::default_compression;
+ default:
+ Assert(false, ExcNotImplemented());
+ return boost::iostreams::zlib::no_compression;
+ }
+ }
+
/**
* Do a zlib compression followed by a base64 encoding of the given data. The
* result is then written to the given stream.
if (compression != VtkFlags::no_compression)
# ifdef DEAL_II_WITH_ZLIB
- f.push(boost::iostreams::zlib_compressor());
+ f.push(boost::iostreams::zlib_compressor(
+ get_boost_zlib_compression_level(compression)));
# else
AssertThrow(
false,
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2022 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.
+//
+// ---------------------------------------------------------------------
+
+// Test DataOut::write_deal_II_intermediate_in_parallel() and
+// DataOutReader::read_whole_parallel_file() with compression
+
+#include <deal.II/base/mpi.h>
+
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/filtered_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include <deal.II/lac/vector.h>
+
+#include <deal.II/numerics/data_out.h>
+
+#include "../tests.h"
+
+
+template <int dim>
+void
+check()
+{
+ Triangulation<dim> tria;
+ GridGenerator::hyper_cube(tria, 0., 1.);
+ tria.refine_global(1);
+
+ Vector<double> cell_data(tria.n_active_cells());
+ for (unsigned int i = 0; i < tria.n_active_cells(); ++i)
+ cell_data(i) = i * 1.0;
+
+ FE_Q<dim> fe(1);
+ DoFHandler<dim> dof_handler(tria);
+ dof_handler.distribute_dofs(fe);
+
+ Vector<double> x(dof_handler.n_dofs());
+
+ DataOut<dim> data_out;
+ data_out.attach_dof_handler(dof_handler);
+ data_out.add_data_vector(cell_data,
+ "cell_data",
+ DataOut<dim>::type_cell_data);
+ data_out.add_data_vector(x, "solution");
+
+ data_out.build_patches();
+
+ data_out.write_deal_II_intermediate_in_parallel(
+ "test.pd2", MPI_COMM_WORLD, DataOutBase::VtkFlags::best_compression);
+
+ const unsigned int my_rank =
+ dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+ if (my_rank == 0)
+ {
+ // Read the data back in and dump it into the deallog:
+ std::ifstream in("test.pd2");
+ Assert(in, dealii::ExcIO());
+ DataOutReader<dim, dim> reader;
+ reader.read_whole_parallel_file(in);
+ reader.write_deal_II_intermediate(deallog.get_file_stream());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+int
+main(int argc, char **argv)
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ MPILogInitAll all;
+
+ check<2>();
+
+ return 0;
+}
--- /dev/null
+
+2 2
+[deal.II intermediate format graphics data]
+[written by deal.II x.y.z]
+[Version: 4]
+2
+solution
+cell_data
+8
+[deal.II intermediate Patch<2,2>]
+3
+0.00000 0.00000 0.500000 0.00000 0.00000 0.500000 0.500000 0.500000
+4294967295 1 4294967295 2
+0 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.500000 0.00000 1.00000 0.00000 0.500000 0.500000 1.00000 0.500000
+0 4294967295 4294967295 3
+1 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 1.00000 1.00000 1.00000 1.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.00000 0.500000 0.500000 0.500000 0.00000 1.00000 0.500000 1.00000
+4294967295 3 0 4294967295
+2 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 2.00000 2.00000 2.00000 2.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.500000 0.500000 1.00000 0.500000 0.500000 1.00000 1.00000 1.00000
+2 4294967295 1 4294967295
+3 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 3.00000 3.00000 3.00000 3.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.00000 0.00000 0.500000 0.00000 0.00000 0.500000 0.500000 0.500000
+4294967295 5 4294967295 6
+4 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.500000 0.00000 1.00000 0.00000 0.500000 0.500000 1.00000 0.500000
+4 4294967295 4294967295 7
+5 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 1.00000 1.00000 1.00000 1.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.00000 0.500000 0.500000 0.500000 0.00000 1.00000 0.500000 1.00000
+4294967295 7 4 4294967295
+6 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 2.00000 2.00000 2.00000 2.00000
+
+
+[deal.II intermediate Patch<2,2>]
+3
+0.500000 0.500000 1.00000 0.500000 0.500000 1.00000 1.00000 1.00000
+6 4294967295 5 4294967295
+7 1
+0
+2 4
+0.00000 0.00000 0.00000 0.00000 3.00000 3.00000 3.00000 3.00000
+
+
+0
+
+DEAL:0::OK
+
+DEAL:1::OK
+