]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Introduce a temporary vector in the Trilinos SparseMatrix class that is used for...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 27 Sep 2008 11:12:43 +0000 (11:12 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 27 Sep 2008 11:12:43 +0000 (11:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@17018 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 315f6e3d1b5e3e99c32c397428b938151c660f4a..3ea0425fa3b177691830ca21260d9ec080e378f7 100755 (executable)
@@ -1461,6 +1461,16 @@ namespace TrilinosWrappers
                                        */
       bool compressed;
 
+                                      /**
+                                       * An internal Trilinos vector
+                                       * that is used for
+                                       * accelerating vmult_add
+                                       * functions (do not need to
+                                       * allocate too many temporary
+                                       * vectors).
+                                       */
+      mutable VectorBase temp_vector;
+
     public:
                                        /**
                                         * A sparse matrix object in
index 0f8a43f187576179efebaad3219b5a4c609e7446..9e3ef01181fdf462a5c1c947d763047a8ba34cf7 100755 (executable)
@@ -914,9 +914,10 @@ namespace TrilinosWrappers
   {
     Assert (&src != &dst, ExcSourceEqualsDestination());
 
-    VectorBase tmp(dst);
+    temp_vector.reinit(dst);
+
     vmult (dst, src);
-    dst += tmp;
+    dst += temp_vector;
   }
 
 
@@ -927,9 +928,10 @@ namespace TrilinosWrappers
   {
     Assert (&src != &dst, ExcSourceEqualsDestination());
 
-    VectorBase tmp(dst);
+    temp_vector.reinit(dst);
+
     vmult (dst, src);
-    dst += tmp;
+    dst += temp_vector;
   }
 
 
@@ -937,9 +939,14 @@ namespace TrilinosWrappers
   TrilinosScalar
   SparseMatrix::matrix_norm_square (const VectorBase &v) const
   {
-    VectorBase tmp (v);
-    vmult (tmp, v);
-    return tmp*v;
+    Assert (row_map.SameAs(col_map),
+           ExcDimensionMismatch(row_map.NumGlobalElements(),
+                                col_map.NumGlobalElements()));
+
+    temp_vector.reinit(v);
+
+    vmult (temp_vector, v);
+    return temp_vector*v;
   }
 
 
@@ -948,9 +955,14 @@ namespace TrilinosWrappers
   SparseMatrix::matrix_scalar_product (const VectorBase &u,
                                       const VectorBase &v) const
   {
-    VectorBase tmp (v);
-    vmult (tmp, v);
-    return u*tmp;
+    Assert (row_map.SameAs(col_map),
+           ExcDimensionMismatch(row_map.NumGlobalElements(),
+                                col_map.NumGlobalElements()));
+
+    temp_vector.reinit(v);
+
+    vmult (temp_vector, v);
+    return u*temp_vector;
   }
 
 

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.