]> https://gitweb.dealii.org/ - dealii.git/commitdiff
make zlib optional 5322/head
authorTimo Heister <timo.heister@gmail.com>
Wed, 25 Oct 2017 13:26:03 +0000 (09:26 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 26 Oct 2017 13:26:07 +0000 (09:26 -0400)
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.

include/deal.II/distributed/grid_tools.h
source/dofs/dof_handler_policy.cc

index 5c48895bf38f0723ebfeb3d3740e90cd335d74bc..822d34eb8daa752a28fb824bea82aebdb64b6ed2 100644 (file)
@@ -27,10 +27,14 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
 #include <boost/archive/binary_iarchive.hpp>
 #include <boost/serialization/vector.hpp>
 #include <boost/serialization/array.hpp>
+
+#ifdef DEAL_II_WITH_ZLIB
 #include <boost/iostreams/stream.hpp>
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/iostreams/device/back_inserter.hpp>
 #include <boost/iostreams/filter/gzip.hpp>
+#endif
+
 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
 
 #include <vector>
@@ -212,6 +216,7 @@ namespace parallel
           // stream into which we serialize the current object
           std::vector<char> 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
index d8b397fe31708bcf8ade34a862c769db962b0fea..9978d969197ab371bfb4ea61808dfb875090c0ea 100644 (file)
 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
 #include <boost/archive/binary_oarchive.hpp>
 #include <boost/archive/binary_iarchive.hpp>
+#ifdef DEAL_II_WITH_ZLIB
 #include <boost/iostreams/stream.hpp>
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/iostreams/device/back_inserter.hpp>
 #include <boost/iostreams/filter/gzip.hpp>
 #include <boost/serialization/array.hpp>
+#endif
 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
 
 #include <set>
@@ -3052,6 +3054,7 @@ namespace internal
             // stream into which we serialize the current object
             std::vector<char> 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<char> 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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.