]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move the save and load function to serial tria
authorBruno Blais <blais.bruno@gmail.com>
Mon, 3 Jul 2023 15:20:15 +0000 (11:20 -0400)
committerBruno Blais <blais.bruno@gmail.com>
Mon, 3 Jul 2023 15:20:15 +0000 (11:20 -0400)
include/deal.II/distributed/tria_base.h
include/deal.II/grid/tria.h
source/grid/tria.cc

index 6e9f74734f802ec26b3bc41fd5c37b7aa7f0ab59..187389c37c796536e1d21009df4cefdf44c2145a 100644 (file)
@@ -487,16 +487,16 @@ namespace parallel
      * into this file. Additional cell-based data can be saved using
      * register_data_attach().
      */
-    virtual void
-    save(const std::string &filename) const = 0;
+    using Triangulation<dim, spacedim>::save;
+
 
     /**
      * Load the triangulation saved with save() back in. Cell-based data that
      * was saved with register_data_attach() can be read in with
      * notify_ready_to_unpack() after calling load().
      */
-    virtual void
-    load(const std::string &filename) = 0;
+    using Triangulation<dim, spacedim>::load;
+
 
     /**
      * @copydoc load()
index cd10daeed10ccb60af09c3fb5803fca1e24a62d0..5d26bd6ff695088e60bb2ff0bb2b30cf3930f30e 100644 (file)
@@ -3411,6 +3411,22 @@ public:
   load(Archive &ar, const unsigned int version);
 
 
+  /**
+   * Save the triangulation into the given file. Internally, this
+   * function calls the save funtion which uses BOOST archives. This
+   * is a placeholder implementation that, in the near future, will also
+   * attach the data associated with the triangulation
+   */
+  virtual void
+  save(const std::string &filename) const;
+
+  /**
+   * Load the triangulation saved with save() back in.
+   */
+  virtual void
+  load(const std::string &filename);
+
+
   /**
    * Declare the (coarse) face pairs given in the argument of this function as
    * periodic. This way it is possible to obtain neighbors across periodic
index c5682522294637f8a8594e538d05afc9454152fe..1a1ca15f17d6a04624f279b9f9f38cf03424fc06 100644 (file)
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/grid/tria_levels.h>
 
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/text_oarchive.hpp>
+
 #include <algorithm>
 #include <array>
 #include <cmath>
+#include <fstream>
 #include <functional>
 #include <list>
 #include <map>
@@ -12751,7 +12755,25 @@ void Triangulation<dim, spacedim>::load_user_indices(
     Assert(false, ExcNotImplemented());
 }
 
+template <int dim, int spacedim>
+DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
+void Triangulation<dim, spacedim>::save(const std::string &filename) const
+{
+  // Create boost archive then call alternative version of the save function
+  std::ofstream                 ofs(filename);
+  boost::archive::text_oarchive oa(ofs, boost::archive::no_header);
+  save(oa, 0);
+}
 
+template <int dim, int spacedim>
+DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
+void Triangulation<dim, spacedim>::load(const std::string &filename)
+{
+  // Create boost archive then call alternative version of the load function
+  std::ifstream                 ifs(filename);
+  boost::archive::text_iarchive ia(ifs, boost::archive::no_header);
+  load(ia, 0);
+}
 
 namespace
 {

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.