From b26f81bd8e8d5b0af20c64e573978ea6a2ff2b7c Mon Sep 17 00:00:00 2001
From: Timo Heister <timo.heister@gmail.com>
Date: Mon, 6 May 2019 18:08:05 -0400
Subject: [PATCH] provide access to p4est_t

I need access for the p4est object inside a distributed Triangulation.
Provide an accessor function for this.
---
 include/deal.II/distributed/tria.h | 10 ++++++++++
 source/distributed/tria.cc         | 11 +++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/deal.II/distributed/tria.h b/include/deal.II/distributed/tria.h
index f373f7145f..eac6147b04 100644
--- a/include/deal.II/distributed/tria.h
+++ b/include/deal.II/distributed/tria.h
@@ -815,6 +815,16 @@ namespace parallel
       const std::vector<types::global_dof_index> &
       get_coarse_cell_to_p4est_tree_permutation() const;
 
+      /**
+       * This returns a pointer to the internally stored p4est object (of type
+       * p4est_t or p8est_t depending on @p dim).
+       *
+       * @warning: If you modify the p4est object, internal data structures
+       * can become inconsistent.
+       */
+      typename dealii::internal::p4est::types<dim>::forest *
+      get_p4est() const;
+
       /**
        * In addition to the action in the base class Triangulation, this
        * function joins faces in the p4est forest for periodic boundary
diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc
index f814270c31..ddbfa0fa3f 100644
--- a/source/distributed/tria.cc
+++ b/source/distributed/tria.cc
@@ -2887,6 +2887,17 @@ namespace parallel
 
 
 
+    template <int dim, int spacedim>
+    typename dealii::internal::p4est::types<dim>::forest *
+    Triangulation<dim, spacedim>::get_p4est() const
+    {
+      Assert(parallel_forest != nullptr,
+             ExcMessage("The forest has not been allocated yet."));
+      return parallel_forest;
+    }
+
+
+
     template <int dim, int spacedim>
     void
     Triangulation<dim, spacedim>::update_number_cache()
-- 
2.39.5