]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix compiling deal.II with PETSc and complex scalar type
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 13 Jun 2023 16:58:18 +0000 (12:58 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 13 Jun 2023 16:58:18 +0000 (12:58 -0400)
include/deal.II/numerics/vector_tools_mean_value.templates.h
source/lac/petsc_vector_base.cc

index 94de319928775d794f07d1527ccef300f202a25b..6a96f587189c01b820a0c4e08a8e308e8a1d1895 100644 (file)
@@ -209,7 +209,9 @@ namespace VectorTools
                         continue;
 
                       // Then adjust its value:
-                      solution(idx) = copy(idx) + constant_adjustment;
+                      solution(idx) =
+                        typename VectorType::value_type(copy(idx)) +
+                        constant_adjustment;
                     }
                 }
             }
index a3280a8b247402b1b32d407e08861fd944641ca9..8e1429a39979342418c2bd340b509fe9783bc161 100644 (file)
@@ -198,7 +198,7 @@ namespace PETScWrappers
       OutType
       operator*() const
       {
-        return static_cast<OutType>(*m_iterator);
+        return static_cast<OutType>(std::real(*m_iterator));
       }
 
       ConvertingIterator &
@@ -284,7 +284,10 @@ namespace PETScWrappers
         ghost_indices.set_size(this->size());
 
         if (std::is_sorted(&array[end_index - ghost_start_index],
-                           &array[n_elements_stored_locally]))
+                           &array[n_elements_stored_locally],
+                           [](PetscScalar left, PetscScalar right) {
+                             return std::real(left) < std::real(right);
+                           }))
           {
             ConvertingIterator<PetscScalar *, types::global_dof_index> start(
               &array[end_index - ghost_start_index]);
@@ -294,9 +297,14 @@ namespace PETScWrappers
           }
         else
           {
-            std::vector<PetscInt> sorted_indices(
-              &array[end_index - ghost_start_index],
-              &array[n_elements_stored_locally]);
+            std::vector<PetscInt> sorted_indices;
+            sorted_indices.reserve(n_elements_stored_locally -
+                                   (end_index - ghost_start_index));
+            for (PetscInt i = end_index - ghost_start_index;
+                 i < n_elements_stored_locally;
+                 ++i)
+              sorted_indices.push_back(
+                static_cast<types::global_dof_index>(std::real(array[i])));
             std::sort(sorted_indices.begin(), sorted_indices.end());
             ghost_indices.add_indices(sorted_indices.begin(),
                                       sorted_indices.end());

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.