From: bangerth Date: Wed, 9 Jan 2013 16:42:51 +0000 (+0000) Subject: Fix a problem where we needed to call compress() in ConstraintMatrix::condense. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2df651f93a7b3f8761f99ae03bc1837170ef9e1;p=dealii-svn.git Fix a problem where we needed to call compress() in ConstraintMatrix::condense. git-svn-id: https://svn.dealii.org/trunk@27996 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 0c14593263..3fae5d6b78 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -172,6 +172,11 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. Fixed: The one-argument version of ConstraintMatrix::condense was +not prepared to deal with parallel vectors. This is now fixed. +
    +(Daniel Arndt, Wolfgang Bangerth, 2013/1/9) +
  2. New: Utilities::int_to_string can now deal with any 32-bit integer, not just those with up to 6 digits.
    diff --git a/deal.II/include/deal.II/lac/constraint_matrix.templates.h b/deal.II/include/deal.II/lac/constraint_matrix.templates.h index 8d7f1b552a..d1ad4d3565 100644 --- a/deal.II/include/deal.II/lac/constraint_matrix.templates.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.templates.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -142,24 +142,36 @@ ConstraintMatrix::condense (VectorType &vec) const { Assert (sorted == true, ExcMatrixNotClosed()); - // distribute all entries, and set them to zero - std::vector::const_iterator constraint_line = lines.begin(); - for (; constraint_line!=lines.end(); ++constraint_line) + // distribute all entries, and set them to zero. do so in + // two loops because in the first one we need to add to elements + // and in the second one we need to set elements to zero. for + // parallel vectors, this can only work if we can put a compress() + // in between, but we don't want to call compress() twice per entry + for (std::vector::const_iterator + constraint_line = lines.begin(); + constraint_line!=lines.end(); ++constraint_line) { - for (unsigned int q=0; q!=constraint_line->entries.size(); ++q) - vec(constraint_line->entries[q].first) - += (static_cast - (vec(constraint_line->line)) * - constraint_line->entries[q].second); - vec(constraint_line->line) = 0.; - // in case the constraint is // inhomogeneous, this function is not // appropriate. Throw an exception. Assert (constraint_line->inhomogeneity == 0., ExcMessage ("Inhomogeneous constraint cannot be condensed " "without any matrix specified.")); + + const typename VectorType::value_type old_value = vec(constraint_line->line); + for (unsigned int q=0; q!=constraint_line->entries.size(); ++q) + vec(constraint_line->entries[q].first) + += (static_cast + (old_value) * + constraint_line->entries[q].second); } + + vec.compress(); + + for (std::vector::const_iterator + constraint_line = lines.begin(); + constraint_line!=lines.end(); ++constraint_line) + vec(constraint_line->line) = 0.; }