]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a function to the vector.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 4 Sep 2008 07:52:08 +0000 (07:52 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 4 Sep 2008 07:52:08 +0000 (07:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@16741 0785d39b-7218-0410-832d-ea1e28bc413d

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

index f5902e11ecf3edbec6cbf3a8c8882cecf866d410..f50e7884251b0fb7ba5ce7f309062bb2eabf6003 100755 (executable)
@@ -329,7 +329,7 @@ namespace TrilinosWrappers
       Vector ();
                                        /**
                                         * One of the constructors that
-                                       * actually build a vector. This
+                                       * actually builds a vector. This
                                        * one requires prior knowledge
                                         * of the size of the vector and
                                        * a communicator from 
@@ -341,16 +341,17 @@ namespace TrilinosWrappers
                                        * from the beginning to the end, 
                                        * so you might want to use some
                                        * more advanced mapping and the
-                                       * third constructor with argument
+                                       * constructor with argument
                                        * Epetra_Map.
                                         */
       Vector (unsigned int GlobalSize, Epetra_Comm &Comm);
 
                                        /**
-                                       * Third constructor. It takes an
+                                       * This constructor takes an
                                        * Epetra_Map that already knows how
                                        * to distribute the individual 
-                                       * components among the MPI processors.
+                                       * components among the MPI processors,
+                                       * including the size of the vector.
                                         */
       Vector (const Epetra_Map &InputMap);
 
@@ -358,7 +359,7 @@ namespace TrilinosWrappers
                                         * Copy constructor. Sets the dimension
                                         * to that of the given vector and uses
                                        * the map of that vector, but
-                                        * does not copies any element. Instead,
+                                        * does not copy any element. Instead,
                                        * the memory will remain untouched
                                        * in case <tt>fast</tt> is false and
                                        * initialized with zero otherwise.
@@ -490,8 +491,7 @@ namespace TrilinosWrappers
                                        * a pair (i,i+n), where
                                        * <tt>n=local_size()</tt>.
                                        */
-      std::pair<unsigned int, unsigned int>
-      local_range () const;
+      std::pair<unsigned int, unsigned int> local_range () const;
 
                                       /**
                                        * Return whether @p index is
@@ -545,8 +545,8 @@ namespace TrilinosWrappers
                                        * function takes a deal.II vector
                                        * of values.
                                        */
-      void set (const std::vector<unsigned int>      &indices,
-               const dealii::Vector<TrilinosScalar> &values);
+      void set (const std::vector<unsigned int>        &indices,
+               const ::dealii::Vector<TrilinosScalar> &values);
 
                                        /**
                                        * This collective set operation is
@@ -567,16 +567,30 @@ namespace TrilinosWrappers
                                        * stored in @p values to the vector
                                        * components specified by @p indices.
                                         */
-      void add (const std::vector<unsigned int> &indices,
-               const std::vector<TrilinosScalar>  &values);
+      void add (const std::vector<unsigned int>   &indices,
+               const std::vector<TrilinosScalar> &values);
 
+                                      /**
+                                       * This is a second collective add 
+                                       * operation. As a difference, this
+                                       * function takes a deal.II vector
+                                       * of values.
+                                       */
+      void add (const std::vector<unsigned int>        &indices,
+               const ::dealii::Vector<TrilinosScalar> &values);
+
+                                     /**
+                                      * Take an address where n_elements
+                                      * are stored contiguously and add
+                                      * them into the vector.
+                                      */
       void add (const unsigned int    n_elements,
                const unsigned int   *indices,
                const TrilinosScalar *values);
 
                                        /**
-                                        * Return the scalar/inner product of two
-                                        * vectors. The vectors must have the
+                                        * Return the scalar (inner) product of
+                                        * two vectors. The vectors must have the
                                         * same size.
                                         */
       TrilinosScalar operator * (const Vector &vec) const;
@@ -673,7 +687,7 @@ namespace TrilinosWrappers
 
                                        /**
                                         * Simple vector addition, equal to the
-                                        * <tt>operator =</tt>.
+                                        * <tt>operator +=</tt>.
                                         */
       void add (const Vector &V);
 
@@ -865,6 +879,7 @@ namespace TrilinosWrappers
       std::auto_ptr<Epetra_FEVector> vector;
 
 
+    private:
                                        /**
                                         * Trilinos doesn't allow to mix additions
                                         * to matrix entries and overwriting
index 09d6bfd169d0cbe5732c18cbfef01f9d4dc6f384..bd99c0eeaa1cb36129e5cc53141f4b5d55861d54 100755 (executable)
@@ -95,7 +95,7 @@ namespace TrilinosWrappers
   {
     vector.reset();
     map = input_map;
-    
+
     vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(input_map));
     last_action = Insert;
   }
@@ -107,10 +107,10 @@ namespace TrilinosWrappers
                  const bool    fast)
   {
     vector.reset();
-    
+
     if (!map.SameAs(v.map))
       map = v.map;
-    
+
     vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(v.map,!fast));
     last_action = Insert;
   }
@@ -151,7 +151,8 @@ namespace TrilinosWrappers
   {
 
     Assert (numbers::is_finite(s),
-           ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
+           ExcMessage("The given value is not finite but either "
+                      "infinite or Not A Number (NaN)"));
 
     const int ierr = vector->PutScalar(s);
 
@@ -169,7 +170,8 @@ namespace TrilinosWrappers
             ExcDimensionMismatch(size(), v.size()));
     unsigned int i;
     for (i=0; i<size(); i++) 
-      if ((*(v.vector))[i]!=(*vector)[i]) return false;
+      if ((*(v.vector))[0][i]!=(*vector)[0][i]) return false;
+
     return true;
   }
 
@@ -227,22 +229,36 @@ namespace TrilinosWrappers
       }
     else
       value = (*vector)[0][trilinos_i];
-    
+
     return value;
   }
 
 
+
   void
   Vector::set (const std::vector<unsigned int>    &indices,
               const std::vector<TrilinosScalar>  &values)
   {
     Assert (indices.size() == values.size(),
-           ExcMessage ("Function called with arguments of different sizes"));
-    
+           ExcDimensionMismatch(indices.size(),values.size()));
+
     set (indices.size(), &indices[0], &values[0]);
   }
 
-  
+
+
+  void
+  Vector::set (const std::vector<unsigned int>        &indices,
+              const ::dealii::Vector<TrilinosScalar> &values)
+  {
+    Assert (indices.size() == values.size(),
+           ExcDimensionMismatch(indices.size(),values.size()));
+
+    set (indices.size(), &indices[0], values.begin());
+  }
+
+
+
   void
   Vector::set (const unsigned int    n_elements,
               const unsigned int   *indices,
@@ -261,19 +277,31 @@ namespace TrilinosWrappers
   }
 
 
-  
+
   void
   Vector::add (const std::vector<unsigned int>    &indices,
               const std::vector<TrilinosScalar>  &values)
   {
     Assert (indices.size() == values.size(),
-           ExcMessage ("Function called with arguments of different sizes"));
-    
+           ExcDimensionMismatch(indices.size(),values.size()));
+
     add (indices.size(), &indices[0], &values[0]);
   }
 
-  
-  
+
+
+  void
+  Vector::add (const std::vector<unsigned int>        &indices,
+              const ::dealii::Vector<TrilinosScalar> &values)
+  {
+    Assert (indices.size() == values.size(),
+           ExcDimensionMismatch(indices.size(),values.size()));
+
+    add (indices.size(), &indices[0], values.begin());
+  }
+
+
+
   void
   Vector::add (const unsigned int    n_elements,
               const unsigned int   *indices,
@@ -321,11 +349,9 @@ namespace TrilinosWrappers
   TrilinosScalar
   Vector::mean_value () const
   {
-
     TrilinosScalar mean;
-    int ierr;
 
-    ierr = vector->MeanValue (&mean);
+    const int ierr = vector->MeanValue (&mean);
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
     return mean;

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.