Fix get/submit_normal_derivative for arbitrary number of components
authorMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Fri, 21 Mar 2025 10:10:22 +0000 (11:10 +0100)
committerMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Mon, 24 Mar 2025 14:38:37 +0000 (15:38 +0100)
include/deal.II/matrix_free/fe_point_evaluation.h

index f0067851dd367c2ebf4a87692c9b283b62a5005e..27569a944fc250a709dc6537e666a974868698f9 100644 (file)
@@ -3200,7 +3200,17 @@ FEPointEvaluation<n_components_, dim, spacedim, Number>::get_normal_derivative(
   const unsigned int point_index) const
 {
   AssertIndexRange(point_index, this->gradients.size());
-  return this->gradients[point_index] * normal_vector(point_index);
+
+  value_type normal_derivative;
+  if constexpr (n_components == 1)
+    normal_derivative =
+      this->gradients[point_index] * normal_vector(point_index);
+  else
+    for (unsigned int comp = 0; comp < n_components; ++comp)
+      normal_derivative[comp] =
+        this->gradients[point_index][comp] * normal_vector(point_index);
+
+  return normal_derivative;
 }
 
 
@@ -3215,8 +3225,9 @@ FEPointEvaluation<n_components_, dim, spacedim, Number>::
   if constexpr (n_components == 1)
     this->gradients[point_index] = value * normal_vector(point_index);
   else
-    this->gradients[point_index] =
-      outer_product(value, normal_vector(point_index));
+    for (unsigned int comp = 0; comp < n_components; ++comp)
+      this->gradients[point_index][comp] =
+        value[comp] * normal_vector(point_index);
 }
 
 
@@ -3958,7 +3969,17 @@ FEFacePointEvaluation<n_components_, dim, spacedim, Number>::
   get_normal_derivative(const unsigned int point_index) const
 {
   AssertIndexRange(point_index, this->gradients.size());
-  return this->gradients[point_index] * normal_vector(point_index);
+
+  value_type normal_derivative;
+  if constexpr (n_components == 1)
+    normal_derivative =
+      this->gradients[point_index] * normal_vector(point_index);
+  else
+    for (unsigned int comp = 0; comp < n_components; ++comp)
+      normal_derivative[comp] =
+        this->gradients[point_index][comp] * normal_vector(point_index);
+
+  return normal_derivative;
 }
 
 
@@ -3973,8 +3994,9 @@ FEFacePointEvaluation<n_components_, dim, spacedim, Number>::
   if constexpr (n_components == 1)
     this->gradients[point_index] = value * normal_vector(point_index);
   else
-    this->gradients[point_index] =
-      outer_product(value, normal_vector(point_index));
+    for (unsigned int comp = 0; comp < n_components; ++comp)
+      this->gradients[point_index][comp] =
+        value[comp] * normal_vector(point_index);
 }
 
 DEAL_II_NAMESPACE_CLOSE

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.