]> https://gitweb.dealii.org/ - dealii.git/commitdiff
FEEvaluation: Fix two places where the address sanitizer complained 14154/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Wed, 20 Jul 2022 16:14:31 +0000 (18:14 +0200)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Wed, 20 Jul 2022 16:14:31 +0000 (18:14 +0200)
include/deal.II/matrix_free/fe_evaluation.h

index 2ed29508a4972bb623a70b77a778d4e246097021..16a639c76b0891f2cd3c7bf36a8a341083e028bf 100644 (file)
@@ -4118,7 +4118,7 @@ namespace internal
             std::enable_if_t<has_shared_vector_data<VectorType>, VectorType> * =
               nullptr>
   const std::vector<ArrayView<const typename VectorType::value_type>> *
-  get_shared_vector_data(VectorType &       vec,
+  get_shared_vector_data(VectorType *       vec,
                          const bool         is_valid_mode_for_sm,
                          const unsigned int active_fe_index,
                          const internal::MatrixFreeFunctions::DoFInfo *dof_info)
@@ -4128,7 +4128,7 @@ namespace internal
         dof_info->dof_indices_contiguous_sm[0 /*any index (<3) should work*/]
             .size() > 0 &&
         active_fe_index == 0)
-      return &vec.shared_vector_data();
+      return &vec->shared_vector_data();
     else
       return nullptr;
   }
@@ -4137,7 +4137,7 @@ namespace internal
             std::enable_if_t<!has_shared_vector_data<VectorType>, VectorType>
               * = nullptr>
   const std::vector<ArrayView<const typename VectorType::value_type>> *
-  get_shared_vector_data(VectorType &,
+  get_shared_vector_data(VectorType *,
                          const bool,
                          const unsigned int,
                          const internal::MatrixFreeFunctions::DoFInfo *)
@@ -4189,7 +4189,7 @@ namespace internal
         const_cast<typename internal::BlockVectorSelector<
           typename std::remove_const<VectorType>::type,
           IsBlockVector<typename std::remove_const<VectorType>::type>::value>::
-                     BaseVectorType &>(*src_data.first[d]),
+                     BaseVectorType *>(src_data.first[d]),
         is_valid_mode_for_sm,
         active_fe_index,
         dof_info);
@@ -7377,8 +7377,6 @@ FEEvaluation<dim,
   Assert(this->mapped_geometry == nullptr,
          ExcMessage("FEEvaluation was initialized without a matrix-free object."
                     " Integer indexing is not possible"));
-  if (this->mapped_geometry != nullptr)
-    return;
 
   Assert(this->dof_info != nullptr, ExcNotInitialized());
   Assert(this->mapping_data != nullptr, ExcNotInitialized());
@@ -7390,10 +7388,13 @@ FEEvaluation<dim,
     this->mapping_data->data_index_offsets[cell_index];
   this->jacobian = &this->mapping_data->jacobians[0][offsets];
   this->J_value  = &this->mapping_data->JxW_values[offsets];
-  this->jacobian_gradients =
-    this->mapping_data->jacobian_gradients[0].data() + offsets;
-  this->jacobian_gradients_non_inverse =
-    this->mapping_data->jacobian_gradients_non_inverse[0].data() + offsets;
+  if (!this->mapping_data->jacobian_gradients[0].empty())
+    {
+      this->jacobian_gradients =
+        this->mapping_data->jacobian_gradients[0].data() + offsets;
+      this->jacobian_gradients_non_inverse =
+        this->mapping_data->jacobian_gradients_non_inverse[0].data() + offsets;
+    }
 
   unsigned int i = 0;
   for (; i < this->matrix_free->n_active_entries_per_cell_batch(this->cell);
@@ -8921,7 +8922,7 @@ FEFaceEvaluation<dim,
                     "and EvaluationFlags::hessians are supported."));
 
   const auto shared_vector_data = internal::get_shared_vector_data(
-    input_vector,
+    &input_vector,
     this->dof_access_index ==
       internal::MatrixFreeFunctions::DoFInfo::dof_access_cell,
     this->active_fe_index,
@@ -9038,7 +9039,7 @@ FEFaceEvaluation<dim,
          ExcNotImplemented());
 
   const auto shared_vector_data = internal::get_shared_vector_data(
-    destination,
+    &destination,
     this->dof_access_index ==
       internal::MatrixFreeFunctions::DoFInfo::dof_access_cell,
     this->active_fe_index,

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.