]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new constructor/reinit for PETScWrappers::MPI::BlockVector using IndexSets
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 19 Feb 2013 22:49:52 +0000 (22:49 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 19 Feb 2013 22:49:52 +0000 (22:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@28483 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/lac/petsc_parallel_block_vector.h

index 4f791bf6afa78e07eaec25377e6551a0fd5a8c77..f3b589a07064600cff996ee8a298ca693ab8241d 100644 (file)
@@ -208,6 +208,11 @@ DoFHandler, in particular removal of specializations.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> New: PETScWrappers::MPI::BlockVector now has a constructor and reinit
+that takes a std::vector<IndexSet> (same interface as in Trilinos).
+<br>
+(Timo Heister, 2013/02/19)
+
 <li> New: PETScWrappers::*Matrix::add(other, factor) to
 add a scaled other matrix to the current matrix.
 <br>
index e17ce5b48479965076524ef38b0f71f3a07c84cd..3c5587a6abd008f5060e943aa714f67872ae5676 100644 (file)
@@ -126,6 +126,13 @@ namespace PETScWrappers
                    const MPI_Comm                  &communicator,
                    const std::vector<unsigned int> &local_elements);
 
+      /**
+       * Create a BlockVector with parallel_partitioning.size() blocks,
+       * each initialized with the given IndexSet.
+       */
+      explicit BlockVector (const std::vector<IndexSet> &parallel_partitioning,
+                            const MPI_Comm &communicator = MPI_COMM_WORLD);
+
       /**
        * Destructor. Clears memory
        */
@@ -265,6 +272,13 @@ namespace PETScWrappers
       void reinit (const BlockVector &V,
                    const bool         fast=false);
 
+      /**
+       * Reinitialize the BlockVector using IndexSets. See the constructor
+       * with the same arguments for details.
+       */
+      void reinit (const std::vector<IndexSet> &parallel_partitioning,
+                   const MPI_Comm              &communicator);
+
       /**
        * Return a reference to the MPI
        * communicator object in use with
@@ -365,6 +379,12 @@ namespace PETScWrappers
         this->components[i] = v.components[i];
     }
 
+    inline
+    BlockVector::BlockVector (const std::vector<IndexSet> &parallel_partitioning,
+                 const MPI_Comm              &communicator)
+    {
+      reinit(parallel_partitioning, communicator);
+    }
 
 
     inline
@@ -438,6 +458,22 @@ namespace PETScWrappers
         block(i).reinit(v.block(i), fast);
     }
 
+    inline
+    void
+    BlockVector::reinit (const std::vector<IndexSet> &parallel_partitioning,
+                 const MPI_Comm              &communicator)
+    {
+      std::vector<unsigned int> sizes(parallel_partitioning.size());
+      for (unsigned int i=0; i<parallel_partitioning.size(); ++i)
+        sizes[i] = parallel_partitioning[i].size();
+
+      this->block_indices.reinit(sizes);
+      if (this->components.size() != this->n_blocks())
+        this->components.resize(this->n_blocks());
+
+      for (unsigned int i=0; i<this->n_blocks(); ++i)
+        block(i).reinit(communicator, parallel_partitioning[i]);
+    }
 
 
     inline

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.