]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Avoid compiler warning. Improve error message for parallel vector.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 19 Feb 2014 21:56:11 +0000 (21:56 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 19 Feb 2014 21:56:11 +0000 (21:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@32518 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/aligned_vector.h
deal.II/include/deal.II/lac/parallel_vector.h
deal.II/include/deal.II/lac/parallel_vector.templates.h

index 2916bcd0ba07b52739b8749a1fec24d6bb179fbc..0876e0f6fe10036dbc875aa355a3bee24cadabc3 100644 (file)
@@ -288,9 +288,13 @@ namespace internal
     virtual void apply_to_subrange (const std::size_t begin,
                                     const std::size_t end) const
     {
-      // for classes trivial assignment can use memcpy
+      // for classes trivial assignment can use memcpy. cast element to
+      // (void*) to silence compiler warning for virtual classes (they will
+      // never arrive here because they are non-trivial).
+
       if (std_cxx1x::is_trivial<T>::value == true)
-        std::memcpy (destination_+begin, source_+begin, (end-begin)*sizeof(T));
+        std::memcpy ((void*)(destination_+begin), source_+begin,
+                     (end-begin)*sizeof(T));
       else if (copy_only_ == false)
         for (std::size_t i=begin; i<end; ++i)
           {
@@ -339,7 +343,10 @@ namespace internal
       if (std_cxx1x::is_trivial<T>::value == true)
         {
           const unsigned char zero [sizeof(T)] = {};
-          if (std::memcmp(zero, &element, sizeof(T)) == 0)
+          // cast element to (void*) to silence compiler warning for virtual
+          // classes (they will never arrive here because they are
+          // non-trivial).
+          if (std::memcmp(zero, (void*)&element, sizeof(T)) == 0)
             trivial_element = true;
         }
       if (size < minimum_parallel_grain_size)
@@ -356,9 +363,12 @@ namespace internal
     virtual void apply_to_subrange (const std::size_t begin,
                                     const std::size_t end) const
     {
-      // for classes with trivial assignment of zero can use memset
+      // for classes with trivial assignment of zero can use memset. cast
+      // element to (void*) to silence compiler warning for virtual
+      // classes (they will never arrive here because they are
+      // non-trivial).
       if (std_cxx1x::is_trivial<T>::value == true && trivial_element)
-        std::memset (destination_+begin, 0, (end-begin)*sizeof(T));
+        std::memset ((void*)(destination_+begin), 0, (end-begin)*sizeof(T));
       else
         // initialize memory and set
         for (std::size_t i=begin; i<end; ++i)
index 126737eba779078c1d80dd0be70a4c916f6f9401..92259610afdf10a8dae225babe29262ed6141522 100644 (file)
@@ -932,6 +932,18 @@ namespace parallel
       std::size_t memory_consumption () const;
       //@}
 
+      /**
+       * Exception
+       */
+      DeclException3 (ExcNonMatchingElements,
+                      double, double, unsigned int,
+                      << "Called compress(VectorOperation::insert), but"
+                      << " the element received from a remote processor, value "
+                      << std::setprecision(16) << arg1
+                      << ", does not match with the value "
+                      << std::setprecision(16) << arg2
+                      << " on the owner processor " << arg3);
+
     private:
       /**
        * Local part of all_zero().
index 252c5b926cadb1abb53e3fe6ca823465e7783fa1..b053621bc78b955c40b4f03e1679dbf4c62a4d99 100644 (file)
@@ -454,7 +454,8 @@ namespace parallel
                        std::abs(local_element(j) - *read_position) <
                        std::abs(local_element(j)) * 1000. *
                        std::numeric_limits<Number>::epsilon(),
-                       ExcMessage("Inserted elements do not match."));
+                       ExcNonMatchingElements(*read_position, local_element(j),
+                                              part.this_mpi_process()));
           AssertDimension(read_position-import_data,part.n_import_indices());
         }
 

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.