From: kronbichler Date: Mon, 17 May 2010 11:11:22 +0000 (+0000) Subject: Make smarter use of shared_ptr. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f7da20ffd557a32b130045e4f92385ab02fef80;p=dealii-svn.git Make smarter use of shared_ptr. git-svn-id: https://svn.dealii.org/trunk@21133 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/trilinos_sparse_matrix.h b/deal.II/lac/include/lac/trilinos_sparse_matrix.h index 9991065825..d5ce7da433 100644 --- a/deal.II/lac/include/lac/trilinos_sparse_matrix.h +++ b/deal.II/lac/include/lac/trilinos_sparse_matrix.h @@ -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); } diff --git a/deal.II/lac/include/lac/trilinos_vector.h b/deal.II/lac/include/lac/trilinos_vector.h index b948dac479..8e730fe177 100644 --- a/deal.II/lac/include/lac/trilinos_vector.h +++ b/deal.II/lac/include/lac/trilinos_vector.h @@ -504,7 +504,7 @@ namespace TrilinosWrappers void Vector::reinit (const Epetra_Map ¶llel_partitioner, const dealii::Vector &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(); diff --git a/deal.II/lac/include/lac/trilinos_vector_base.h b/deal.II/lac/include/lac/trilinos_vector_base.h index 3f1db34a67..c687382558 100644 --- a/deal.II/lac/include/lac/trilinos_vector_base.h +++ b/deal.II/lac/include/lac/trilinos_vector_base.h @@ -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()) diff --git a/deal.II/lac/source/petsc_solver.cc b/deal.II/lac/source/petsc_solver.cc index 85f5a80942..adeb904bf4 100644 --- a/deal.II/lac/source/petsc_solver.cc +++ b/deal.II/lac/source/petsc_solver.cc @@ -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 diff --git a/deal.II/lac/source/slepc_solver.cc b/deal.II/lac/source/slepc_solver.cc index bb50e8b2cd..49e60c9f56 100644 --- a/deal.II/lac/source/slepc_solver.cc +++ b/deal.II/lac/source/slepc_solver.cc @@ -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; } diff --git a/deal.II/lac/source/slepc_spectral_transformation.cc b/deal.II/lac/source/slepc_spectral_transformation.cc index 1d818a3c31..7545234a8a 100644 --- a/deal.II/lac/source/slepc_spectral_transformation.cc +++ b/deal.II/lac/source/slepc_spectral_transformation.cc @@ -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()); diff --git a/deal.II/lac/source/trilinos_precondition.cc b/deal.II/lac/source/trilinos_precondition.cc index 8f4a58e608..8aa2df9364 100644 --- a/deal.II/lac/source/trilinos_precondition.cc +++ b/deal.II/lac/source/trilinos_precondition.cc @@ -85,8 +85,8 @@ namespace TrilinosWrappers const_cast(&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(&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(&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(&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(&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(&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(&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; } diff --git a/deal.II/lac/source/trilinos_solver.cc b/deal.II/lac/source/trilinos_solver.cc index 055734cb43..aadc4b0bd7 100644 --- a/deal.II/lac/source/trilinos_solver.cc +++ b/deal.II/lac/source/trilinos_solver.cc @@ -118,7 +118,7 @@ namespace TrilinosWrappers // Introduce the // preconditioner, ... ierr = solver.SetPrecOperator (const_cast - (&*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 - (&*preconditioner.preconditioner)); + (preconditioner.preconditioner.get())); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); // ... set some options, ... diff --git a/deal.II/lac/source/trilinos_sparse_matrix.cc b/deal.II/lac/source/trilinos_sparse_matrix.cc index fea6fb0b7a..f2e0f79f6f 100644 --- a/deal.II/lac/source/trilinos_sparse_matrix.cc +++ b/deal.II/lac/source/trilinos_sparse_matrix.cc @@ -413,7 +413,7 @@ namespace TrilinosWrappers std_cxx1x::shared_ptr 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 mod_B; if (use_vector == false) { - mod_B = Teuchos::rcp(const_cast(&inputright.trilinos_matrix()), + mod_B = Teuchos::rcp(const_cast + (&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(&inputleft.trilinos_matrix()),A_,false); + (const_cast(&inputleft.trilinos_matrix()),A_, + false); else { ML_Operator_WrapEpetraCrsMatrix - (const_cast(&inputleft.trilinos_matrix()),Anotrans_,false); + (const_cast(&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 diff --git a/deal.II/lac/source/trilinos_sparsity_pattern.cc b/deal.II/lac/source/trilinos_sparsity_pattern.cc index 9e214f4636..c0d4222b33 100644 --- a/deal.II/lac/source/trilinos_sparsity_pattern.cc +++ b/deal.II/lac/source/trilinos_sparsity_pattern.cc @@ -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(graph->RangeMap()), true); diff --git a/deal.II/lac/source/trilinos_vector.cc b/deal.II/lac/source/trilinos_vector.cc index ce51fc79a3..deb093ea0d 100644 --- a/deal.II/lac/source/trilinos_vector.cc +++ b/deal.II/lac/source/trilinos_vector.cc @@ -245,7 +245,7 @@ namespace TrilinosWrappers Teuchos::RCP 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; diff --git a/deal.II/lac/source/trilinos_vector_base.cc b/deal.II/lac/source/trilinos_vector_base.cc index 28873eb827..3ec70b5fe9 100644 --- a/deal.II/lac/source/trilinos_vector_base.cc +++ b/deal.II/lac/source/trilinos_vector_base.cc @@ -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())