]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix an ownership problem with shared_ptr.
authorBruno Turcksin <bruno.turcksin@gmail.com>
Mon, 15 Feb 2016 20:16:57 +0000 (15:16 -0500)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 23 Mar 2016 13:33:43 +0000 (09:33 -0400)
include/deal.II/lac/la_vector.h
include/deal.II/lac/la_vector.templates.h
include/deal.II/lac/read_write_vector.h
include/deal.II/lac/read_write_vector.templates.h
include/deal.II/lac/trilinos_epetra_vector.h
include/deal.II/lac/vector_space_vector.h
source/lac/trilinos_epetra_vector.cc

index fbdb0a75c73cea2c37dfa74269188ea8b40416cf..1cfb6cb4e3f9dffad96cc749fe6b985a5a859605 100644 (file)
@@ -137,7 +137,7 @@ namespace LinearAlgebra
      */
     virtual void import(const ReadWriteVector<Number> &V,
                         VectorOperation::values operation,
-                        const CommunicationPatternBase *communication_pattern = NULL) override;
+                        std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr) override;
 
     /**
      * Add @p a to all components. Note that @p a is a scalar not a vector.
index a6ea7c6b52d0f7d060c7c87d8e12e53dd2625852..1544a5f06e3e9b1b7ab66e82a5e226c84fc19e9d 100644 (file)
@@ -117,7 +117,7 @@ namespace LinearAlgebra
   template <typename Number>
   void Vector<Number>::import(const ReadWriteVector<Number> &,
                               VectorOperation::values        ,
-                              const CommunicationPatternBase *)
+                              std::shared_ptr<const CommunicationPatternBase>)
   {
     AssertThrow(false, ExcMessage("This function is not implemented."));
   }
index 197ead3db0fd48fa16219f2dcaced65c5c4e1c1c..ef38613f2da121a9f4d27e3e85fc5d198c9a0f19 100644 (file)
@@ -233,7 +233,7 @@ namespace LinearAlgebra
      */
     void import(const PETScWrappers::MPI::Vector &petsc_vec,
                 VectorOperation::values operation,
-                const CommunicationPatternBase *communication_pattern = nullptr);
+                std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr);
 #endif
 
 #ifdef DEAL_II_WITH_TRILINOS
@@ -247,7 +247,7 @@ namespace LinearAlgebra
      */
     void import(const TrilinosWrappers::MPI::Vector &trilinos_vec,
                 VectorOperation::values operation,
-                const CommunicationPatternBase *communication_pattern = nullptr);
+                std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr);
 
     /**
      * Imports all the elements present in the vector's IndexSet from the input
@@ -259,7 +259,7 @@ namespace LinearAlgebra
      */
     void import(const EpetraWrappers::Vector &epetra_vec,
                 VectorOperation::values operation,
-                const CommunicationPatternBase *communication_pattern = nullptr);
+                std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr);
 #endif
 
     /**
@@ -450,11 +450,11 @@ namespace LinearAlgebra
      * vector @p multivector. This is an helper function and it should not be
      * used directly.
      */
-    void import(const Epetra_MultiVector        &multivector,
-                const IndexSet                  &locally_owned_elements,
-                VectorOperation::values          operation,
-                const MPI_Comm                  &mpi_comm,
-                const CommunicationPatternBase  *communication_pattern);
+    void import(const Epetra_MultiVector                       &multivector,
+                const IndexSet                                 &locally_owned_elements,
+                VectorOperation::values                         operation,
+                const MPI_Comm                                 &mpi_comm,
+                std::shared_ptr<const CommunicationPatternBase> communication_pattern);
 #endif
 
     /**
index 26c0c360deeb2aab511b9bcad4d606405adc32e0..6da4a67284d89d375deab89a28ce39591ac659ed 100644 (file)
@@ -180,7 +180,7 @@ namespace LinearAlgebra
                                   const IndexSet                  &source_elements,
                                   VectorOperation::values          operation,
                                   const MPI_Comm                  &mpi_comm,
-                                  const CommunicationPatternBase *communication_pattern)
+                                  std::shared_ptr<const CommunicationPatternBase> communication_pattern)
   {
     std_cxx11::shared_ptr<const EpetraWrappers::CommunicationPattern> epetra_comm_pattern;
 
@@ -206,8 +206,8 @@ namespace LinearAlgebra
       }
     else
       {
-        epetra_comm_pattern.reset(
-          dynamic_cast<const EpetraWrappers::CommunicationPattern *> (communication_pattern));
+        epetra_comm_pattern = std::dynamic_pointer_cast<const EpetraWrappers::CommunicationPattern> (
+                                communication_pattern);
         AssertThrow(epetra_comm_pattern != nullptr,
                     ExcMessage(std::string("The communication pattern is not of type ") +
                                "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
@@ -236,9 +236,9 @@ namespace LinearAlgebra
 
   template <typename Number>
   void
-  ReadWriteVector<Number>::import(const TrilinosWrappers::MPI::Vector &trilinos_vec,
-                                  VectorOperation::values              operation,
-                                  const CommunicationPatternBase      *communication_pattern)
+  ReadWriteVector<Number>::import(const TrilinosWrappers::MPI::Vector            &trilinos_vec,
+                                  VectorOperation::values                         operation,
+                                  std::shared_ptr<const CommunicationPatternBase> communication_pattern)
   {
     import(trilinos_vec.trilinos_vector(), trilinos_vec.locally_owned_elements(),
            operation, trilinos_vec.get_mpi_communicator(), communication_pattern);
@@ -248,9 +248,9 @@ namespace LinearAlgebra
 
   template <typename Number>
   void
-  ReadWriteVector<Number>::import(const LinearAlgebra::EpetraWrappers::Vector &trilinos_vec,
-                                  VectorOperation::values                      operation,
-                                  const CommunicationPatternBase     *communication_pattern)
+  ReadWriteVector<Number>::import(const LinearAlgebra::EpetraWrappers::Vector    &trilinos_vec,
+                                  VectorOperation::values                         operation,
+                                  std::shared_ptr<const CommunicationPatternBase> communication_pattern)
   {
     import(trilinos_vec.trilinos_vector(), trilinos_vec.locally_owned_elements(),
            operation, trilinos_vec.get_mpi_communicator(), communication_pattern);
index b46e0530095fa233020641d0ae634cc308aafb51..2a29f1100b00541eb3eadb73e40f1f95bf1cda27 100644 (file)
@@ -101,7 +101,7 @@ namespace LinearAlgebra
        */
       virtual void import(const ReadWriteVector<double>  &V,
                           VectorOperation::values         operation,
-                          const CommunicationPatternBase *communication_pattern = NULL)
+                          std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr)
       override;
 
       /**
index 577da9b9d212e0c7bb311e7688159552c3ec40a6..8ccab81807df728550631ed68b817b7ba5d03c6b 100644 (file)
@@ -79,7 +79,7 @@ namespace LinearAlgebra
      */
     virtual void import(const ReadWriteVector<Number> &V,
                         VectorOperation::values operation,
-                        const CommunicationPatternBase *communication_pattern = NULL) = 0;
+                        std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr) = 0;
 
     /**
      * Return the scalar product of two vectors.
index b2b4cab8c6a66f8cc228ed0acd7056d8cccac02f..7a8d8ae16378c63367a79bf0a72abba0ecf4e38e 100644 (file)
@@ -99,9 +99,9 @@ namespace LinearAlgebra
 
 
 
-    void Vector::import(const ReadWriteVector<double>  &V,
-                        VectorOperation::values         operation,
-                        const CommunicationPatternBase *communication_pattern)
+    void Vector::import(const ReadWriteVector<double>                  &V,
+                        VectorOperation::values                         operation,
+                        std::shared_ptr<const CommunicationPatternBase> communication_pattern)
     {
       // If no communication pattern is given, create one. Otherwsie, use the
       // one given.
@@ -120,8 +120,8 @@ namespace LinearAlgebra
         }
       else
         {
-          epetra_comm_pattern.reset(
-            dynamic_cast<const CommunicationPattern *> (communication_pattern));
+          epetra_comm_pattern =
+            std::dynamic_pointer_cast<const CommunicationPattern> (communication_pattern);
           AssertThrow(epetra_comm_pattern != nullptr,
                       ExcMessage(std::string("The communication pattern is not of type ") +
                                  "LinearAlgebra::EpetraWrappers::CommunicationPattern."));

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.