From: Timo Heister Date: Thu, 14 Jul 2022 01:58:24 +0000 (-0400) Subject: deprecate VtkFalgs::ZlibCompressionLevel X-Git-Tag: v9.5.0-rc1~1072^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8810ab9ba3d796c29d49e6d4d4771203f180576d;p=dealii.git deprecate VtkFalgs::ZlibCompressionLevel --- diff --git a/examples/step-23/step-23.cc b/examples/step-23/step-23.cc index 5b44c4f221..444a94784a 100644 --- a/examples/step-23/step-23.cc +++ b/examples/step-23/step-23.cc @@ -412,8 +412,7 @@ namespace Step23 // zlib compression algorithm that is optimized for speed instead of disk // usage since otherwise plotting the output becomes a bottleneck: DataOutBase::VtkFlags vtk_flags; - vtk_flags.compression_level = - DataOutBase::VtkFlags::ZlibCompressionLevel::best_speed; + vtk_flags.compression_level = DataOutBase::best_speed; data_out.set_flags(vtk_flags); std::ofstream output(filename); data_out.write_vtu(output); diff --git a/examples/step-24/step-24.cc b/examples/step-24/step-24.cc index 448b44d892..ee7d7477a3 100644 --- a/examples/step-24/step-24.cc +++ b/examples/step-24/step-24.cc @@ -431,8 +431,7 @@ namespace Step24 const std::string filename = "solution-" + Utilities::int_to_string(timestep_number, 3) + ".vtu"; DataOutBase::VtkFlags vtk_flags; - vtk_flags.compression_level = - DataOutBase::VtkFlags::ZlibCompressionLevel::best_speed; + vtk_flags.compression_level = DataOutBase::best_speed; std::ofstream output(filename); data_out.write_vtu(output); } diff --git a/examples/step-25/step-25.cc b/examples/step-25/step-25.cc index ee2cabd13d..5c0c3fa073 100644 --- a/examples/step-25/step-25.cc +++ b/examples/step-25/step-25.cc @@ -559,8 +559,7 @@ namespace Step25 const std::string filename = "solution-" + Utilities::int_to_string(timestep_number, 3) + ".vtu"; DataOutBase::VtkFlags vtk_flags; - vtk_flags.compression_level = - DataOutBase::VtkFlags::ZlibCompressionLevel::best_speed; + vtk_flags.compression_level = DataOutBase::best_speed; data_out.set_flags(vtk_flags); std::ofstream output(filename); data_out.write_vtu(output); diff --git a/examples/step-9/step-9.cc b/examples/step-9/step-9.cc index c00b03a26c..26d2db469e 100644 --- a/examples/step-9/step-9.cc +++ b/examples/step-9/step-9.cc @@ -844,8 +844,7 @@ namespace Step9 // disk. Here we ask ZLib, a compression library, to compress the data // in a way that maximizes throughput. DataOutBase::VtkFlags vtk_flags; - vtk_flags.compression_level = - DataOutBase::VtkFlags::ZlibCompressionLevel::best_speed; + vtk_flags.compression_level = DataOutBase::best_speed; data_out.set_flags(vtk_flags); std::ofstream output("solution-" + std::to_string(cycle) + ".vtu"); diff --git a/include/deal.II/base/data_out_base.h b/include/deal.II/base/data_out_base.h index 2fa678252f..75f316d514 100644 --- a/include/deal.II/base/data_out_base.h +++ b/include/deal.II/base/data_out_base.h @@ -220,6 +220,33 @@ class XDMFEntry; */ namespace DataOutBase { + /** + * An enum for different levels of compression used in several places + * to determine zlib compression levels. + */ + enum CompressionLevel + { + /** + * Do not use any compression. + */ + no_compression, + /** + * Use the fastest available compression algorithm. + */ + best_speed, + /** + * Use the algorithm which results in the smallest compressed + * files. This is the default flag. + */ + best_compression, + /** + * Use the default compression algorithm. This is a compromise between + * speed and file size. + */ + default_compression + }; + + /** * Data structure describing a patch of data in dim space * dimensions. @@ -1124,34 +1151,26 @@ namespace DataOutBase /** * A data type providing the different possible zlib compression * levels. These map directly to constants defined by zlib. + * + * @deprecated Use DataOutBase::CompressionLevel instead. */ - enum ZlibCompressionLevel - { - /** - * Do not use any compression. - */ - no_compression, - /** - * Use the fastest available compression algorithm. - */ - best_speed, - /** - * Use the algorithm which results in the smallest compressed - * files. This is the default flag. - */ - best_compression, - /** - * Use the default compression algorithm. This is a compromise between - * speed and file size. - */ - default_compression - }; + using ZlibCompressionLevel DEAL_II_DEPRECATED = + DataOutBase::CompressionLevel; + + DEAL_II_DEPRECATED static const DataOutBase::CompressionLevel + no_compression = dealii::DataOutBase::no_compression; + DEAL_II_DEPRECATED static const DataOutBase::CompressionLevel + best_compression = dealii::DataOutBase::best_compression; + DEAL_II_DEPRECATED static const DataOutBase::CompressionLevel best_speed = + dealii::DataOutBase::best_speed; + DEAL_II_DEPRECATED static const DataOutBase::CompressionLevel + default_compression = dealii::DataOutBase::default_compression; /** * Flag determining the compression level at which zlib, if available, is * run. The default is best_compression. */ - ZlibCompressionLevel compression_level; + DataOutBase::CompressionLevel compression_level; /** * Flag determining whether to write patches as linear cells @@ -1200,11 +1219,11 @@ namespace DataOutBase * to the argument names of this function. */ VtkFlags( - const double time = std::numeric_limits::min(), - const unsigned int cycle = std::numeric_limits::min(), - const bool print_date_and_time = true, - const ZlibCompressionLevel compression_level = best_compression, - const bool write_higher_order_cells = false, + const double time = std::numeric_limits::min(), + const unsigned int cycle = std::numeric_limits::min(), + const bool print_date_and_time = true, + const CompressionLevel compression_level = best_compression, + const bool write_higher_order_cells = false, const std::map &physical_units = {}); }; @@ -2361,11 +2380,11 @@ namespace DataOutBase unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation>> - & nonscalar_data_ranges, - const Deal_II_IntermediateFlags & flags, - const std::string & filename, - const MPI_Comm & comm, - const VtkFlags::ZlibCompressionLevel compression); + & nonscalar_data_ranges, + const Deal_II_IntermediateFlags &flags, + const std::string & filename, + const MPI_Comm & comm, + const CompressionLevel compression); /** * Write the data in @p data_filter to a single HDF5 file containing both the @@ -2858,9 +2877,9 @@ public: */ void write_deal_II_intermediate_in_parallel( - const std::string & filename, - const MPI_Comm & comm, - const DataOutBase::VtkFlags::ZlibCompressionLevel compression) const; + const std::string & filename, + const MPI_Comm & comm, + const DataOutBase::CompressionLevel compression) const; /** * Create an XDMFEntry based on the data in the data_filter. This assumes diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 9caf6a6033..701f7d7d89 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -94,18 +94,17 @@ namespace * constant defined by zlib. */ int - get_zlib_compression_level( - const DataOutBase::VtkFlags::ZlibCompressionLevel level) + get_zlib_compression_level(const DataOutBase::CompressionLevel level) { switch (level) { - case (DataOutBase::VtkFlags::no_compression): + case (DataOutBase::no_compression): return Z_NO_COMPRESSION; - case (DataOutBase::VtkFlags::best_speed): + case (DataOutBase::best_speed): return Z_BEST_SPEED; - case (DataOutBase::VtkFlags::best_compression): + case (DataOutBase::best_compression): return Z_BEST_COMPRESSION; - case (DataOutBase::VtkFlags::default_compression): + case (DataOutBase::default_compression): return Z_DEFAULT_COMPRESSION; default: Assert(false, ExcNotImplemented()); @@ -113,29 +112,30 @@ namespace } } +# ifdef DEAL_II_WITH_MPI /** * 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) + get_boost_zlib_compression_level(const DataOutBase::CompressionLevel level) { switch (level) { - case (DataOutBase::VtkFlags::no_compression): + case (DataOutBase::no_compression): return boost::iostreams::zlib::no_compression; - case (DataOutBase::VtkFlags::best_speed): + case (DataOutBase::best_speed): return boost::iostreams::zlib::best_speed; - case (DataOutBase::VtkFlags::best_compression): + case (DataOutBase::best_compression): return boost::iostreams::zlib::best_compression; - case (DataOutBase::VtkFlags::default_compression): + case (DataOutBase::default_compression): return boost::iostreams::zlib::default_compression; default: Assert(false, ExcNotImplemented()); return boost::iostreams::zlib::no_compression; } } +# endif /** * Do a zlib compression followed by a base64 encoding of the given data. The @@ -2727,11 +2727,11 @@ namespace DataOutBase - VtkFlags::VtkFlags(const double time, - const unsigned int cycle, - const bool print_date_and_time, - const VtkFlags::ZlibCompressionLevel compression_level, - const bool write_higher_order_cells, + VtkFlags::VtkFlags(const double time, + const unsigned int cycle, + const bool print_date_and_time, + const CompressionLevel compression_level, + const bool write_higher_order_cells, const std::map &physical_units) : time(time) , cycle(cycle) @@ -7602,11 +7602,11 @@ namespace DataOutBase unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation>> - & nonscalar_data_ranges, - const Deal_II_IntermediateFlags & flags, - const std::string & filename, - const MPI_Comm & comm, - const VtkFlags::ZlibCompressionLevel compression) + & nonscalar_data_ranges, + const Deal_II_IntermediateFlags &flags, + const std::string & filename, + const MPI_Comm & comm, + const CompressionLevel compression) { #ifndef DEAL_II_WITH_MPI (void)patches; @@ -7641,7 +7641,7 @@ namespace DataOutBase { boost::iostreams::filtering_ostream f; - if (compression != VtkFlags::no_compression) + if (compression != no_compression) # ifdef DEAL_II_WITH_ZLIB f.push(boost::iostreams::zlib_compressor( get_boost_zlib_compression_level(compression))); @@ -8141,9 +8141,9 @@ DataOutInterface::write_deal_II_intermediate( template void DataOutInterface::write_deal_II_intermediate_in_parallel( - const std::string & filename, - const MPI_Comm & comm, - const DataOutBase::VtkFlags::ZlibCompressionLevel compression) const + const std::string & filename, + const MPI_Comm & comm, + const DataOutBase::CompressionLevel compression) const { DataOutBase::write_deal_II_intermediate_in_parallel( get_patches(), @@ -9335,8 +9335,8 @@ DataOutReader::read_whole_parallel_file(std::istream &in) in.read(temp_buffer.data(), chunk_sizes[n]); boost::iostreams::filtering_istreambuf f; - if (static_cast( - header.compression) != DataOutBase::VtkFlags::no_compression) + if (static_cast(header.compression) != + DataOutBase::no_compression) #ifdef DEAL_II_WITH_ZLIB f.push(boost::iostreams::zlib_decompressor()); #else diff --git a/source/base/data_out_base.inst.in b/source/base/data_out_base.inst.in index 56730ced65..35077900a8 100644 --- a/source/base/data_out_base.inst.in +++ b/source/base/data_out_base.inst.in @@ -213,11 +213,11 @@ for (deal_II_dimension : OUTPUT_DIMENSIONS; unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation>> - & nonscalar_data_ranges, - const Deal_II_IntermediateFlags & flags, - const std::string & filename, - const MPI_Comm & comm, - const VtkFlags::ZlibCompressionLevel compression); + & nonscalar_data_ranges, + const Deal_II_IntermediateFlags &flags, + const std::string & filename, + const MPI_Comm & comm, + const CompressionLevel compression); template void write_hdf5_parallel( diff --git a/tests/simplex/step-23.cc b/tests/simplex/step-23.cc index 7102155424..5ad1b47298 100644 --- a/tests/simplex/step-23.cc +++ b/tests/simplex/step-23.cc @@ -312,8 +312,7 @@ namespace Step23 const std::string filename = "solution-" + Utilities::int_to_string(timestep_number, 3) + ".vtu"; DataOutBase::VtkFlags vtk_flags; - vtk_flags.compression_level = - DataOutBase::VtkFlags::ZlibCompressionLevel::best_speed; + vtk_flags.compression_level = DataOutBase::best_speed; data_out.set_flags(vtk_flags); std::ofstream output(filename); data_out.write_vtu(output);