]> https://gitweb.dealii.org/ - dealii.git/commitdiff
FEPointEvaluation/MappingInfo for simplices
authorPeter Munch <peterrmuench@gmail.com>
Sat, 5 Aug 2023 12:44:42 +0000 (14:44 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Wed, 23 Aug 2023 05:38:47 +0000 (07:38 +0200)
include/deal.II/matrix_free/fe_point_evaluation.h
include/deal.II/non_matching/mapping_info.h

index 4f71313c4668b28183d4c6f137b9810f03b2ca68..841adb4725368dd5f2f2534e04c6de163e44a19b 100644 (file)
@@ -1603,6 +1603,32 @@ FEPointEvaluation<n_components_, dim, spacedim, Number>::reinit(
   current_face_number = numbers::invalid_unsigned_int;
 
   do_reinit();
+
+  if (!fast_path)
+    {
+      const auto unit_points_vectorized = mapping_info->get_unit_point(
+        mapping_info->compute_unit_point_index_offset(current_cell_index,
+                                                      current_face_number));
+      const unsigned int n_q_points_unvectorized =
+        mapping_info->get_n_q_points_unvectorized(current_cell_index,
+                                                  current_face_number);
+
+      std::vector<Point<dim>> unit_points(n_q_points_unvectorized);
+
+      for (unsigned int v = 0; v < n_q_points_unvectorized; ++v)
+        for (unsigned int d = 0; d < dim; ++d)
+          unit_points[v][d] = unit_points_vectorized[v / n_lanes_internal][d]
+                                                    [v % n_lanes_internal];
+
+      fe_values = std::make_shared<FEValues<dim, spacedim>>(
+        *mapping,
+        *fe,
+        Quadrature<dim>(
+          std::vector<Point<dim>>(unit_points.begin(), unit_points.end())),
+        update_flags);
+
+      fe_values->reinit(mapping_info->get_cell_iterator(current_cell_index));
+    }
 }
 
 
index 532dbe635bb14869792ad6f789720d76f0d2c070..b8c571fd95bbdd1d988638a7fc25e20270acba02 100644 (file)
@@ -216,8 +216,10 @@ namespace NonMatching
       /**
        * Constructor which sets the default arguments.
        */
-      AdditionalData(const bool use_global_weights = false)
+      AdditionalData(const bool use_global_weights = false,
+                     const bool store_cells        = false)
         : use_global_weights(use_global_weights)
+        , store_cells(store_cells)
       {}
 
       /**
@@ -226,6 +228,15 @@ namespace NonMatching
        * QSimplex::compute_affine_transformation().
        */
       bool use_global_weights;
+
+      /**
+       * During the reinit() function calls, cells are passed as
+       * argument. In the default case, the cell is not stored,
+       * since all relevant mapping related information is precomputed.
+       * Hoever, this flag enables that the cells are stored so that
+       * they can be accessed later on.
+       */
+      bool store_cells;
     };
 
     /**
@@ -422,6 +433,14 @@ namespace NonMatching
     get_n_q_points_unvectorized(const unsigned int cell_index,
                                 const unsigned int face_number) const;
 
+    /**
+     * Return cell iterator.
+     *
+     * @note This call is only possible if AdditionalData::store_cells is enabled.
+     */
+    typename Triangulation<dim, spacedim>::cell_iterator
+    get_cell_iterator(const unsigned int cell_index) const;
+
   private:
     using MappingData =
       dealii::internal::FEValuesImplementation::MappingRelatedData<dim,
@@ -633,6 +652,19 @@ namespace NonMatching
      * dependent objects know that they need to reinitialize as well.
      */
     boost::signals2::signal<void()> is_reinitialized;
+
+    /**
+     * Reference to the triangulation passed via the cells to the
+     * reinit functions. This field is only set if
+     * AdditionalData::store_cells is enabled.
+     */
+    SmartPointer<const Triangulation<dim, spacedim>> triangulation;
+
+    /**
+     * Level and indices of cells passed to the reinit functions. This
+     * vector is only filled if AdditionalData::store_cells is enabled.
+     */
+    std::vector<std::pair<int, int>> cell_level_and_indices;
   };
 
   // ----------------------- template functions ----------------------
@@ -807,6 +839,9 @@ namespace NonMatching
 
     n_q_points_unvectorized.reserve(n_cells);
 
+    if (additional_data.store_cells)
+      cell_level_and_indices.resize(n_cells);
+
     // fill unit points index offset vector
     unit_points_index.reserve(n_cells + 1);
     unit_points_index.push_back(0);
@@ -844,6 +879,12 @@ namespace NonMatching
     unsigned int cell_index = 0;
     for (const auto &cell : cell_iterator_range)
       {
+        if (additional_data.store_cells)
+          {
+            this->triangulation                = &cell->get_triangulation();
+            cell_level_and_indices[cell_index] = {cell->level(), cell->index()};
+          }
+
         // store unit points
         const unsigned int n_q_points = compute_n_q_points<VectorizedArrayType>(
           n_q_points_unvectorized[cell_index]);
@@ -1164,6 +1205,22 @@ namespace NonMatching
 
 
 
+  template <int dim, int spacedim, typename Number>
+  typename Triangulation<dim, spacedim>::cell_iterator
+  MappingInfo<dim, spacedim, Number>::get_cell_iterator(
+    const unsigned int cell_index) const
+  {
+    Assert(
+      additional_data.store_cells,
+      ExcMessage(
+        "Cells have been not stored. You can enable this by Additional::store_cells."));
+    return {triangulation.get(),
+            cell_level_and_indices[cell_index].first,
+            cell_level_and_indices[cell_index].second};
+  }
+
+
+
   template <int dim, int spacedim, typename Number>
   template <typename NumberType>
   unsigned int

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.