]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce RefinementCase::all_refinement_cases().
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 26 Oct 2023 19:58:10 +0000 (13:58 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 26 Oct 2023 19:58:10 +0000 (13:58 -0600)
include/deal.II/base/geometry_info.h

index 185a188fa071135b64337f4d83da30908d7770d3..211009c88b4773f56af960010dc430b1f557bcc2 100644 (file)
@@ -789,6 +789,11 @@ template <int dim>
 class RefinementCase : public RefinementPossibilities<dim>
 {
 public:
+  /**
+   * A variable indicating the number of possible refinement cases.
+   */
+  static constexpr unsigned int n_refinement_cases = (1 << dim);
+
   /**
    * Default constructor. Initialize the refinement case with no_refinement.
    */
@@ -854,6 +859,17 @@ public:
   static RefinementCase
   cut_axis(const unsigned int i);
 
+  /**
+   * Return an array that lists all possible refinement cases possible in
+   * the given space dimension. For example, for `dim==1`, it returns an
+   * array that only contains `{ RefinementCase<1>::no_refinement,
+   * RefinementCase<1>::cut_x }`. In `dim==2`, it returns
+   * `{ RefinementCase<1>::no_refinement, RefinementCase<2>::cut_x,
+   * RefinementCase<2>::cut_y, RefinementCase<2>::cut_xy }`.
+   */
+  static std::array<RefinementCase<dim>, n_refinement_cases>
+  all_refinement_cases();
+
   /**
    * Return the amount of memory occupied by an object of this type.
    */
@@ -888,6 +904,7 @@ private:
 };
 
 
+
 namespace internal
 {
   /**
@@ -2774,6 +2791,44 @@ RefinementCase<3>::cut_axis(const unsigned int i)
 
 
 
+template <>
+inline std::array<RefinementCase<1>, 2>
+RefinementCase<1>::all_refinement_cases()
+{
+  return {{RefinementPossibilities<1>::no_refinement,
+           RefinementPossibilities<1>::cut_x}};
+}
+
+
+
+template <>
+inline std::array<RefinementCase<2>, 4>
+RefinementCase<2>::all_refinement_cases()
+{
+  return {{RefinementPossibilities<2>::no_refinement,
+           RefinementPossibilities<2>::cut_x,
+           RefinementPossibilities<2>::cut_y,
+           RefinementPossibilities<2>::cut_xy}};
+}
+
+
+
+template <>
+inline std::array<RefinementCase<3>, 8>
+RefinementCase<3>::all_refinement_cases()
+{
+  return {{RefinementPossibilities<3>::no_refinement,
+           RefinementPossibilities<3>::cut_x,
+           RefinementPossibilities<3>::cut_y,
+           RefinementPossibilities<3>::cut_xy,
+           RefinementPossibilities<3>::cut_z,
+           RefinementPossibilities<3>::cut_xz,
+           RefinementPossibilities<3>::cut_yz,
+           RefinementPossibilities<3>::cut_xyz}};
+}
+
+
+
 template <int dim>
 inline RefinementCase<dim>::RefinementCase()
   : value(RefinementPossibilities<dim>::no_refinement)

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.