]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make smarter use of shared_ptr.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 May 2010 11:11:22 +0000 (11:11 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 May 2010 11:11:22 +0000 (11:11 +0000)
git-svn-id: https://svn.dealii.org/trunk@21133 0785d39b-7218-0410-832d-ea1e28bc413d

12 files changed:
deal.II/lac/include/lac/trilinos_sparse_matrix.h
deal.II/lac/include/lac/trilinos_vector.h
deal.II/lac/include/lac/trilinos_vector_base.h
deal.II/lac/source/petsc_solver.cc
deal.II/lac/source/slepc_solver.cc
deal.II/lac/source/slepc_spectral_transformation.cc
deal.II/lac/source/trilinos_precondition.cc
deal.II/lac/source/trilinos_solver.cc
deal.II/lac/source/trilinos_sparse_matrix.cc
deal.II/lac/source/trilinos_sparsity_pattern.cc
deal.II/lac/source/trilinos_vector.cc
deal.II/lac/source/trilinos_vector_base.cc

index 99910658258f2b3780b4f8bcb2e3ff9429b8edd8..d5ce7da4336643358f86f9f4c3066446a4e53ede 100644 (file)
@@ -3103,7 +3103,7 @@ namespace TrilinosWrappers
                             const ::dealii::SparsityPattern *use_this_sparsity)
   {
     Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator, false);
-    reinit (map, map, sparse_matrix, drop_tolerance, copy_values, 
+    reinit (map, map, sparse_matrix, drop_tolerance, copy_values,
            use_this_sparsity);
   }
 
index b948dac479779a01533a71b4d70d3c287b14c44e..8e730fe177abc5e4c90b345ad9d8a4a8183e98c0 100644 (file)
@@ -504,7 +504,7 @@ namespace TrilinosWrappers
     void Vector::reinit (const Epetra_Map             &parallel_partitioner,
                         const dealii::Vector<number> &v)
     {
-      if (&*vector != 0 && vector->Map().SameAs(parallel_partitioner))
+      if (vector.get() != 0 && vector->Map().SameAs(parallel_partitioner))
        vector.reset (new Epetra_FEVector(parallel_partitioner));
 
       const int size = parallel_partitioner.NumMyElements();
index 3f1db34a67ea7daa88dda15a7cf8f4f02c22dd6d..c68738255885c08b5ce17dab90e025e5e47f68fa 100644 (file)
@@ -1109,7 +1109,7 @@ namespace TrilinosWrappers
   VectorBase::reinit (const VectorBase &v,
                      const bool        fast)
   {
-    Assert (&*vector != 0,
+    Assert (vector.get() != 0,
            ExcMessage("Vector has not been constructed properly."));
 
     if (fast == false || local_range() != v.local_range())
index 85f5a809424f4591693596bdbadb4140e6b3902b..adeb904bf4d494ce15073689d72f98c6cf4276fd 100644 (file)
@@ -133,7 +133,7 @@ namespace PETScWrappers
 
                                      // first create a solver object if this
                                      // is necessary
-    if (&*solver_data == 0)
+    if (solver_data.get() == 0)
       {
         solver_data.reset (new SolverData());
 
@@ -218,7 +218,7 @@ namespace PETScWrappers
     solver_data.reset ();
   }
 
-  
+
 
   SolverControl &
   SolverBase::control() const
index bb50e8b2cdacde0261e13fdf2c6e972b0046706a..49e60c9f56bfbc426cf1bf21b6a652dbc20e13d1 100644 (file)
@@ -52,10 +52,7 @@ namespace SLEPcWrappers
   }
 
   SolverBase::~SolverBase ()
-  {
-    if (&*solver_data != 0)
-      solver_data.reset ();
-  }
+  {}
 
   void
   SolverBase::set_matrices (const PETScWrappers::MatrixBase &A)
@@ -95,7 +92,7 @@ namespace SLEPcWrappers
   {
     int ierr;
 
-    AssertThrow (&*solver_data == 0, ExcSLEPcWrappersUsageError());
+    AssertThrow (solver_data.get() == 0, ExcSLEPcWrappersUsageError());
     solver_data.reset (new SolverData());
 
                                     // create eigensolver context and
@@ -158,7 +155,7 @@ namespace SLEPcWrappers
 #endif
                             PETScWrappers::VectorBase &vr)
   {
-    AssertThrow (&*solver_data != 0, ExcSLEPcWrappersUsageError());
+    AssertThrow (solver_data.get() != 0, ExcSLEPcWrappersUsageError());
 
                                     // get converged eigenpair
     int ierr = EPSGetEigenpair(solver_data->eps, index,
@@ -170,7 +167,7 @@ namespace SLEPcWrappers
   void
   SolverBase::reset ()
   {
-    AssertThrow (&*solver_data != 0, ExcSLEPcWrappersUsageError());
+    AssertThrow (solver_data.get() != 0, ExcSLEPcWrappersUsageError());
 
                                     // destroy solver object.
     solver_data.reset ();
@@ -179,7 +176,7 @@ namespace SLEPcWrappers
   EPS *
   SolverBase::get_EPS ()
   {
-    if( &*solver_data == 0 )
+    if( solver_data.get() == 0 )
       return NULL;
     return &solver_data->eps;
   }
index 1d818a3c314b02a3133a995f06de0ce79e05f684..7545234a8a9e1ca1aa5cdf4d3c91bcd9063025cf 100644 (file)
@@ -45,7 +45,7 @@ namespace SLEPcWrappers
 
   void TransformationBase::set_context (EPS &eps)
   {
-    AssertThrow (&*transformation_data == 0,
+    AssertThrow (transformation_data.get() == 0,
                 SolverBase::ExcSLEPcWrappersUsageError());
     transformation_data.reset (new TransformationData());
 
index 8f4a58e60840a84bbfd24188b36407e52345b378..8aa2df93644e00d2bac68214b85e4986b9199954 100644 (file)
@@ -85,8 +85,8 @@ namespace TrilinosWrappers
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            0));
 
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -106,7 +106,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -137,8 +137,8 @@ namespace TrilinosWrappers
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            additional_data.overlap));
 
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -159,7 +159,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -190,8 +190,8 @@ namespace TrilinosWrappers
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            additional_data.overlap));
 
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -212,7 +212,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -245,8 +245,8 @@ namespace TrilinosWrappers
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            additional_data.overlap));
 
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -265,7 +265,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -298,8 +298,8 @@ namespace TrilinosWrappers
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            additional_data.overlap));
 
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -318,7 +318,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -353,8 +353,8 @@ namespace TrilinosWrappers
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            additional_data.overlap));
 
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -374,7 +374,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -400,8 +400,8 @@ namespace TrilinosWrappers
                           ("Amesos",
                            const_cast<Epetra_CrsMatrix*>(&matrix.trilinos_matrix()),
                            additional_data.overlap));
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -417,7 +417,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -450,8 +450,8 @@ namespace TrilinosWrappers
     ifpack.release();
 
     ifpack = Teuchos::rcp (new Ifpack_Chebyshev (&matrix.trilinos_matrix()));
-    Assert (&*ifpack != 0, ExcMessage ("Trilinos could not create this "
-                                      "preconditioner"));
+    Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this "
+                                          "preconditioner"));
 
     int ierr;
 
@@ -478,7 +478,7 @@ namespace TrilinosWrappers
     ierr = ifpack->Compute();
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-    preconditioner = Teuchos::rcp (&*ifpack, false);
+    preconditioner = Teuchos::rcp (ifpack.get(), false);
   }
 
 
@@ -635,7 +635,7 @@ namespace TrilinosWrappers
     multilevel_operator = Teuchos::rcp (new ML_Epetra::MultiLevelPreconditioner(
                                        matrix.trilinos_matrix(), ml_parameters,
                                        true));
-    preconditioner = Teuchos::rcp (&*multilevel_operator, false);
+    preconditioner = Teuchos::rcp (multilevel_operator.get(), false);
   }
 
 
@@ -656,7 +656,7 @@ namespace TrilinosWrappers
                                        // elements.
     vector_distributor.reset (new Epetra_Map(n_rows, 0, communicator));
 
-    if (&*Matrix==0)
+    if (Matrix.get() == 0)
       Matrix.reset (new SparseMatrix());
 
     Matrix->reinit (*vector_distributor, *vector_distributor,
@@ -680,7 +680,7 @@ namespace TrilinosWrappers
 
                                // todo: find a way to read out ML's data
                                // sizes
-    if (&*Matrix != 0)
+    if (Matrix.get() != 0)
       memory += Matrix->memory_consumption();
     return memory;
   }
index 055734cb43b5928632662d074cefd9338aec8350..aadc4b0bd715625569b86fa3830fc0b23f5f54cf 100644 (file)
@@ -118,7 +118,7 @@ namespace TrilinosWrappers
                                        // Introduce the
                                        // preconditioner, ...
     ierr = solver.SetPrecOperator (const_cast<Epetra_Operator*>
-                                    (&*preconditioner.preconditioner));
+                                  (preconditioner.preconditioner.get()));
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
                                        // ... set some options, ...
@@ -212,7 +212,7 @@ namespace TrilinosWrappers
                                        // Introduce the
                                        // preconditioner, ...
     ierr = solver.SetPrecOperator (const_cast<Epetra_Operator*>
-                                    (&*preconditioner.preconditioner));
+                                  (preconditioner.preconditioner.get()));
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
                                        // ... set some options, ...
index fea6fb0b7a2517cf56c39896604e78ea6812ec06..f2e0f79f6f886ad8c3565e4503c94e741a803cef 100644 (file)
@@ -413,7 +413,7 @@ namespace TrilinosWrappers
     std_cxx1x::shared_ptr<Epetra_CrsGraph> graph;
     int * first_row_length = &n_entries_per_row[input_row_map.MinMyGID()];
     if (input_row_map.Comm().NumProc() > 1)
-      graph.reset (new Epetra_CrsGraph (Copy, input_row_map, first_row_length, 
+      graph.reset (new Epetra_CrsGraph (Copy, input_row_map, first_row_length,
                                        true));
     else
       graph.reset (new Epetra_CrsGraph (Copy, input_row_map, input_col_map,
@@ -492,7 +492,7 @@ namespace TrilinosWrappers
   {
                                   // reinit with a (parallel) Trilinos
                                   // sparsity pattern.
-    column_space_map.reset (new Epetra_Map 
+    column_space_map.reset (new Epetra_Map
                            (sparsity_pattern.domain_partitioner()));
     matrix.reset (new Epetra_FECrsMatrix
                  (Copy, sparsity_pattern.trilinos_sparsity_pattern(), false));
@@ -582,7 +582,7 @@ namespace TrilinosWrappers
       (use_this_sparsity!=0)? *use_this_sparsity :
       dealii_sparse_matrix.get_sparsity_pattern();
 
-    if (&*matrix != 0 && m() == n_rows && 
+    if (matrix.get() != 0 && m() == n_rows &&
        n_nonzero_elements() == sparsity_pattern.n_nonzero_elements())
       goto set_matrix_values;
 
@@ -688,7 +688,7 @@ namespace TrilinosWrappers
                                  // When we clear the matrix, reset
                                  // the pointer and generate an
                                  // empty matrix.
-    column_space_map.reset (new Epetra_Map (0, 0, 
+    column_space_map.reset (new Epetra_Map (0, 0,
                                            Utilities::Trilinos::comm_self()));
     matrix.reset (new Epetra_FECrsMatrix(View, *column_space_map, 0));
 
@@ -974,13 +974,14 @@ namespace TrilinosWrappers
       Teuchos::RCP<Epetra_CrsMatrix> mod_B;
       if (use_vector == false)
        {
-         mod_B = Teuchos::rcp(const_cast<Epetra_CrsMatrix*>(&inputright.trilinos_matrix()),
+         mod_B = Teuchos::rcp(const_cast<Epetra_CrsMatrix*>
+                              (&inputright.trilinos_matrix()),
                               false);
        }
       else
        {
-         mod_B = Teuchos::rcp(new Epetra_CrsMatrix (Copy,
-                                                    inputright.trilinos_sparsity_pattern()),
+         mod_B = Teuchos::rcp(new Epetra_CrsMatrix
+                              (Copy, inputright.trilinos_sparsity_pattern()),
                               true);
          mod_B->FillComplete(inputright.domain_partitioner(),
                              inputright.range_partitioner());
@@ -1015,15 +1016,17 @@ namespace TrilinosWrappers
 
       if (transpose_left == false)
        ML_Operator_WrapEpetraCrsMatrix
-         (const_cast<Epetra_CrsMatrix*>(&inputleft.trilinos_matrix()),A_,false);
+         (const_cast<Epetra_CrsMatrix*>(&inputleft.trilinos_matrix()),A_,
+          false);
       else
        {
          ML_Operator_WrapEpetraCrsMatrix
-           (const_cast<Epetra_CrsMatrix*>(&inputleft.trilinos_matrix()),Anotrans_,false);
+           (const_cast<Epetra_CrsMatrix*>(&inputleft.trilinos_matrix()),
+            Anotrans_,false);
          ML_Operator_Transpose_byrow(Anotrans_,A_);
        }
 
-      ML_Operator_WrapEpetraCrsMatrix(&*mod_B,B_,false);
+      ML_Operator_WrapEpetraCrsMatrix(mod_B.get(),B_,false);
 
                                   // We implement the multiplication by
                                   // hand in a similar way as is done in
index 9e214f463636957c0ec629eb0c5902f7ca1bbc87..c0d4222b3382a09c65f509e530bfcc6b13861ae7 100644 (file)
@@ -398,7 +398,7 @@ namespace TrilinosWrappers
   SparsityPattern::compress ()
   {
     int ierr;
-    Assert (&* column_space_map != 0, ExcInternalError());
+    Assert (column_space_map.get() != 0, ExcInternalError());
     ierr = graph->GlobalAssemble (*column_space_map,
                                  static_cast<const Epetra_Map&>(graph->RangeMap()),
                                  true);
index ce51fc79a33a8e49518b2b2a44e1a93bb2dc1844..deb093ea0d6922105d5a11ccb219a62d96397d48 100644 (file)
@@ -245,7 +245,7 @@ namespace TrilinosWrappers
 
       Teuchos::RCP<Epetra_FEVector> actual_vec = (import_data == true) ?
        Teuchos::rcp (new Epetra_FEVector (new_map), true) :
-       Teuchos::rcp (&*vector, false);
+       Teuchos::rcp (vector.get(), false);
 
       TrilinosScalar* entries = (*actual_vec)[0];
       block_offset = 0;
index 28873eb82795cd4bb09336e95a84e57599d52758..3ec70b5fe9ce84353d7287349d127f3fca1ae23f 100644 (file)
@@ -103,7 +103,7 @@ namespace TrilinosWrappers
   VectorBase &
   VectorBase::operator = (const VectorBase &v)
   {
-    Assert (&*vector != 0,
+    Assert (vector.get() != 0,
            ExcMessage("Vector is not constructed properly."));
 
     if (local_range() != v.local_range())

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.