]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Accelerated the addition into vectors a bit by directly calling the relevant functions.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 Nov 2008 13:02:31 +0000 (13:02 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 Nov 2008 13:02:31 +0000 (13:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@17675 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/trilinos_vector_base.h
deal.II/lac/source/trilinos_vector_base.cc

index 9b0e5f4b3914e6a20e510266d1ef2ed601a4ff5f..5a22e76ef1e6b5e639d4541d694404f1a564d911 100644 (file)
@@ -328,13 +328,7 @@ namespace TrilinosWrappers
                                        * vector, i.e., whether
                                        * compress() has already been
                                        * called after an operation
-                                       * requiring data exchange. Does
-                                       * only return non-true values
-                                       * when used in <tt>debug</tt>
-                                       * mode, since it is quite
-                                       * expensive to keep track of all
-                                       * operations that lead to a
-                                       * need for compress().
+                                       * requiring data exchange.
                                        */
       bool is_compressed () const;
 
index d4e62154bb71b652270dc1e8776288639a10f62f..7b8c83273937f4dc8e2da18ed04a7be3e55086af 100644 (file)
@@ -353,20 +353,23 @@ namespace TrilinosWrappers
     if (last_action != Insert)
       last_action = Insert;
 
-#ifdef DEBUG
+    int ierr;
     for (unsigned int i=0; i<n_elements; ++i)
-      if (in_local_range (indices[i]) == false)
-       {
-         compressed = false;
-         break;
-       }
-#endif
-      
-    const int ierr= vector->ReplaceGlobalValues (n_elements, 
-                              (int*)(const_cast<unsigned int*>(indices)), 
-                                     const_cast<TrilinosScalar*>(values));
-   
-    AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+      {
+       const unsigned int row = indices[i];
+       const int local_row = vector->Map().LID(indices[i]);
+       if (local_row == -1)
+         {
+           ierr = vector->ReplaceGlobalValues (1, 
+                                               (const int*)(&row), 
+                                               &values[i]);
+           compressed = false;
+         }
+       else
+         ierr = vector->ReplaceMyValue (local_row, 0, values[i]);
+
+       AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+      }
   }
 
 
@@ -406,20 +409,23 @@ namespace TrilinosWrappers
     if (last_action != Add)
       last_action = Add;
 
-#ifdef DEBUG
+    int ierr;
     for (unsigned int i=0; i<n_elements; ++i)
-      if (in_local_range (indices[i]) == false)
-       {
-         compressed = false;
-         break;
-       }
-#endif
-
-    const int ierr = vector->SumIntoGlobalValues (n_elements, 
-                                 (int*)(const_cast<unsigned int*>(indices)), 
-                                        const_cast<TrilinosScalar*>(values));
+      {
+       const unsigned int row = indices[i];
+       const int local_row = vector->Map().LID(indices[i]);
+       if (local_row == -1)
+         {
+           ierr = vector->SumIntoGlobalValues (1, 
+                                               (const int*)(&row), 
+                                               &values[i]);
+           compressed = false;
+         }
+       else
+         ierr = vector->SumIntoMyValue (local_row, 0, values[i]);
 
-    AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+       AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+      }
   }
 
 

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.