]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Updated version of Trilinos wrappers.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 23 Aug 2008 00:56:06 +0000 (00:56 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 23 Aug 2008 00:56:06 +0000 (00:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@16659 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/trilinos_block_sparse_matrix.h
deal.II/lac/include/lac/trilinos_block_vector.h
deal.II/lac/include/lac/trilinos_precondition_amg.h
deal.II/lac/include/lac/trilinos_sparse_matrix.h
deal.II/lac/include/lac/trilinos_vector.h
deal.II/lac/source/trilinos_block_sparse_matrix.cc
deal.II/lac/source/trilinos_precondition_amg.cc
deal.II/lac/source/trilinos_vector.cc
deal.II/lac/source/vector_memory.cc

index 99f2caab4c1dd7dff633913cadfddb843157a443..b2ee84f753881ccb8789a51d03fcaf46e9f218dd 100644 (file)
@@ -17,6 +17,7 @@
 #include <base/config.h>
 #include <base/table.h>
 #include <lac/block_matrix_base.h>
+#include <lac/block_sparsity_pattern.h>
 #include <lac/trilinos_sparse_matrix.h>
 #include <lac/trilinos_block_vector.h>
 #include <lac/exceptions.h>
@@ -177,7 +178,8 @@ namespace TrilinosWrappers
                                        * assumes that a quadratic block
                                        * matrix is generated.
                                         */
-      //void reinit (const std::vector<Epetra_Map> &input_maps);
+      void reinit (const std::vector<Epetra_Map> &input_maps,
+                  const BlockSparsityPattern    &block_sparsity_pattern);
 
                                       /** 
                                        * This function calls the compress()
index 4f25d2ed03c3e75dffb2450e78d03abf58e02217..61547947b0a82e5f075ef87a40dc8eddc63d89c7 100644 (file)
@@ -255,7 +255,7 @@ namespace TrilinosWrappers
 
 
     inline
-    BlockVector::BlockVector (const unsigned int num_blocks = 0)
+    BlockVector::BlockVector (const unsigned int num_blocks)
     {
       reinit (num_blocks);
     }
index 1ecf56904799cc56c464e440e9fedb0ac5d42977..919fe922f97e1323c3f09b554d51473a5d10f903 100755 (executable)
@@ -98,11 +98,11 @@ namespace TrilinosWrappers
                                        * TrilinosWrappers::SparseMatrix.
                                        */
       void initialize (const SparseMatrix        &matrix,
-                      const std::vector<double> &null_space,
-                      const unsigned int         null_space_dimension,
-                      const bool                 higher_order_elements,
-                      const bool                 elliptic,
-                      const bool                 output_details);
+                      const bool                 elliptic = true,
+                      const bool                 higher_order_elements = false,
+                      const std::vector<double> &null_space = std::vector<double>(),
+                      const unsigned int         null_space_dimension = 1,
+                      const bool                 output_details = false);
 
                                       /**
                                        * Let Trilinos compute a
@@ -116,11 +116,11 @@ namespace TrilinosWrappers
                                        * inefficient.
                                        */
       void initialize (const dealii::SparseMatrix<double> &matrix,
-                      const std::vector<double>  &null_space,
-                      const unsigned int          null_space_dimension,
-                      const bool                  higher_order_elements,
-                      const bool                  elliptic,
-                      const bool                  output_details);
+                      const bool                 elliptic = true,
+                      const bool                 higher_order_elements = false,
+                      const std::vector<double> &null_space = std::vector<double>(),
+                      const unsigned int         null_space_dimension = 1,
+                      const bool                 output_details = false);
 
                                       /**
                                        * This function can be used 
index f3e432bc2a9dbc16059628ae309320b24dfab32d..3285cc6a638a4c4071a85059fdceef8d41b36dd4 100755 (executable)
@@ -442,7 +442,7 @@ namespace TrilinosWrappers
                                         */
       void reinit (const Epetra_Map                     &input_map,
                   const ::dealii::SparseMatrix<double> &deal_ii_sparse_matrix,
-                  const double                          drop_tolerance=1e-15);
+                  const double                          drop_tolerance=1e-13);
 
                                       /**
                                         * This function is similar to the
index a887ebc37dd6ebff1b29be6dccc7db71179d60d0..7b9e151a6d11fdb7afb689600a0ec609554b30d8 100755 (executable)
@@ -359,10 +359,14 @@ namespace TrilinosWrappers
                                        /**
                                         * Copy constructor. Sets the dimension
                                         * to that of the given vector and uses
-                                       * the map of that vector, and
-                                        * copies all elements.
+                                       * the map of that vector, but
+                                        * does not copies any element. Instead,
+                                       * the memory will remain untouched
+                                       * in case <tt>fast</tt> is false and
+                                       * initialized with zero otherwise.
                                         */
-      Vector (const Vector &v);
+      Vector (const Vector &v, 
+             const bool    fast = false);
 
                                        /**
                                         * Destructor
@@ -382,7 +386,8 @@ namespace TrilinosWrappers
                                        * copies the vector v to the current
                                        * one.
                                        */
-      void reinit (const Vector &v);
+      void reinit (const Vector &v,
+                  const bool    fast = false);
 
                                        /**
                                         * Release all memory and return
@@ -812,6 +817,13 @@ namespace TrilinosWrappers
                                         */
       void swap (Vector &v);
 
+                                      /**
+                                       * Estimate for the memory
+                                       * consumption (not implemented
+                                       * for this class).
+                                       */
+      unsigned int memory_consumption () const;
+
                                       /**
                                        * Exception
                                        */
@@ -994,7 +1006,16 @@ namespace TrilinosWrappers
   {
                                    // if the vectors have different sizes,
                                    // then first resize the present one
-    reinit (v);
+    if (!map.SameAs(v.map))
+      {
+       map = v.map;
+         vector = std::auto_ptr<Epetra_FEVector> 
+                       (new Epetra_FEVector(*v.vector));
+      }
+    else
+      *vector = *v.vector;
+         
+    last_action = Insert;
     
     return *this;
   }
index 6d486470e8ff4c5304188bf2fda49bed910cb212..08b3009734e2b24b1575fa5ee9cba7e630a6c22f 100644 (file)
@@ -51,6 +51,7 @@ namespace TrilinosWrappers
   }
 
 
+
   void
   BlockSparseMatrix::
   reinit (const unsigned int n_block_rows,
@@ -85,7 +86,31 @@ namespace TrilinosWrappers
         }
   }
 
-  
+
+
+  void
+  BlockSparseMatrix::
+  reinit (const std::vector<Epetra_Map> &input_maps,
+         const BlockSparsityPattern    &block_sparsity_pattern)
+  {
+    const unsigned int n_block_rows = input_maps.size();
+    
+                                    // Call the other reinit function ...
+    reinit (n_block_rows, n_block_rows);
+       
+                                    // ... and now assign the correct
+                                    // blocks.
+
+    for (unsigned int r=0; r<this->n_block_rows(); ++r)
+      for (unsigned int c=0; c<this->n_block_cols(); ++c)
+        {
+          this->block(r,c).reinit(input_maps[r],input_maps[c],
+                                 block_sparsity_pattern.block(r,c));
+        }
+  }
+
+
+
   void
   BlockSparseMatrix::compress()
   {
index ca338ed565c52fd04949cb3c0880d5663b4435e3..5791c8a2fce8a9097fceda02488cfa7243df9b8e 100755 (executable)
@@ -44,21 +44,13 @@ namespace TrilinosWrappers
   void
   PreconditionAMG::
   initialize (const SparseMatrix        &matrix,
-             const std::vector<double> &null_space,
-             const unsigned int         null_space_dimension,
              const bool                 elliptic,
              const bool                 higher_order_elements,
+             const std::vector<double> &null_space,
+             const unsigned int         null_space_dimension,
              const bool                 output_details)
   {
     const unsigned int n_rows = matrix.m();
-    
-    if (!Matrix)
-      {
-       Matrix = boost::shared_ptr<SparseMatrix>
-                         (const_cast<SparseMatrix*>(&matrix));
-       Map = boost::shared_ptr<Epetra_Map>
-                         (const_cast<Epetra_Map*>(&matrix.row_map));
-      }
 
                                     // Build the AMG preconditioner.
     Teuchos::ParameterList parameter_list;
@@ -76,6 +68,8 @@ namespace TrilinosWrappers
        parameter_list.set("aggregation: block scaling", true);
       }
   
+    parameter_list.set("aggregation: threshold", 1e-12);
+    
     if (output_details)
       parameter_list.set("ML output", 10);
     else
@@ -84,12 +78,12 @@ namespace TrilinosWrappers
     if (higher_order_elements)
       parameter_list.set("aggregation: type", "MIS");
   
-    Assert (n_rows * null_space_dimension == null_space.size(),
-           ExcDimensionMismatch(n_rows * null_space_dimension,
-                                null_space.size()));
-  
     if (null_space_dimension > 1)
       {
+       Assert (n_rows * null_space_dimension == null_space.size(),
+               ExcDimensionMismatch(n_rows * null_space_dimension,
+                                   null_space.size()));
+  
        parameter_list.set("null space: type", "pre-computed");
        parameter_list.set("null space: dimension", int(null_space_dimension));
        parameter_list.set("null space: vectors", (double *)&null_space[0]);
@@ -108,10 +102,10 @@ namespace TrilinosWrappers
   void
   PreconditionAMG::
   initialize (const dealii::SparseMatrix<double> &deal_ii_sparse_matrix,
-             const std::vector<double>  &null_space,
-             const unsigned int          null_space_dimension,
              const bool                  elliptic,
              const bool                  higher_order_elements,
+             const std::vector<double>  &null_space,
+             const unsigned int          null_space_dimension,
              const bool                  output_details)
   {
     const unsigned int n_rows = deal_ii_sparse_matrix.m();
@@ -127,8 +121,8 @@ namespace TrilinosWrappers
     Matrix->reinit (*Map, deal_ii_sparse_matrix);
     Matrix->compress();
 
-    initialize (*Matrix, null_space, null_space_dimension, elliptic,
-               higher_order_elements, output_details);
+    initialize (*Matrix, elliptic, higher_order_elements, null_space,
+               null_space_dimension,  output_details);
   }
   
   
@@ -143,7 +137,8 @@ namespace TrilinosWrappers
   void PreconditionAMG::vmult (Vector        &dst,
                               const Vector  &src) const
   {
-    const int ierr = multigrid_operator->ApplyInverse (*src.vector, *dst.vector);
+    const int ierr = multigrid_operator->ApplyInverse (*src.vector,
+                                                      *dst.vector);
 
     Assert (ierr == 0, ExcTrilinosError(ierr));
   }
@@ -178,8 +173,10 @@ namespace TrilinosWrappers
                       "a map that is not compatible. Check ML preconditioner "
                       "setup."));
     
-    Epetra_Vector LHS (View, *Map, dst.begin());
-    Epetra_Vector RHS (View, *Map, const_cast<double*>(src.begin()));
+    Epetra_Vector LHS (View, multigrid_operator->OperatorDomainMap(),
+                      dst.begin());
+    Epetra_Vector RHS (View, multigrid_operator->OperatorDomainMap(),
+                      const_cast<double*>(src.begin()));
   
     const int res = multigrid_operator->ApplyInverse (RHS, LHS);
   
index c8c047f5dc26816175c98ff837f6bcdca21e622b..0c952be3531f75de262c9cff893d5c9f8726ebb6 100755 (executable)
@@ -74,11 +74,12 @@ namespace TrilinosWrappers
   {}
   
   
-  Vector::Vector (const Vector &v)
+  Vector::Vector (const Vector &v,
+                 const bool    fast)
                   :
                  map (v.map),
                  vector(std::auto_ptr<Epetra_FEVector> 
-                        (new Epetra_FEVector(*(v.vector)))),
+                        (new Epetra_FEVector(v.map,!fast))),
                   last_action (Insert)
   {}
   
@@ -102,14 +103,15 @@ namespace TrilinosWrappers
 
 
   void
-  Vector::reinit (const Vector &v)
+  Vector::reinit (const Vector &v,
+                 const bool    fast)
   {
     vector.reset();
     
     if (!map.SameAs(v.map))
       map = v.map;
     
-    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*v.vector));
+    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(v.map,!fast));
     last_action = Insert;
   }
 
@@ -794,6 +796,14 @@ namespace TrilinosWrappers
     vector = tmp;
   }
 
+
+  unsigned int
+  Vector::memory_consumption () const
+  {
+    AssertThrow(false, ExcNotImplemented() );
+    return 0;
+  }
+
 }
 
 DEAL_II_NAMESPACE_CLOSE
index 4284ba640ece785556275731a3921019ea62b7e8..6c9019a378c6dba10b965d806ac23d50910e07e8 100644 (file)
@@ -19,6 +19,8 @@
 #include <lac/petsc_block_vector.h>
 #include <lac/petsc_parallel_vector.h>
 #include <lac/petsc_parallel_block_vector.h>
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_block_vector.h>
 
 DEAL_II_NAMESPACE_OPEN
 
@@ -100,4 +102,12 @@ Threads::ThreadMutex GrowingVectorMemory<VECTOR>::mutex;
     template class GrowingVectorMemory<PETScWrappers::MPI::BlockVector>;
 #endif
 
+#ifdef DEAL_II_USE_TRILINOS
+    template class VectorMemory<TrilinosWrappers::Vector>;
+    template class GrowingVectorMemory<TrilinosWrappers::Vector>;
+    
+    template class VectorMemory<TrilinosWrappers::BlockVector>;
+    template class GrowingVectorMemory<TrilinosWrappers::BlockVector>;
+#endif
+
 DEAL_II_NAMESPACE_CLOSE

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.