From: Peter Munch Date: Fri, 16 Aug 2019 04:14:20 +0000 (+0200) Subject: Enable internal::DoFHandlerImplementation::Policy::ParallelDistributed for 1D X-Git-Tag: v9.2.0-rc1~1204^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=289709f070a6d4532e4a90eb3415d29272adcf9d;p=dealii.git Enable internal::DoFHandlerImplementation::Policy::ParallelDistributed for 1D --- diff --git a/doc/news/changes/minor/20190816PeterMunch b/doc/news/changes/minor/20190816PeterMunch new file mode 100644 index 0000000000..f8d8d4f682 --- /dev/null +++ b/doc/news/changes/minor/20190816PeterMunch @@ -0,0 +1,3 @@ +New: Enable internal::DoFHandlerImplementation::Policy::ParallelDistributed for 1D. +
+(Peter Munch, 2019/08/16) diff --git a/include/deal.II/distributed/p4est_wrappers.h b/include/deal.II/distributed/p4est_wrappers.h index 5f4e228d56..54fa37c2f3 100644 --- a/include/deal.II/distributed/p4est_wrappers.h +++ b/include/deal.II/distributed/p4est_wrappers.h @@ -64,6 +64,20 @@ namespace internal template 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::digits; + }; + template <> struct types<2> { diff --git a/source/distributed/p4est_wrappers.cc b/source/distributed/p4est_wrappers.cc index b8bd84bc3a..d71f6fc9b6 100644 --- a/source/distributed/p4est_wrappers.cc +++ b/source/distributed/p4est_wrappers.cc @@ -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