]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix MatrixFree::loop() for the case where VectorType is not a vector 7803/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 13 Mar 2019 16:16:04 +0000 (17:16 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 13 Mar 2019 17:01:51 +0000 (18:01 +0100)
include/deal.II/matrix_free/matrix_free.h
source/matrix_free/task_info.cc
tests/matrix_free/matrix_free_type_traits.cc

index 4877be670b782c0772c815052e241dd6c3092c9d..65a2f533f5f8d721722fdbbee6c92251bb99f22c 100644 (file)
@@ -1436,7 +1436,6 @@ public:
    * Queries whether or not the geometry-related information for the cells has
    * been set.
    */
-
   bool
   mapping_initialized() const;
 
@@ -3321,13 +3320,15 @@ namespace internal
 
 
     /**
-     * Zero out vector region for vector that do _not_ support
-     * exchange on a subset of DoFs <==> begin() + ind == local_element(ind)
+     * Zero out vector region for vector that do _not_ support exchange on a
+     * subset of DoFs <==> begin() + ind == local_element(ind) but are still a
+     * vector type
      */
     template <
       typename VectorType,
       typename std::enable_if<!has_exchange_on_subset<VectorType>::value,
-                              VectorType>::type * = nullptr>
+                              VectorType>::type * = nullptr,
+      typename VectorType::value_type *           = nullptr>
     void
     zero_vector_region(const unsigned int range_index, VectorType &vec) const
     {
@@ -3341,6 +3342,20 @@ namespace internal
 
 
 
+    /**
+     * Zero out vector region for non-vector types, i.e., classes that do not
+     * have VectorType::value_type
+     */
+    void
+    zero_vector_region(const unsigned int, ...) const
+    {
+      Assert(false,
+             ExcNotImplemented("Zeroing is only implemented for vector types "
+                               "which provide VectorType::value_type"));
+    }
+
+
+
     const dealii::MatrixFree<dim, Number> &matrix_free;
     const typename dealii::MatrixFree<dim, Number>::DataAccessOnFaces
          vector_face_access;
index d60db786c86b0e91d1d32a712852a905638803b8..203fcad6ea72dc966395ca0f366dccfeda543518 100644 (file)
@@ -631,6 +631,7 @@ namespace internal
       n_blocks             = 0;
       scheme               = none;
       partition_row_index.clear();
+      partition_row_index.resize(2);
       cell_partition_data.clear();
       face_partition_data.clear();
       boundary_partition_data.clear();
index fb0f597c0c64ab950afa5d174c59aaedacc3dead..4ea0771d0bd2dcc9c986961074b625a0d46aefaf 100644 (file)
@@ -90,5 +90,16 @@ main()
           << "unsigned int = "
           << internal::is_serial_or_dummy<unsigned int>::value << std::endl;
 
+  // check that MatrixFree::cell_loop can run for non-vector types
+  MatrixFree<2> matrix_free;
+  int           dummy = 0;
+  matrix_free.cell_loop(
+    std::function<void(const MatrixFree<2> &,
+                       int &,
+                       const int &,
+                       const std::pair<unsigned int, unsigned int> &)>(),
+    dummy,
+    dummy);
+
   deallog << "OK" << std::endl;
 }

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.