]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a few bugs with distribute. constraint_matrix_trilinos_bug/ncpu_10 still not...
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 31 May 2013 09:48:26 +0000 (09:48 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 31 May 2013 09:48:26 +0000 (09:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@29679 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/constraint_matrix.templates.h
tests/mpi/constraint_matrix_trilinos_bug.cc
tests/mpi/constraint_matrix_trilinos_bug/ncpu_10/cmp/generic
tests/mpi/constraint_matrix_trilinos_bug/ncpu_4/cmp/generic
tests/mpi/p4est_2d_constraintmatrix_03.cc

index ed19a1c0d63167a2923e062feeb1910ca54f82b0..24063ce28cfdcc14e39a3e8addfb65635d3df940 100644 (file)
@@ -1016,6 +1016,8 @@ namespace internal
                                        parallel::distributed::Vector<number>       &output,
                                        const internal::bool2type<false>             /*is_block_vector*/)
     {
+      // TODO: the in vector might already have all elements. need to find a
+      // way to efficiently avoid the copy then
       const_cast<parallel::distributed::Vector<number>&>(vec).zero_out_ghosts();
       output.reinit (locally_owned_elements, needed_elements, vec.get_mpi_communicator());
       output = vec;
@@ -1069,28 +1071,20 @@ template <class VectorType>
 void
 ConstraintMatrix::distribute (VectorType &vec) const
 {
-  Assert (sorted==true, ExcMatrixIsClosed());
-
-  // if the vector type supports parallel storage and if the
-  // vector actually does store only part of the vector, distributing
-  // is slightly more complicated. we can skip the complicated part
-  // if the local processor stores the *entire* vector and pretend
-  // that this is a sequential vector but we need to pay attention that
-  // in that case the other processors don't actually do anything (in
-  // particular that they do not call compress because the processor
-  // that owns everything doesn't do so either); this is the first if
-  // case here, the second is for the complicated case, the last else
-  // is for the simple case (sequential vector or distributed vector
-  // where the current processor stores everything)
-  if ((vec.supports_distributed_data == true)
-      &&
-      (vec.locally_owned_elements().n_elements() == 0))
-    {
-      // do nothing, in particular don't call compress()
-    }
-  else if ((vec.supports_distributed_data == true)
-           &&
-           (vec.locally_owned_elements() != complete_index_set(vec.size())))
+  Assert (sorted==true, ExcMatrixNotClosed());
+
+  // if the vector type supports parallel storage and if the vector actually
+  // does store only part of the vector, distributing is slightly more
+  // complicated. we might be able to skip the complicated part if one
+  // processor owns everything and pretend that this is a sequential vector,
+  // but it is difficult for the other processors to know whether they should
+  // not do anything or if other processors will create a temporary vector,
+  // exchange data (requiring communication, maybe even with the processors
+  // that do not own anything because of that particular parallel model), and
+  // call compress() finally. the first case here is for the complicated case,
+  // the last else is for the simple case (sequential vector)
+  const IndexSet vec_owned_elements = vec.locally_owned_elements();
+  if (vec.supports_distributed_data == true)
     {
       // This processor owns only part of the vector. one may think that
       // every processor should be able to simply communicate those elements
@@ -1105,7 +1099,6 @@ ConstraintMatrix::distribute (VectorType &vec) const
       // need to get a vector that has all the *sources* or constraints we
       // own locally, possibly as ghost vector elements, then read from them,
       // and finally throw away the ghosted vector. Implement this in the following.
-      const IndexSet vec_owned_elements = vec.locally_owned_elements();
       IndexSet needed_elements = vec_owned_elements;
 
       typedef std::vector<ConstraintLine>::const_iterator constraint_iterator;
@@ -1124,17 +1117,16 @@ ConstraintMatrix::distribute (VectorType &vec) const
       for (constraint_iterator it = lines.begin();
           it != lines.end(); ++it)
         if (vec_owned_elements.is_element(it->line))
-          for (unsigned int i=0; i<it->entries.size(); ++i)
-            {
-              typename VectorType::value_type
+          {
+            typename VectorType::value_type
               new_value = it->inhomogeneity;
-              for (unsigned int i=0; i<it->entries.size(); ++i)
-                new_value += (static_cast<typename VectorType::value_type>
-                              (ghosted_vector(it->entries[i].first)) *
-                               it->entries[i].second);
-              Assert(numbers::is_finite(new_value), ExcNumberNotFinite());
-              vec(it->line) = new_value;
-            }
+            for (unsigned int i=0; i<it->entries.size(); ++i)
+              new_value += (static_cast<typename VectorType::value_type>
+                            (ghosted_vector(it->entries[i].first)) *
+                            it->entries[i].second);
+            Assert(numbers::is_finite(new_value), ExcNumberNotFinite());
+            vec(it->line) = new_value;
+          }
 
       // now compress to communicate the entries that we added to
       // and that weren't to local processors to the owner
@@ -1146,7 +1138,7 @@ ConstraintMatrix::distribute (VectorType &vec) const
   else
     // purely sequential vector (either because the type doesn't
     // support anything else or because it's completely stored
-    // locally
+    // locally)
     {
       std::vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
       for (; next_constraint != lines.end(); ++next_constraint)
index 6872ef2c694c82216f79c8e1a91b8355ce344e76..e0c397d24aae2418f4664cd1919aa0f32600e5fd 100644 (file)
 #include <sstream>
 
 
-template<int dim>
-class FilteredDataOut : public DataOut<dim>
-{
-  public:
-    FilteredDataOut (const unsigned int subdomain_id)
-                   :
-                   subdomain_id (subdomain_id)
-      {}
-
-    virtual typename DoFHandler<dim>::cell_iterator
-    first_cell ()
-      {
-       typename DoFHandler<dim>::active_cell_iterator
-         cell = this->dofs->begin_active();
-       while ((cell != this->dofs->end()) &&
-              (cell->subdomain_id() != subdomain_id))
-         ++cell;
-
-       return cell;
-      }
-
-    virtual typename DoFHandler<dim>::cell_iterator
-    next_cell (const typename DoFHandler<dim>::cell_iterator &old_cell)
-      {
-       if (old_cell != this->dofs->end())
-         {
-           const IteratorFilters::SubdomainEqualTo
-             predicate(subdomain_id);
-
-           return
-             ++(FilteredIterator
-                <typename DoFHandler<dim>::active_cell_iterator>
-                (predicate,old_cell));
-         }
-       else
-         return old_cell;
-      }
-
-  private:
-    const unsigned int subdomain_id;
-};
-
-
-
 
 template<int dim>
 void test()
@@ -131,11 +87,9 @@ void test()
   TrilinosWrappers::MPI::Vector x;
   x.reinit(owned_set, MPI_COMM_WORLD);
   x=2.0;
-  x.compress();
 
   TrilinosWrappers::MPI::Vector x_rel;
   x_rel.reinit(relevant_set, MPI_COMM_WORLD);
-  x_rel.compress();
 
   ConstraintMatrix cm(relevant_set);
   DoFTools::make_hanging_node_constraints (dofh, cm);
index b3af4de68802ed03bb2ad5cd854a35ca0b39f93b..c3ced6c764dc30aef04316912352721e30023995 100644 (file)
@@ -1,13 +1,13 @@
 
 DEAL:0:2d::Exception: 
 --------------------------------------------------------
-An error occurred in file <constraint_matrix.cc> in function
-    void dealii::ConstraintMatrix::distribute(VectorType&) const [with VectorType = dealii::TrilinosWrappers::MPI::Vector]
+An error occurred in file <trilinos_vector_base.h> in function
+    void dealii::TrilinosWrappers::VectorBase::set(unsigned int, const unsigned int*, const double*)
 The violated condition was: 
-    vec.vector_partitioner().IsOneToOne()
+    !has_ghost_elements()
 The name and call sequence of the exception was:
-    ExcMessage ("Distribute does not work on vectors with overlapping parallel partitioning.")
+    ExcGhostsPresent()
 Additional Information: 
-Distribute does not work on vectors with overlapping parallel partitioning.
+(none)
 --------------------------------------------------------
 
index b3af4de68802ed03bb2ad5cd854a35ca0b39f93b..c3ced6c764dc30aef04316912352721e30023995 100644 (file)
@@ -1,13 +1,13 @@
 
 DEAL:0:2d::Exception: 
 --------------------------------------------------------
-An error occurred in file <constraint_matrix.cc> in function
-    void dealii::ConstraintMatrix::distribute(VectorType&) const [with VectorType = dealii::TrilinosWrappers::MPI::Vector]
+An error occurred in file <trilinos_vector_base.h> in function
+    void dealii::TrilinosWrappers::VectorBase::set(unsigned int, const unsigned int*, const double*)
 The violated condition was: 
-    vec.vector_partitioner().IsOneToOne()
+    !has_ghost_elements()
 The name and call sequence of the exception was:
-    ExcMessage ("Distribute does not work on vectors with overlapping parallel partitioning.")
+    ExcGhostsPresent()
 Additional Information: 
-Distribute does not work on vectors with overlapping parallel partitioning.
+(none)
 --------------------------------------------------------
 
index 8d147e39dd132610f494ea70572f29aa677a9583..a3a7bed44b6004568ffb57ba7ab08d5e46c83124 100644 (file)
@@ -143,11 +143,9 @@ void test()
   TrilinosWrappers::MPI::Vector x;
   x.reinit(owned_set, MPI_COMM_WORLD);
   x=2.0;
-  x.compress();
 
   TrilinosWrappers::MPI::Vector x_rel;
   x_rel.reinit(relevant_set, MPI_COMM_WORLD);
-  x_rel.compress();
 
   ConstraintMatrix cm(relevant_set);
   DoFTools::make_hanging_node_constraints (dofh, cm);

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.