]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PETScWrappers::VectorBase implement copy operator
authorStefano Zampini <stefano.zampini@gmail.com>
Tue, 17 Jan 2023 08:07:05 +0000 (11:07 +0300)
committerStefano Zampini <stefano.zampini@gmail.com>
Sun, 22 Jan 2023 14:07:09 +0000 (17:07 +0300)
Judging from 456c02ad25e, this was not implemented

include/deal.II/lac/petsc_vector_base.h
source/lac/petsc_vector_base.cc

index 5e84c1e42e68585191dd3eeae4c1ac4543acd461..8a5510054d306c24cb1160d373a3f132e4fe22d5 100644 (file)
@@ -279,13 +279,6 @@ namespace PETScWrappers
      */
     explicit VectorBase(const Vec &v);
 
-    /**
-     * The copy assignment operator is deleted to avoid accidental usage with
-     * unexpected behavior.
-     */
-    VectorBase &
-    operator=(const VectorBase &) = delete;
-
     /**
      * Destructor.
      */
@@ -311,6 +304,12 @@ namespace PETScWrappers
     void
     compress(const VectorOperation::values operation);
 
+    /**
+     * The copy assignment operator.
+     */
+    VectorBase &
+    operator=(const VectorBase &);
+
     /**
      * Set all components of the vector to the given number @p s. Simply pass
      * this down to the individual block objects, but we still need to declare
index 5998d1894c53daba767255f06cbd9368dab6c3f9..b1982975fef667095e352dbbb0e8d20deb053c02 100644 (file)
@@ -189,6 +189,19 @@ namespace PETScWrappers
 
 
 
+  VectorBase &
+  VectorBase::operator=(const VectorBase &v)
+  {
+    Assert(size() == v.size(), ExcDimensionMismatch(size(), v.size()));
+
+    PetscErrorCode ierr = VecCopy(v, vector);
+    AssertThrow(ierr == 0, ExcPETScError(ierr));
+
+    return *this;
+  }
+
+
+
   VectorBase &
   VectorBase::operator=(const PetscScalar s)
   {

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.