From: Timo Heister Date: Wed, 25 Oct 2017 13:26:03 +0000 (-0400) Subject: make zlib optional X-Git-Tag: v9.0.0-rc1~873^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5322%2Fhead;p=dealii.git make zlib optional distributed DoFHandler and GridTools::exchange_cell_data_to_ghosts relied on gzip support inside boost but we enable/require boost::iostreams if and only if DEAL_II_WITH_ZLIB=ON. Disable compressing the streams in that case. --- diff --git a/include/deal.II/distributed/grid_tools.h b/include/deal.II/distributed/grid_tools.h index 5c48895bf3..822d34eb8d 100644 --- a/include/deal.II/distributed/grid_tools.h +++ b/include/deal.II/distributed/grid_tools.h @@ -27,10 +27,14 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS #include #include #include + +#ifdef DEAL_II_WITH_ZLIB #include #include #include #include +#endif + DEAL_II_ENABLE_EXTRA_DIAGNOSTICS #include @@ -212,6 +216,7 @@ namespace parallel // stream into which we serialize the current object std::vector buffer; { +#ifdef DEAL_II_WITH_ZLIB boost::iostreams::filtering_ostream out; out.push(boost::iostreams::gzip_compressor (boost::iostreams::gzip_params @@ -219,9 +224,16 @@ namespace parallel out.push(boost::iostreams::back_inserter(buffer)); boost::archive::binary_oarchive archive(out); - archive << *this; out.flush(); +#else + std::ostringstream out; + boost::archive::binary_oarchive archive(out); + archive << *this; + const std::string &s = out.str(); + buffer.reserve(s.size()); + buffer.assign(s.begin(), s.end()); +#endif } return buffer; @@ -239,11 +251,14 @@ namespace parallel // first decompress the buffer { +#ifdef DEAL_II_WITH_ZLIB boost::iostreams::filtering_ostream decompressing_stream; decompressing_stream.push(boost::iostreams::gzip_decompressor()); decompressing_stream.push(boost::iostreams::back_inserter(decompressed_buffer)); - decompressing_stream.write (buffer.data(), buffer.size()); +#else + decompressed_buffer.assign (buffer.begin(), buffer.end()); +#endif } // then restore the object from the buffer diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index d8b397fe31..9978d96919 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -32,11 +32,13 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS #include #include +#ifdef DEAL_II_WITH_ZLIB #include #include #include #include #include +#endif DEAL_II_ENABLE_EXTRA_DIAGNOSTICS #include @@ -3052,6 +3054,7 @@ namespace internal // stream into which we serialize the current object std::vector buffer; { +#ifdef DEAL_II_WITH_ZLIB boost::iostreams::filtering_ostream out; out.push(boost::iostreams::gzip_compressor (boost::iostreams::gzip_params @@ -3062,6 +3065,14 @@ namespace internal archive << *this; out.flush(); +#else + std::ostringstream out; + boost::archive::binary_oarchive archive(out); + archive << *this; + const std::string &s = out.str(); + buffer.reserve(s.size()); + buffer.assign(s.begin(), s.end()); +#endif } return buffer; @@ -3079,11 +3090,14 @@ namespace internal // first decompress the buffer { +#ifdef DEAL_II_WITH_ZLIB boost::iostreams::filtering_ostream decompressing_stream; decompressing_stream.push(boost::iostreams::gzip_decompressor()); decompressing_stream.push(boost::iostreams::back_inserter(decompressed_buffer)); - decompressing_stream.write (buffer.data(), buffer.size()); +#else + decompressed_buffer.assign (buffer.begin(), buffer.end()); +#endif } // then restore the object from the buffer @@ -4296,6 +4310,8 @@ namespace internal // serialize our own IndexSet std::vector my_data; { +#ifdef DEAL_II_WITH_ZLIB + boost::iostreams::filtering_ostream out; out.push(boost::iostreams::gzip_compressor (boost::iostreams::gzip_params @@ -4306,6 +4322,14 @@ namespace internal archive << my_locally_owned_dofs; out.flush(); +#else + std::ostringstream out; + boost::archive::binary_oarchive archive(out); + archive << my_locally_owned_dofs; + const std::string &s = out.str(); + my_data.reserve(s.size()); + my_data.assign(s.begin(), s.end()); +#endif } // determine maximum size of IndexSet @@ -4334,11 +4358,16 @@ namespace internal // first decompress the buffer { +#ifdef DEAL_II_WITH_ZLIB + boost::iostreams::filtering_ostream decompressing_stream; decompressing_stream.push(boost::iostreams::gzip_decompressor()); decompressing_stream.push(boost::iostreams::back_inserter(decompressed_buffer)); decompressing_stream.write(&buffer[i*max_size], max_size); +#else + decompressed_buffer.assign (&buffer[i*max_size], max_size); +#endif } // then restore the object from the buffer