]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Changed the Epetra_Map back to a copy instead of a pointer.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 9 Sep 2008 12:30:16 +0000 (12:30 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 9 Sep 2008 12:30:16 +0000 (12:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@16770 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 2399203e18ec9bcf69d2fa57889abf5551c4b7d5..ca2eaf08a837219f891ddd87e17e1b6ab6be88c0 100755 (executable)
@@ -1191,15 +1191,7 @@ namespace TrilinosWrappers
 
     private:
                                        /**
-                                       * Dummy pointer that is used
-                                       * internally in the
-                                       * constructor for empty
-                                       * matrices.
-                                       */
-      const Epetra_Map *dummy_map;
-
-                                       /**
-                                       * Pointer to Epetra Trilinos
+                                       * Epetra Trilinos
                                        * mapping of the matrix rows
                                        * that assigns parts of the
                                        * matrix to the individual
@@ -1208,7 +1200,7 @@ namespace TrilinosWrappers
                                        * constructor or in a reinit
                                        * function.
                                        */
-      Epetra_Map *row_map;
+      Epetra_Map row_map;
 
                                        /**
                                         * Pointer to the user-supplied
@@ -1217,7 +1209,7 @@ namespace TrilinosWrappers
                                        * assigns parts of the matrix
                                        * to the individual processes.
                                        */
-      Epetra_Map *col_map;
+      Epetra_Map col_map;
   
                                        /**
                                         * Trilinos doesn't allow to
@@ -1339,9 +1331,10 @@ namespace TrilinosWrappers
 
       ++accessor.a_index;
 
-                                       // if at end of line: do one step, then
-                                       // cycle until we find a row with a
-                                       // nonzero number of entries
+                                       // If at end of line: do one
+                                       // step, then cycle until we 
+                                       // find a row with a nonzero
+                                       // number of entries.
       if (accessor.a_index >= accessor.colnum_cache->size())
         {
           accessor.a_index = 0;
index 7871e248db5302df0e6fc06f50312780d271d814..de66fabbaa10634330a4b001d4ebc4daf5d437d6 100755 (executable)
@@ -887,23 +887,15 @@ namespace TrilinosWrappers
 
     private:
                                        /**
-                                       * A dummy pointer to an
-                                       * Epetra_Map to be used for
-                                       * the default constructor.
-                                       */
-      Epetra_Map *dummy_map;
-
-                                       /**
-                                        * A pointer to an Epetra map
-                                        * used to map vector data
-                                        * accross multiple
+                                        * The Epetra map used to map
+                                        * vector data accross multiple
                                         * processes. This is the
                                         * communicator and data
                                         * distribution object common
                                         * to all Trilinos objects used
                                         * by deal.II.
                                         */
-      Epetra_Map *map;
+      Epetra_Map map;
 
                                       /**
                                         * Trilinos doesn't allow to
@@ -1068,7 +1060,7 @@ namespace TrilinosWrappers
   {
                                    // if the vectors have different sizes,
                                    // then first resize the present one
-    if (! map->SameAs(*v.map))
+    if (map.SameAs(v.map) == false)
       {
        map = v.map;
        vector = std::auto_ptr<Epetra_FEVector> 
index 09dadcdb54c12c097742c829afb937b2395f048a..1f9af2c7ddea5916c18c1306b7317a5786a7799b 100755 (executable)
@@ -80,46 +80,35 @@ namespace TrilinosWrappers
   SparseMatrix::SparseMatrix ()
                  :
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
+                  row_map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD)),
 #else
-                  dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
+                  row_map (0, 0, Epetra_SerialComm()),
 #endif
-                 row_map (const_cast<Epetra_Map*>(dummy_map)),
                  col_map (row_map),
                  last_action (Insert),
                  matrix (std::auto_ptr<Epetra_FECrsMatrix>
-                               (new Epetra_FECrsMatrix(Copy, *row_map, 0)))
+                               (new Epetra_FECrsMatrix(Copy, row_map, 0)))
   {}
 
   SparseMatrix::SparseMatrix (const Epetra_Map  &InputMap,
                              const unsigned int n_max_entries_per_row)
                  :
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
-                  dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
-                  row_map (const_cast<Epetra_Map*>(&InputMap)),
+                  row_map (InputMap),
                  col_map (row_map),
                  last_action (Insert),
                  matrix (std::auto_ptr<Epetra_FECrsMatrix>
-                               (new Epetra_FECrsMatrix(Copy, *row_map, 
+                               (new Epetra_FECrsMatrix(Copy, row_map, 
                                        int(n_max_entries_per_row), false)))
   {}
 
   SparseMatrix::SparseMatrix (const Epetra_Map                &InputMap,
                              const std::vector<unsigned int> &n_entries_per_row)
                  :
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
-                  dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
-                  row_map (const_cast<Epetra_Map*>(&InputMap)),
+                  row_map (InputMap),
                  col_map (row_map),
                  last_action (Insert),
                  matrix (std::auto_ptr<Epetra_FECrsMatrix>
-                   (new Epetra_FECrsMatrix(Copy, *row_map, 
+                   (new Epetra_FECrsMatrix(Copy, row_map, 
                      (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
                      true)))
   {}
@@ -128,16 +117,11 @@ namespace TrilinosWrappers
                              const Epetra_Map  &InputColMap,
                              const unsigned int n_max_entries_per_row)
                  :
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
-                  dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
-                  row_map (const_cast<Epetra_Map*>(&InputRowMap)),
-                  col_map (const_cast<Epetra_Map*>(&InputColMap)),
+                  row_map (InputRowMap),
+                  col_map (InputColMap),
                  last_action (Insert),
                  matrix (std::auto_ptr<Epetra_FECrsMatrix>
-                               (new Epetra_FECrsMatrix(Copy, *row_map, *col_map, 
+                               (new Epetra_FECrsMatrix(Copy, row_map, col_map, 
                                        int(n_max_entries_per_row), false)))
   {}
 
@@ -145,16 +129,11 @@ namespace TrilinosWrappers
                              const Epetra_Map                &InputColMap,
                              const std::vector<unsigned int> &n_entries_per_row)
                  :
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
-                  dummy_map (new Epetra_Map (0, 0, Epetra_SerialComm())),
-#endif
-                  row_map (const_cast<Epetra_Map*>(&InputRowMap)),
-                  col_map (const_cast<Epetra_Map*>(&InputColMap)),
+                  row_map (InputRowMap),
+                  col_map (InputColMap),
                  last_action (Insert),
                  matrix (std::auto_ptr<Epetra_FECrsMatrix>
-                   (new Epetra_FECrsMatrix(Copy, *row_map, *col_map, 
+                   (new Epetra_FECrsMatrix(Copy, row_map, col_map, 
                      (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
                      true)))
   {}
@@ -163,7 +142,6 @@ namespace TrilinosWrappers
 
   SparseMatrix::~SparseMatrix ()
   {
-    delete dummy_map;
   }
 
 
@@ -189,7 +167,7 @@ namespace TrilinosWrappers
                                  // sparsity pattern on that
                                  // processor, and only broadcast the
                                  // pattern afterwards.
-    if (row_map->Comm().MyPID() == 0)
+    if (row_map.Comm().MyPID() == 0)
       {
        Assert (matrix->NumGlobalRows() == (int)sparsity_pattern.n_rows(),
                ExcDimensionMismatch (matrix->NumGlobalRows(),
@@ -255,7 +233,7 @@ namespace TrilinosWrappers
 
     unsigned int n_rows = sparsity_pattern.n_rows();
 
-    if (row_map->Comm().MyPID() == 0)
+    if (row_map.Comm().MyPID() == 0)
       {
        Assert (input_map.NumGlobalElements() == (int)sparsity_pattern.n_rows(),
                ExcDimensionMismatch (input_map.NumGlobalElements(),
@@ -265,7 +243,7 @@ namespace TrilinosWrappers
                                      sparsity_pattern.n_cols()));
       }
 
-    row_map = const_cast<Epetra_Map*>(&input_map);
+    row_map = input_map;
     col_map = row_map;
 
     std::vector<int> n_entries_per_row(n_rows);
@@ -274,7 +252,7 @@ namespace TrilinosWrappers
       n_entries_per_row[(int)row] = sparsity_pattern.row_length(row);
 
     matrix = std::auto_ptr<Epetra_FECrsMatrix>
-             (new Epetra_FECrsMatrix(Copy, *row_map, &n_entries_per_row[0], 
+             (new Epetra_FECrsMatrix(Copy, row_map, &n_entries_per_row[0], 
                                      false));
 
                                      reinit (sparsity_pattern);*/
@@ -301,8 +279,8 @@ namespace TrilinosWrappers
                                      sparsity_pattern.n_cols()));
       }
 
-    row_map = const_cast<Epetra_Map*>(&input_row_map);
-    col_map = const_cast<Epetra_Map*>(&input_col_map);
+    row_map = input_row_map;
+    col_map = input_col_map;
 
     std::vector<int> n_entries_per_row(n_rows);
 
@@ -310,7 +288,7 @@ namespace TrilinosWrappers
       n_entries_per_row[(int)row] = sparsity_pattern.row_length(row);
 
     matrix = std::auto_ptr<Epetra_FECrsMatrix>
-             (new Epetra_FECrsMatrix(Copy, *row_map, *col_map,
+             (new Epetra_FECrsMatrix(Copy, row_map, col_map,
                                      &n_entries_per_row[0], false));
 
     reinit (sparsity_pattern);
@@ -357,8 +335,8 @@ namespace TrilinosWrappers
            ExcDimensionMismatch (input_col_map.NumGlobalElements(),
                                  dealii_sparse_matrix.n()));
 
-    row_map = const_cast<Epetra_Map*>(&input_row_map);
-    col_map = const_cast<Epetra_Map*>(&input_col_map);
+    row_map = input_row_map;
+    col_map = input_col_map;
 
     std::vector<int> n_entries_per_row(n_rows);
 
@@ -367,7 +345,7 @@ namespace TrilinosWrappers
          dealii_sparse_matrix.get_sparsity_pattern().row_length(row);
 
     matrix = std::auto_ptr<Epetra_FECrsMatrix>
-             (new Epetra_FECrsMatrix(Copy, *row_map, *col_map,
+             (new Epetra_FECrsMatrix(Copy, row_map, col_map,
                                      &n_entries_per_row[0], true));
 
     std::vector<double> values;
@@ -405,12 +383,17 @@ namespace TrilinosWrappers
                                  // the pointer and generate an
                                  // empty matrix.
     matrix.reset();
-    
-    row_map = const_cast<Epetra_Map*>(dummy_map);
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+    row_map = Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD));
+#else
+    row_map = Epetra_Map (0, 0, Epetra_SerialComm());
+#endif
+
     col_map = row_map;
 
     matrix = std::auto_ptr<Epetra_FECrsMatrix> 
-             (new Epetra_FECrsMatrix(Copy, *row_map, 0));
+             (new Epetra_FECrsMatrix(Copy, row_map, 0));
   }
 
 
@@ -420,10 +403,10 @@ namespace TrilinosWrappers
   {
                                  // flush buffers
     int ierr;
-    //if (row_map->SameAs(*col_map))
+    //if (row_map.SameAs(col_map))
       //ierr = matrix->GlobalAssemble ();
     //else
-      ierr = matrix->GlobalAssemble (*col_map, *row_map);
+      ierr = matrix->GlobalAssemble (col_map, row_map);
     
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
@@ -461,10 +444,10 @@ namespace TrilinosWrappers
     if (last_action == Add)
       {
        int ierr;
-       if (row_map->SameAs(*col_map))
+       if (row_map.SameAs(col_map))
          ierr = matrix->GlobalAssemble (false);
        else
-         ierr = matrix->GlobalAssemble(*col_map, *row_map, false);
+         ierr = matrix->GlobalAssemble(col_map, row_map, false);
        
        AssertThrow (ierr == 0, ExcTrilinosError(ierr));
        last_action = Insert;
@@ -496,10 +479,10 @@ namespace TrilinosWrappers
     if (last_action == Insert)
       {
        int ierr;
-       if (row_map->SameAs(*col_map))
+       if (row_map.SameAs(col_map))
          ierr = matrix->GlobalAssemble (false);
        else
-         ierr = matrix->GlobalAssemble(*col_map, *row_map, false);
+         ierr = matrix->GlobalAssemble(col_map, row_map, false);
        
        AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
@@ -797,12 +780,12 @@ namespace TrilinosWrappers
   {
     Assert (&src != &dst, ExcSourceEqualsDestination());
     
-    Assert (col_map->SameAs(src.vector->Map()),
+    Assert (col_map.SameAs(src.vector->Map()) == true,
            ExcMessage ("Column map of matrix does not fit with vector map!"));
-    Assert (row_map->SameAs(dst.vector->Map()),
+    Assert (row_map.SameAs(dst.vector->Map()) == true,
            ExcMessage ("Row map of matrix does not fit with vector map!"));
 
-    if (!matrix->Filled())
+    if (matrix->Filled() == false)
       matrix->FillComplete();
 
     const int ierr = matrix->Multiply (false, *(src.vector), *(dst.vector));
@@ -817,12 +800,12 @@ namespace TrilinosWrappers
   {
     Assert (&src != &dst, ExcSourceEqualsDestination());
 
-    Assert (row_map->SameAs(src.vector->Map()),
+    Assert (row_map.SameAs(src.vector->Map()) == true,
            ExcMessage ("Row map of matrix does not fit with vector map!"));
-    Assert (col_map->SameAs(dst.vector->Map()),
+    Assert (col_map.SameAs(dst.vector->Map()) == true,
            ExcMessage ("Column map of matrix does not fit with vector map!"));
 
-    if (!matrix->Filled())
+    if (matrix->Filled() == false)
       matrix->FillComplete();
 
     const int ierr = matrix->Multiply (true, *(src.vector), *(dst.vector));
index 547d2bd5d257e45a89c2137e4b77e98298e83673..c10a0a7f8e1d98042f19d9e6045d5ddea624fdd7 100755 (executable)
@@ -35,10 +35,10 @@ namespace TrilinosWrappers
                                         // checks index bounds Also,
                                         // can only get local values
 
-      AssertThrow ((static_cast<signed int>(index) >= vector.map->MinMyGID()) &&
-                  (static_cast<signed int>(index) <= vector.map->MaxMyGID()),
-                  ExcAccessToNonLocalElement (index, vector.map->MinMyGID(),
-                                              vector.map->MaxMyGID()));
+      AssertThrow ((static_cast<signed int>(index) >= vector.map.MinMyGID()) &&
+                  (static_cast<signed int>(index) <= vector.map.MaxMyGID()),
+                  ExcAccessToNonLocalElement (index, vector.map.MinMyGID(),
+                                              vector.map.MaxMyGID()));
 
       return (*(vector.vector))[0][index];
     }
@@ -49,29 +49,23 @@ namespace TrilinosWrappers
   Vector::Vector ()
                   :
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0,0,Epetra_MpiComm(MPI_COMM_WORLD))),
+                  map (0,0,Epetra_MpiComm(MPI_COMM_WORLD)),
 #else
-                 dummy_map (new Epetra_Map (0,0,Epetra_SerialComm())),
+                 map (0,0,Epetra_SerialComm()),
 #endif
-                 map (const_cast<Epetra_Map*>(dummy_map)),
                   last_action (Insert),
                  vector(std::auto_ptr<Epetra_FEVector> 
-                        (new Epetra_FEVector(*map)))
+                        (new Epetra_FEVector(map)))
   {}
 
 
   
   Vector::Vector (const Epetra_Map &InputMap)
                   :
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0,0,Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
-                 dummy_map (new Epetra_Map (0,0,Epetra_SerialComm())),
-#endif
-                 map (const_cast<Epetra_Map*>(&InputMap)),
+                 map (InputMap),
                   last_action (Insert),
                  vector (std::auto_ptr<Epetra_FEVector> 
-                         (new Epetra_FEVector(*map)))
+                         (new Epetra_FEVector(map)))
   {}
   
 
@@ -79,23 +73,16 @@ namespace TrilinosWrappers
   Vector::Vector (const Vector &v,
                  const bool    fast)
                   :
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                  dummy_map (new Epetra_Map (0,0,Epetra_MpiComm(MPI_COMM_WORLD))),
-#else
-                 dummy_map (new Epetra_Map (0,0,Epetra_SerialComm())),
-#endif
                  map (v.map),
                   last_action (Insert),
                  vector(std::auto_ptr<Epetra_FEVector> 
-                        (new Epetra_FEVector(*map,!fast)))
+                        (new Epetra_FEVector(map,!fast)))
   {}
   
 
 
   Vector::~Vector ()
   {
-    vector.reset();
-    delete dummy_map;
   }
 
 
@@ -104,9 +91,9 @@ namespace TrilinosWrappers
   Vector::reinit (const Epetra_Map &input_map)
   {
     vector.reset();
-    map = const_cast<Epetra_Map*> (&input_map);
+    map = input_map;
 
-    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*map));
+    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(map));
     last_action = Insert;
   }
 
@@ -117,10 +104,10 @@ namespace TrilinosWrappers
                  const bool    fast)
   {
     vector.reset();
+    if (map.SameAs(v.map) == false)
+      map = v.map;
 
-    map = v.map;
-
-    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*map,!fast));
+    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(map,!fast));
     last_action = Insert;
   }
 
@@ -133,9 +120,14 @@ namespace TrilinosWrappers
                                     // reset the pointer and generate
                                     // an empty vector.
     vector.reset();
-    map = dummy_map;
 
-    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(*map));
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+    map = Epetra_Map (0, 0, Epetra_MpiComm(MPI_COMM_WORLD));
+#else
+    map = Epetra_Map (0, 0, Epetra_SerialComm());
+#endif
+
+    vector = std::auto_ptr<Epetra_FEVector> (new Epetra_FEVector(map));
     last_action = Insert;
   }
 

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.