From: Wolfgang Bangerth Date: Fri, 24 May 2013 05:04:17 +0000 (+0000) Subject: Provide Vector::supports_distributed_data for all vector classes. X-Git-Tag: v8.0.0~476 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6491160d8a849fde0830e4fa9fb186875e7d803;p=dealii.git Provide Vector::supports_distributed_data for all vector classes. git-svn-id: https://svn.dealii.org/trunk@29560 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 2b5634e9f4..2366459758 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -75,12 +75,6 @@ this function. (Martin Kronbichler, 2013/05/14) -
  • Fixed: setting values in TrilinosWrappers::SparseMatrix - in parallel was adding the values instead. -
    - (Bruno Turcksin, Timo Heister, 2013/05/03) -
  • -
  • New: The step-49 tutorial program now also has a discussion on what to do once you have a coarse mesh and want to refine it.
    @@ -127,6 +121,15 @@ this function.

    Specific improvements

      +
    1. New: All vector classes now have a static member variable +supports_distributed_data that indicates whether the +vector class supports data that is distributed across multiple +processors. This variable is provided as a traits variable +to allow generic algorithms working on general vector types to +query the capabilities of the vector class at compile time. +
      +(Wolfgang Bangerth, 2013/05/23) +
    2. Fixed: FETools::back_interpolate has been revised to work correctly also with parallel::distributed::Vector. @@ -228,6 +231,12 @@ vector types, not just dealii::Vector and dealii::BlockVector. (Wolfgang Bangerth, 2013/05/06)
    3. +
    4. Fixed: setting values in TrilinosWrappers::SparseMatrix +in parallel was adding the values instead. +
      +(Bruno Turcksin, Timo Heister, 2013/05/03) +
    5. +
    6. Fixed: Generate an error if the user tries to refine a cell that is already on the maximum level in a distributed triangulation.
      diff --git a/deal.II/include/deal.II/lac/block_vector_base.h b/deal.II/include/deal.II/lac/block_vector_base.h index 2eca83b4d2..68b469c76f 100644 --- a/deal.II/include/deal.II/lac/block_vector_base.h +++ b/deal.II/include/deal.II/lac/block_vector_base.h @@ -758,6 +758,19 @@ public: */ typedef typename BlockType::real_type real_type; + /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals the + * value declared for the type of the individual blocks. + */ + static const bool supports_distributed_data = BlockType::supports_distributed_data; + /** * Default constructor. */ diff --git a/deal.II/include/deal.II/lac/parallel_vector.h b/deal.II/include/deal.II/lac/parallel_vector.h index 0e2521acb1..aeef6b51f3 100644 --- a/deal.II/include/deal.II/lac/parallel_vector.h +++ b/deal.II/include/deal.II/lac/parallel_vector.h @@ -100,6 +100,19 @@ namespace parallel typedef size_t size_type; typedef typename numbers::NumberTraits::real_type real_type; + /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals + * true, since it does support parallel data storage. + */ + static const bool supports_distributed_data = true; + /** * @name 1: Basic Object-handling */ diff --git a/deal.II/include/deal.II/lac/petsc_parallel_vector.h b/deal.II/include/deal.II/lac/petsc_parallel_vector.h index f2a3203eca..0ace189356 100644 --- a/deal.II/include/deal.II/lac/petsc_parallel_vector.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_vector.h @@ -154,6 +154,19 @@ namespace PETScWrappers { public: /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals + * true, since it does support parallel data storage. + */ + static const bool supports_distributed_data = true; + + /** * Default constructor. Initialize the * vector as empty. */ diff --git a/deal.II/include/deal.II/lac/petsc_vector.h b/deal.II/include/deal.II/lac/petsc_vector.h index c7909f1f0c..7193166e27 100644 --- a/deal.II/include/deal.II/lac/petsc_vector.h +++ b/deal.II/include/deal.II/lac/petsc_vector.h @@ -47,6 +47,21 @@ namespace PETScWrappers class Vector : public VectorBase { public: + /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals + * false, since it does not support parallel data storage. + * If you do need parallel data storage, use + * PETScWrappers::MPI::Vector. + */ + static const bool supports_distributed_data = false; + /** * Default constructor. Initialize the * vector as empty. diff --git a/deal.II/include/deal.II/lac/trilinos_vector.h b/deal.II/include/deal.II/lac/trilinos_vector.h index 374bc9a29b..79bafae4fa 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_vector.h @@ -166,10 +166,23 @@ namespace TrilinosWrappers class Vector : public VectorBase { public: + /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals + * true, since it does support parallel data storage. + */ + static const bool supports_distributed_data = true; + /** * @name Basic constructors and initalization. */ -//@{ + //@{ /** * Default constructor that * generates an empty (zero size) @@ -571,6 +584,21 @@ namespace TrilinosWrappers class Vector : public VectorBase { public: + /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals + * false, since it does not support parallel data storage. + * If you do need parallel data storage, use + * TrilinosWrappers::MPI::Vector. + */ + static const bool supports_distributed_data = false; + /** * Default constructor that * generates an empty (zero size) diff --git a/deal.II/include/deal.II/lac/vector.h b/deal.II/include/deal.II/lac/vector.h index 05ebaa680d..33f3a5ef47 100644 --- a/deal.II/include/deal.II/lac/vector.h +++ b/deal.II/include/deal.II/lac/vector.h @@ -140,6 +140,19 @@ public: */ typedef typename numbers::NumberTraits::real_type real_type; + /** + * A variable that indicates whether this vector + * supports distributed data storage. If true, then + * this vector also needs an appropriate compress() + * function that allows communicating recent set or + * add operations to individual elements to be communicated + * to other processors. + * + * For the current class, the variable equals + * false, since it does not support parallel data storage. + */ + static const bool supports_distributed_data = false; + public: /** diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 33844ad471..55f1bdf4d7 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -1717,37 +1717,40 @@ ConstraintMatrix::distribute (PETScWrappers::MPI::Vector &vec) const typedef std::vector::const_iterator constraint_iterator; #ifdef DEBUG - // the algorithm below pushes contributions c_ij x_j to a constrained - // DoF x_j *from the side of the owner of x_j*, as opposed to pulling - // it from the owner of the target side x_i. this relies on the - // assumption that both target and source know about the constraint - // on x_i. - // - // the disadvantage is that it is incredibly difficult to find out what - // is happening if the assumption is not satisfied. to help debug - // problems of this kind, we do the following in a first step if - // debugging is enabled: - // - every processor who owns an x_j where c_ij!=0 sends a one - // to the owner of x_i to add up - // - the owner of x_i knows how many nonzero entries exist, so can - // verify that the correct number of ones has been added - // - if the sum is not correct, then apparently one of the owners - // of the x_j's did not know to send its one and, consequently, - // will also not know to send the correct c_ij*x_j later on, - // leading to a bug - set_zero (vec); - for (constraint_iterator it = lines.begin(); - it != lines.end(); ++it) - for (unsigned int i=0; ientries.size(); ++i) - if (vec_owned_elements.is_element (it->entries[i].first)) - vec(it->line) += 1; - vec.compress (VectorOperation::add); - - for (constraint_iterator it = lines.begin(); - it != lines.end(); ++it) - if (vec_owned_elements.is_element(it->line)) - Assert (vec(it->line) == it->entries.size(), + if (vec.supports_distributed_data == true) + { + // the algorithm below pushes contributions c_ij x_j to a constrained + // DoF x_j *from the side of the owner of x_j*, as opposed to pulling + // it from the owner of the target side x_i. this relies on the + // assumption that both target and source know about the constraint + // on x_i. + // + // the disadvantage is that it is incredibly difficult to find out what + // is happening if the assumption is not satisfied. to help debug + // problems of this kind, we do the following in a first step if + // debugging is enabled: + // - every processor who owns an x_j where c_ij!=0 sends a one + // to the owner of x_i to add up + // - the owner of x_i knows how many nonzero entries exist, so can + // verify that the correct number of ones has been added + // - if the sum is not correct, then apparently one of the owners + // of the x_j's did not know to send its one and, consequently, + // will also not know to send the correct c_ij*x_j later on, + // leading to a bug + set_zero (vec); + for (constraint_iterator it = lines.begin(); + it != lines.end(); ++it) + for (unsigned int i=0; ientries.size(); ++i) + if (vec_owned_elements.is_element (it->entries[i].first)) + vec(it->line) += 1; + vec.compress (VectorOperation::add); + + for (constraint_iterator it = lines.begin(); + it != lines.end(); ++it) + if (vec_owned_elements.is_element(it->line)) + Assert (vec(it->line) == it->entries.size(), ExcIncorrectConstraint(it->line, it->entries.size())); + } #endif // set the values of all constrained DoFs to zero, then add the