]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Enable internal::DoFHandlerImplementation::Policy::ParallelDistributed for 1D 8587/head
authorPeter Munch <peterrmuench@gmail.com>
Fri, 16 Aug 2019 04:14:20 +0000 (06:14 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Wed, 21 Aug 2019 15:27:51 +0000 (17:27 +0200)
doc/news/changes/minor/20190816PeterMunch [new file with mode: 0644]
include/deal.II/distributed/p4est_wrappers.h
source/distributed/p4est_wrappers.cc

diff --git a/doc/news/changes/minor/20190816PeterMunch b/doc/news/changes/minor/20190816PeterMunch
new file mode 100644 (file)
index 0000000..f8d8d4f
--- /dev/null
@@ -0,0 +1,3 @@
+New: Enable internal::DoFHandlerImplementation::Policy::ParallelDistributed for 1D.
+<br>
+(Peter Munch, 2019/08/16)
index 5f4e228d56bd1dc11825bb5ca4434d80d05af201..54fa37c2f3f555038ee5d0a4c807ff4befa6324a 100644 (file)
@@ -64,6 +64,20 @@ namespace internal
     template <int>
     struct types;
 
+    // these struct mimics p4est for 1D
+    template <>
+    struct types<1>
+    {
+      // id of a quadrant is an integeger
+      using quadrant = int;
+
+      // maximum number of children
+      static const int max_n_child_indices_bits = 27;
+
+      // number of bits the data type of id has
+      static const int n_bits = std::numeric_limits<quadrant>::digits;
+    };
+
     template <>
     struct types<2>
     {
index b8bd84bc3affe73dd7f551aa53e7f439017d5c8f..d71f6fc9b6c5e655e6d9e2dc384c0c09dd1d1814 100644 (file)
@@ -834,6 +834,73 @@ namespace internal
       return ((coarse_grid_cell >= parallel_forest->first_local_tree) &&
               (coarse_grid_cell <= parallel_forest->last_local_tree));
     }
+
+
+
+    template <>
+    bool
+    quadrant_is_equal<1>(const typename types<1>::quadrant &q1,
+                         const typename types<1>::quadrant &q2)
+    {
+      return q1 == q2;
+    }
+
+
+
+    template <>
+    bool quadrant_is_ancestor<1>(types<1>::quadrant const &q1,
+                                 types<1>::quadrant const &q2)
+    {
+      // determine level of quadrants
+      const int level_1 = (q1 << types<1>::max_n_child_indices_bits) >>
+                          types<1>::max_n_child_indices_bits;
+      const int level_2 = (q2 << types<1>::max_n_child_indices_bits) >>
+                          types<1>::max_n_child_indices_bits;
+
+      // q1 can be an ancestor of q2 if q1's level is smaller
+      if (level_1 >= level_2)
+        return false;
+
+      // extract path of quadrants up to level of possible ancestor q1
+      const int truncated_id_1 = (q1 >> (types<1>::n_bits - 1 - level_1))
+                                 << (types<1>::n_bits - 1 - level_1);
+      const int truncated_id_2 = (q2 >> (types<1>::n_bits - 1 - level_1))
+                                 << (types<1>::n_bits - 1 - level_1);
+
+      // compare paths
+      return truncated_id_1 == truncated_id_2;
+    }
+
+
+
+    template <>
+    void
+    init_quadrant_children<1>(
+      const typename types<1>::quadrant &q,
+      typename types<1>::quadrant (
+        &p4est_children)[dealii::GeometryInfo<1>::max_children_per_cell])
+    {
+      // determine the current level of quadrant
+      const int level_parent = (q << types<1>::max_n_child_indices_bits) >>
+                               types<1>::max_n_child_indices_bits;
+      const int level_child = level_parent + 1;
+
+      // left child: only n_child_indices has to be incremented
+      p4est_children[0] = (q + 1);
+
+      // right child: increment and set a bit to 1 indicating that it is a right
+      // child
+      p4est_children[1] = (q + 1) | (1 << (types<1>::n_bits - 1 - level_child));
+    }
+
+
+
+    template <>
+    void init_coarse_quadrant<1>(typename types<1>::quadrant &quad)
+    {
+      quad = 0;
+    }
+
   } // namespace p4est
 } // namespace internal
 

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.