From b4668c88eb25350ddfcab3a97579c06545a4e187 Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Mon, 24 Mar 2025 16:06:52 +0100
Subject: [PATCH] UGGrid: Remove the rudimentary saveState/loadState
 implementations

The implementations of these methods looked like they do something
reasonable, but in fact they don't: They do call corresponding
UGGrid methods, but those methods never worked (in Dune!).

After giving it some thought it is now my opinion that the UGGrid
saveState/loadState functionality is not worth the time needed
to understand it and get it to work.  A modern snapshotting code
should be written from scratch in any case, using existing modern
standards as much as possible.

Therefore, this patch removes the dummy calls to SaveMultiGrid
and LoadMultiGrid.
---
 dune/grid/uggrid/uggrid.cc | 60 ++------------------------------------
 1 file changed, 2 insertions(+), 58 deletions(-)

diff --git a/dune/grid/uggrid/uggrid.cc b/dune/grid/uggrid/uggrid.cc
index 729a507b91..3aabe0cf29 100644
--- a/dune/grid/uggrid/uggrid.cc
+++ b/dune/grid/uggrid/uggrid.cc
@@ -609,70 +609,14 @@ void UGGrid < dim >::setPosition(const typename Traits::template Codim<dim>::Ent
 template <int dim>
 void UGGrid<dim>::saveState(const std::string& filename) const
 {
-  const char* type = "asc";
-  const char* comment = "written by DUNE";
-
-  if (dim==2)
-    UG::D2::SaveMultiGrid((UG::D2::multigrid*)multigrid_,
-                          filename.c_str(),
-                          type,
-                          comment,
-                          0,      // autosave
-                          0       // rename
-                          );
-  else
-    UG::D3::SaveMultiGrid((UG::D3::multigrid*)multigrid_,
-                          filename.c_str(),
-                          type,
-                          comment,
-                          0,      // autosave
-                          0       // rename
-                          );
+  DUNE_THROW(NotImplemented, "Writing complete UGGrid hierarchies is not implemented yet.");
 }
 
 
 template <int dim>
 void UGGrid<dim>::loadState(const std::string& filename)
 {
-  const char* type = "asc";
-  std::string formatName = "DuneFormat2d";
-
-  if (dim==2) {
-    std::string formatName = "DuneFormat2d";
-    multigrid_ = (typename UG_NS<dim>::MultiGrid*) UG::D2::LoadMultiGrid(
-      name_.c_str(),
-      filename.c_str(),
-      type,
-      nullptr,  // dummy BVP point -- this will crash!
-      formatName.c_str(),
-      0,    // dummy heap size
-      true, //force,
-      true, //optimizedIO,
-      false //autosave
-#if ModelP and DUNE_UGGRID_HAVE_PPIFCONTEXT
-      , std::make_shared<PPIF::PPIFContext>(comm())
-#endif
-      );
-  } else {
-    std::string formatName = "DuneFormat3d";
-    multigrid_ = (typename UG_NS<dim>::MultiGrid*) UG::D3::LoadMultiGrid(
-      name_.c_str(),
-      filename.c_str(),
-      type,
-      nullptr,  // dummy BVP point -- this will crash!
-      formatName.c_str(),
-      0,    // dummy heap size
-      true, //force,
-      true, //optimizedIO,
-      false //autosave
-#if ModelP and DUNE_UGGRID_HAVE_PPIFCONTEXT
-      , std::make_shared<PPIF::PPIFContext>(comm())
-#endif
-      );
-  }
-
-  if (multigrid_==nullptr)
-    DUNE_THROW(GridError, "In loadState()");
+  DUNE_THROW(NotImplemented, "Loading complete UGGrid hierarchies is not implemented yet.");
 }
 
 template < int dim >
-- 
GitLab