]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Do not require C++11
authorBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 8 Mar 2016 22:00:51 +0000 (17:00 -0500)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 23 Mar 2016 13:33:43 +0000 (09:33 -0400)
12 files changed:
include/deal.II/base/std_cxx11/shared_ptr.h
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_communication_pattern.h
include/deal.II/lac/trilinos_epetra_vector.h
include/deal.II/lac/vector_space_vector.h
source/lac/trilinos_epetra_communication_pattern.cc
source/lac/trilinos_epetra_vector.cc
tests/trilinos/epetra_vector_01.cc
tests/trilinos/epetra_vector_02.cc

index 4c90c75221ae0ff09fa1326c3fc7ad053873b4a9..07ac73cc7054dc1ea4202e49d721fccabaddfb7c 100644 (file)
@@ -27,6 +27,8 @@ namespace std_cxx11
 {
   using std::shared_ptr;
   using std::enable_shared_from_this;
+  using std::make_shared;
+  using std::dynamic_pointer_cast;
 }
 DEAL_II_NAMESPACE_CLOSE
 
@@ -34,11 +36,14 @@ DEAL_II_NAMESPACE_CLOSE
 
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
+#include <boost/make_shared.hpp>
 DEAL_II_NAMESPACE_OPEN
 namespace std_cxx11
 {
   using boost::shared_ptr;
   using boost::enable_shared_from_this;
+  using boost::make_shared;
+  using boost::dynamic_pointer_cast;
 }
 DEAL_II_NAMESPACE_CLOSE
 
index 1cfb6cb4e3f9dffad96cc749fe6b985a5a859605..86b23bf715255b80d437b11e5dcd2f774608ff20 100644 (file)
@@ -110,88 +110,89 @@ namespace LinearAlgebra
     /**
      * Multiply the entire vector by a fixed factor.
      */
-    virtual Vector<Number> &operator*= (const Number factor) override;
+    virtual Vector<Number> &operator*= (const Number factor);
 
     /**
      * Divide the entire vector by a fixed factor.
      */
-    virtual Vector<Number> &operator/= (const Number factor) override;
+    virtual Vector<Number> &operator/= (const Number factor);
 
     /**
      * Add the vector @p V to the present one.
      */
-    virtual Vector<Number> &operator+= (const VectorSpaceVector<Number> &V) override;
+    virtual Vector<Number> &operator+= (const VectorSpaceVector<Number> &V);
 
     /**
      * Substract the vector @p V from the present one.
      */
-    virtual Vector<Number> &operator-= (const VectorSpaceVector<Number> &V) override;
+    virtual Vector<Number> &operator-= (const VectorSpaceVector<Number> &V);
 
     /**
      * Return the scalar product of two vectors.
      */
-    virtual Number operator* (const VectorSpaceVector<Number> &V) const override;
+    virtual Number operator* (const VectorSpaceVector<Number> &V) const;
 
     /**
      * This function is not implemented and will throw an exception.
      */
     virtual void import(const ReadWriteVector<Number> &V,
                         VectorOperation::values operation,
-                        std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr) override;
+                        std_cxx11::shared_ptr<const CommunicationPatternBase>
+                        communication_pattern = NULL);
 
     /**
      * Add @p a to all components. Note that @p a is a scalar not a vector.
      */
-    virtual void add(const Number a) override;
+    virtual void add(const Number a);
 
     /**
      * Simple addition of a multiple of a vector, i.e. <tt>*this += a*V</tt>.
      */
-    virtual void add(const Number a, const VectorSpaceVector<Number> &V) override;
+    virtual void add(const Number a, const VectorSpaceVector<Number> &V);
 
     /**
      * Multiple addition of a multiple of a vector, i.e. <tt>*this +=
      * a*V+b*W</tt>.
      */
     virtual void add(const Number a, const VectorSpaceVector<Number> &V,
-                     const Number b, const VectorSpaceVector<Number> &W) override;
+                     const Number b, const VectorSpaceVector<Number> &W);
 
     /**
      * Scaling and simple addition of a multiple of a vector, i.e. <tt>*this =
      * s*(*this)+a*V</tt>.
      */
     virtual void sadd(const Number s, const Number a,
-                      const VectorSpaceVector<Number> &V) override;
+                      const VectorSpaceVector<Number> &V);
 
     /**
      * Scale each element of this vector by the corresponding element in the
      * argument. This function is mostly meant to simulate multiplication (and
      * immediate re-assignement) by a diagonal scaling matrix.
      */
-    virtual void scale(const VectorSpaceVector<Number> &scaling_factors) override;
+    virtual void scale(const VectorSpaceVector<Number> &scaling_factors);
 
     /**
      * Assignement <tt>*this = a*V</tt>.
      */
-    virtual void equ(const Number a, const VectorSpaceVector<Number> &V) override;
+    virtual void equ(const Number a, const VectorSpaceVector<Number> &V);
 
     /**
      * Return the l<sub>1</sub> norm of the vector (i.e., the sum of the
      * absolute values of all entries).
      */
-    virtual typename VectorSpaceVector<Number>::real_type l1_norm() const override;
+    virtual typename VectorSpaceVector<Number>::real_type l1_norm() const;
 
     /**
      * Return the l<sub>2</sub> norm of the vector (i.e., the square root of
      * the sum of the square of all entries among all processors).
      */
-    virtual typename VectorSpaceVector<Number>::real_type l2_norm() const override;
+    virtual typename VectorSpaceVector<Number>::real_type l2_norm() const;
 
     /**
      * Return the maximum norm of the vector (i.e., the maximum absolute value
      * among all entries and among all processors).
      */
-    virtual typename VectorSpaceVector<Number>::real_type linfty_norm() const override;
+    virtual typename VectorSpaceVector<Number>::real_type linfty_norm() const;
 
     /**
      * Perform a combined operation of a vector addition and a subsequent
@@ -204,13 +205,13 @@ namespace LinearAlgebra
      */
     virtual Number add_and_dot(const Number a,
                                const VectorSpaceVector<Number> &V,
-                               const VectorSpaceVector<Number> &W) override;
+                               const VectorSpaceVector<Number> &W);
 
     /**
      * Return the global size of the vector, equal to the sum of the number of
      * locally owned indices among all processors.
      */
-    virtual size_type size() const override;
+    virtual size_type size() const;
 
     /**
      * Return an index set that describes which elements of this vector are
@@ -223,7 +224,7 @@ namespace LinearAlgebra
      *  vec.locally_owned_elements() == complete_index_set(vec.size())
      * @endcode
      */
-    virtual dealii::IndexSet locally_owned_elements() const override;
+    virtual dealii::IndexSet locally_owned_elements() const;
 
     /**
      * Prints the vector to the output stream @p out.
@@ -231,7 +232,7 @@ namespace LinearAlgebra
     virtual void print(std::ostream &out,
                        const unsigned int precision=3,
                        const bool scientific=true,
-                       const bool across=true) const override;
+                       const bool across=true) const;
     /**
      * Write the vector en bloc to a file. This is done in a binary mode, so
      * the output is neither readable by humans nor (probably) by other
@@ -255,7 +256,7 @@ namespace LinearAlgebra
     /**
      * Returns the memory consumption of this class in bytes.
      */
-    virtual std::size_t memory_consumption() const override;
+    virtual std::size_t memory_consumption() const;
 
     /**
      * Attempt to perform an operation between two incompatible vector types.
index 1544a5f06e3e9b1b7ab66e82a5e226c84fc19e9d..de99473af32f3e5d88415988104573951f9ba91c 100644 (file)
@@ -117,7 +117,7 @@ namespace LinearAlgebra
   template <typename Number>
   void Vector<Number>::import(const ReadWriteVector<Number> &,
                               VectorOperation::values        ,
-                              std::shared_ptr<const CommunicationPatternBase>)
+                              std_cxx11::shared_ptr<const CommunicationPatternBase>)
   {
     AssertThrow(false, ExcMessage("This function is not implemented."));
   }
index ef38613f2da121a9f4d27e3e85fc5d198c9a0f19..b8459a05730ca1be1f654c1d1356920f608b3b5b 100644 (file)
@@ -233,7 +233,7 @@ namespace LinearAlgebra
      */
     void import(const PETScWrappers::MPI::Vector &petsc_vec,
                 VectorOperation::values operation,
-                std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr);
+                std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern = NULL);
 #endif
 
 #ifdef DEAL_II_WITH_TRILINOS
@@ -247,7 +247,7 @@ namespace LinearAlgebra
      */
     void import(const TrilinosWrappers::MPI::Vector &trilinos_vec,
                 VectorOperation::values operation,
-                std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr);
+                std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern = NULL);
 
     /**
      * 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,
-                std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr);
+                std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern = NULL);
 #endif
 
     /**
@@ -454,7 +454,7 @@ namespace LinearAlgebra
                 const IndexSet                                 &locally_owned_elements,
                 VectorOperation::values                         operation,
                 const MPI_Comm                                 &mpi_comm,
-                std::shared_ptr<const CommunicationPatternBase> communication_pattern);
+                std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern);
 #endif
 
     /**
@@ -497,7 +497,7 @@ namespace LinearAlgebra
      * CommunicationPattern for the communication between the
      * source_stored_elements IndexSet and the current vector.
      */
-    std::shared_ptr<CommunicationPatternBase> comm_pattern;
+    std_cxx11::shared_ptr<CommunicationPatternBase> comm_pattern;
 
     /**
      * Pointer to the array of local elements of this vector.
@@ -517,8 +517,8 @@ namespace LinearAlgebra
   inline
   ReadWriteVector<Number>::ReadWriteVector ()
     :
-    comm_pattern(nullptr),
-    val(nullptr)
+    comm_pattern(NULL),
+    val(NULL)
   {}
 
 
@@ -528,8 +528,8 @@ namespace LinearAlgebra
   ReadWriteVector<Number>::ReadWriteVector (const ReadWriteVector<Number> &v)
     :
     Subscriptor(),
-    comm_pattern(nullptr),
-    val(nullptr)
+    comm_pattern(NULL),
+    val(NULL)
   {
     this->operator=(v);
   }
@@ -540,8 +540,8 @@ namespace LinearAlgebra
   inline
   ReadWriteVector<Number>::ReadWriteVector (const size_type size)
     :
-    comm_pattern(nullptr),
-    val(nullptr)
+    comm_pattern(NULL),
+    val(NULL)
   {
     reinit (size, false);
   }
@@ -552,8 +552,8 @@ namespace LinearAlgebra
   inline
   ReadWriteVector<Number>::ReadWriteVector (const IndexSet &locally_stored_indices)
     :
-    comm_pattern(nullptr),
-    val(nullptr)
+    comm_pattern(NULL),
+    val(NULL)
   {
     reinit (locally_stored_indices);
   }
index 6da4a67284d89d375deab89a28ce39591ac659ed..4b5fbad69680f1f03cd23fa38b53733ec802ab77 100644 (file)
@@ -39,13 +39,13 @@ namespace LinearAlgebra
   {
     if (new_alloc_size == 0)
       {
-        if (val != nullptr)
+        if (val != NULL)
           free(val);
-        val = nullptr;
+        val = NULL;
       }
     else
       {
-        if (val != nullptr)
+        if (val != NULL)
           free(val);
 
         Utilities::System::posix_memalign ((void **)&val, 64, sizeof(Number)*new_alloc_size);
@@ -71,7 +71,7 @@ namespace LinearAlgebra
 
     // reset the communication patter
     source_stored_elements.clear();
-    comm_pattern = nullptr;
+    comm_pattern = NULL;
   }
 
 
@@ -91,7 +91,7 @@ namespace LinearAlgebra
 
     // reset the communication patter
     source_stored_elements.clear();
-    comm_pattern = nullptr;
+    comm_pattern = NULL;
   }
 
 
@@ -112,7 +112,7 @@ namespace LinearAlgebra
 
     // reset the communication patter
     source_stored_elements.clear();
-    comm_pattern = nullptr;
+    comm_pattern = NULL;
   }
 
 
@@ -180,13 +180,13 @@ namespace LinearAlgebra
                                   const IndexSet                  &source_elements,
                                   VectorOperation::values          operation,
                                   const MPI_Comm                  &mpi_comm,
-                                  std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+                                  std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern)
   {
     std_cxx11::shared_ptr<const EpetraWrappers::CommunicationPattern> epetra_comm_pattern;
 
     // If no communication pattern is given, create one. Otherwise, use the one
     // given.
-    if (communication_pattern == nullptr)
+    if (communication_pattern == NULL)
       {
         // The first time import is called, we create a communication pattern.
         // Check if the communication pattern already exists and if it can be
@@ -195,20 +195,20 @@ namespace LinearAlgebra
             (source_elements == source_stored_elements))
           {
             epetra_comm_pattern =
-              std::dynamic_pointer_cast<const EpetraWrappers::CommunicationPattern> (comm_pattern);
-            if (epetra_comm_pattern == nullptr)
-              epetra_comm_pattern = std::make_shared<const EpetraWrappers::CommunicationPattern>(
+              std_cxx11::dynamic_pointer_cast<const EpetraWrappers::CommunicationPattern> (comm_pattern);
+            if (epetra_comm_pattern == NULL)
+              epetra_comm_pattern = std_cxx11::make_shared<const EpetraWrappers::CommunicationPattern>(
                                       create_epetra_comm_pattern(source_elements, mpi_comm));
           }
         else
-          epetra_comm_pattern = std::make_shared<const EpetraWrappers::CommunicationPattern>(
+          epetra_comm_pattern = std_cxx11::make_shared<const EpetraWrappers::CommunicationPattern>(
                                   create_epetra_comm_pattern(source_elements, mpi_comm));
       }
     else
       {
-        epetra_comm_pattern = std::dynamic_pointer_cast<const EpetraWrappers::CommunicationPattern> (
+        epetra_comm_pattern = std_cxx11::dynamic_pointer_cast<const EpetraWrappers::CommunicationPattern> (
                                 communication_pattern);
-        AssertThrow(epetra_comm_pattern != nullptr,
+        AssertThrow(epetra_comm_pattern != NULL,
                     ExcMessage(std::string("The communication pattern is not of type ") +
                                "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
       }
@@ -238,7 +238,7 @@ namespace LinearAlgebra
   void
   ReadWriteVector<Number>::import(const TrilinosWrappers::MPI::Vector            &trilinos_vec,
                                   VectorOperation::values                         operation,
-                                  std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+                                  std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern)
   {
     import(trilinos_vec.trilinos_vector(), trilinos_vec.locally_owned_elements(),
            operation, trilinos_vec.get_mpi_communicator(), communication_pattern);
@@ -250,7 +250,7 @@ namespace LinearAlgebra
   void
   ReadWriteVector<Number>::import(const LinearAlgebra::EpetraWrappers::Vector    &trilinos_vec,
                                   VectorOperation::values                         operation,
-                                  std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+                                  std_cxx11::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 d25f9187d14cfb098775f34bac9038dce1fc7f1d..9846515776159782d7a95b854b561ce791c730c5 100644 (file)
@@ -60,7 +60,7 @@ namespace LinearAlgebra
       /**
        * Return the underlying MPI communicator.
        */
-      const MPI_Comm &get_mpi_communicator() const override;
+      const MPI_Comm &get_mpi_communicator() const;
 
       /**
        * Return the underlying Epetra_Import object.
index 2a29f1100b00541eb3eadb73e40f1f95bf1cda27..e974863ae1b899e3d3cb4f90b18db4921059b464 100644 (file)
@@ -101,8 +101,7 @@ namespace LinearAlgebra
        */
       virtual void import(const ReadWriteVector<double>  &V,
                           VectorOperation::values         operation,
-                          std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr)
-      override;
+                          std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern = NULL);
 
       /**
        * Multiply the entire vector by a fixed factor.
index 8ccab81807df728550631ed68b817b7ba5d03c6b..15cc4b7cd356d542f8f5eb390a2ff011eb0ed3e8 100644 (file)
@@ -19,6 +19,7 @@
 #include <deal.II/base/config.h>
 #include <deal.II/base/mpi.h>
 #include <deal.II/base/numbers.h>
+#include <deal.II/base/std_cxx11/shared_ptr.h>
 
 
 DEAL_II_NAMESPACE_OPEN
@@ -79,7 +80,7 @@ namespace LinearAlgebra
      */
     virtual void import(const ReadWriteVector<Number> &V,
                         VectorOperation::values operation,
-                        std::shared_ptr<const CommunicationPatternBase> communication_pattern = nullptr) = 0;
+                        std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern = NULL) = 0;
 
     /**
      * Return the scalar product of two vectors.
index 992d2d9c6841abfd18e4b72e6220b6de29764beb..d84ff994563069cf7062006b8507fe6389507adf 100644 (file)
@@ -20,6 +20,7 @@
 #ifdef DEAL_II_WITH_MPI
 
 #include <deal.II/base/index_set.h>
+#include <deal.II/base/std_cxx11/shared_ptr.h>
 #include "Epetra_Map.h"
 
 DEAL_II_NAMESPACE_OPEN
@@ -41,7 +42,7 @@ namespace LinearAlgebra
                                       const IndexSet &read_write_vector_index_set,
                                       const MPI_Comm &communicator)
     {
-      comm = std::make_shared<const MPI_Comm>(communicator);
+      comm = std_cxx11::make_shared<const MPI_Comm>(communicator);
 
       Epetra_Map vector_space_vector_map = vector_space_vector_index_set.make_trilinos_map(*comm,
                                            false);
index 7a8d8ae16378c63367a79bf0a72abba0ecf4e38e..953173f2751745003f654da7ce3be191daa51504 100644 (file)
@@ -34,7 +34,7 @@ namespace LinearAlgebra
     Vector::Vector()
       :
       vector(new Epetra_FEVector(Epetra_Map(0,0,0,Utilities::Trilinos::comm_self()))),
-      epetra_comm_pattern(nullptr)
+      epetra_comm_pattern(NULL)
     {}
 
 
@@ -42,7 +42,7 @@ namespace LinearAlgebra
     Vector::Vector(const Vector &V)
       :
       vector(new Epetra_FEVector(V.trilinos_vector())),
-      epetra_comm_pattern(nullptr)
+      epetra_comm_pattern(NULL)
     {}
 
 
@@ -51,7 +51,7 @@ namespace LinearAlgebra
                    const MPI_Comm &communicator)
       :
       vector(new Epetra_FEVector(parallel_partitioner.make_trilinos_map(communicator,false))),
-      epetra_comm_pattern(nullptr)
+      epetra_comm_pattern(NULL)
     {}
 
 
@@ -101,11 +101,11 @@ namespace LinearAlgebra
 
     void Vector::import(const ReadWriteVector<double>                  &V,
                         VectorOperation::values                         operation,
-                        std::shared_ptr<const CommunicationPatternBase> communication_pattern)
+                        std_cxx11::shared_ptr<const CommunicationPatternBase> communication_pattern)
     {
       // If no communication pattern is given, create one. Otherwsie, use the
       // one given.
-      if (communication_pattern == nullptr)
+      if (communication_pattern == NULL)
         {
           // The first time import is called, a communication pattern is created.
           // Check if the communication pattern already exists and if it can be
@@ -121,8 +121,8 @@ namespace LinearAlgebra
       else
         {
           epetra_comm_pattern =
-            std::dynamic_pointer_cast<const CommunicationPattern> (communication_pattern);
-          AssertThrow(epetra_comm_pattern != nullptr,
+            std_cxx11::dynamic_pointer_cast<const CommunicationPattern> (communication_pattern);
+          AssertThrow(epetra_comm_pattern != NULL,
                       ExcMessage(std::string("The communication pattern is not of type ") +
                                  "LinearAlgebra::EpetraWrappers::CommunicationPattern."));
         }
index 1192ef53826af80552c3f256d0af23d599578354..42132a1f45df3b1c609395cf05bd9f7534183ee1 100644 (file)
@@ -22,8 +22,7 @@
 #include <iostream>
 #include <vector>
 
-// Check LinearAlgebra::EpetraWrappers::Vector assignement and the operator
-// overloading.
+// Check LinearAlgebra::EpetraWrappers::Vector assignement and import
 
 
 void test()
index 437e11284ca75d8d3e6bec9dc0afda5521140302..e0c5eb1fc683ad140a00bddb29ed908e5b0117eb 100644 (file)
@@ -22,6 +22,7 @@
 #include <iostream>
 #include <vector>
 
+// Check LinearAlgebra::EpetraWrappers::Vector add and sadd.
 
 void test()
 {

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.