<h3>Specific improvements</h3>
<ol>
+ <li> Fixed: PETScWrappers::MPI::Vector::all_zero() was broken with more than
+ one processor (illegal memory access) and did not communicate between all
+ processors. Documentation for many vector types of all_zero() has been extended.
+ <br>
+ (Timo Heister, 2014/01/17)
+ </li>
<li> Fixed: DoFCellAccessor::set_dof_values_by_interpolation and
DoFCellAccessor::get_interpolated_dof_values could previously be
/**
* Return whether the vector contains only elements with value
- * zero. This function is mainly for internal consistency checks and
- * should seldom be used when not in debug mode since it uses quite some
- * time.
+ * zero. This is a collective operation. This function is expensive, because
+ * potentially all elements have to be checked.
*/
bool all_zero () const;
const bool scientific = true,
const bool across = true) const;
+ /**
+ * @copydoc PETScWrappers::VectorBase::all_zero()
+ *
+ * @note This function overloads the one in the base class
+ * to make this a collective operation.
+ */
+ bool all_zero () const;
+
protected:
/**
* Create a vector of length
const VectorBase &v);
/**
- * Return whether the vector contains
- * only elements with value zero. This
- * function is mainly for internal
- * consistency checks and should
- * seldom be used when not in debug
- * mode since it uses quite some time.
+ * Return whether the vector contains only elements with value
+ * zero. This is a collective operation. This function is expensive, because
+ * potentially all elements have to be checked.
*/
bool all_zero () const;
real_type linfty_norm () const;
/**
- * Return whether the vector contains only elements with value zero. This
- * function is mainly for internal consistency checks and should seldom be
- * used when not in debug mode since it uses quite some time.
+ * Return whether the vector contains only elements with value
+ * zero. This is a collective operation. This function is expensive, because
+ * potentially all elements have to be checked.
*/
bool all_zero () const;
+ bool
+ Vector::all_zero() const
+ {
+ unsigned int has_nonzero = VectorBase::all_zero()?0:1;
+#ifdef DEAL_II_WITH_MPI
+ // in parallel, check that the vector
+ // is zero on _all_ processors.
+ unsigned int num_nonzero = Utilities::MPI::sum(has_nonzero, communicator);
+ return num_nonzero == 0;
+#else
+ return has_nonzero == 0;
+#endif
+ }
+
+
void
Vector::print (std::ostream &out,
const unsigned int precision,
AssertThrow (ierr == 0, ExcPETScError(ierr));
const PetscScalar *ptr = start_ptr,
- *eptr = start_ptr + size();
+ *eptr = start_ptr + local_size();
bool flag = true;
while (ptr != eptr)
{
AssertThrow (ierr == 0, ExcPETScError(ierr));
const PetscScalar *ptr = start_ptr,
- *eptr = start_ptr + size();
+ *eptr = start_ptr + local_size();
bool flag = true;
while (ptr != eptr)
{