From ad9c648b3821d0d27d4619d44549797fe6894ea8 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 18 Dec 2013 17:30:18 +0000 Subject: [PATCH] Fix a nasty bug in DerivativeApproximation which simply did not work at all in parallel. git-svn-id: https://svn.dealii.org/trunk@32048 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 +++++ .../numerics/derivative_approximation.h | 2 +- .../numerics/derivative_approximation.cc | 24 +++++++++++-------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 63dd4ad503..e239c68280 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -59,6 +59,12 @@ inconvenience this causes.

Specific improvements

    +
  1. Fixed: The DerivativeApproximation class did not work for + parallel programs. This is now fixed. +
    + (Wolfgang Bangerth, 2013/12/18) +
  2. +
  3. Fixed: VectorTools::project_boundary_values could not deal with function values close to (but not exactly equal to) zero. This is now fixed.
    diff --git a/deal.II/include/deal.II/numerics/derivative_approximation.h b/deal.II/include/deal.II/numerics/derivative_approximation.h index fb7062f195..002ec01137 100644 --- a/deal.II/include/deal.II/numerics/derivative_approximation.h +++ b/deal.II/include/deal.II/numerics/derivative_approximation.h @@ -568,7 +568,7 @@ private: template class DH, class InputVector, int spacedim> static void - approximate (SynchronousIterators::active_cell_iterator>, + approximate (SynchronousIterators::active_cell_iterator, Vector::iterator> > const &cell, const Mapping &mapping, const DH &dof, diff --git a/deal.II/source/numerics/derivative_approximation.cc b/deal.II/source/numerics/derivative_approximation.cc index dd2a9ca41d..44b5362740 100644 --- a/deal.II/source/numerics/derivative_approximation.cc +++ b/deal.II/source/numerics/derivative_approximation.cc @@ -646,19 +646,17 @@ approximate_derivative (const Mapping &mapping, Assert (component < dof_handler.get_fe().n_components(), ExcIndexRange (component, 0, dof_handler.get_fe().n_components())); - // Only act on the locally owned cells - typedef FilteredIterator::active_cell_iterator> CellFilter; - - typedef std_cxx1x::tuple::iterator> + typedef std_cxx1x::tuple::active_cell_iterator,Vector::iterator> Iterators; - SynchronousIterators begin(Iterators (CellFilter(IteratorFilters::LocallyOwnedCell(), - dof_handler.begin_active()),derivative_norm.begin())), - end(Iterators (CellFilter(IteratorFilters::LocallyOwnedCell(),dof_handler.end()), - derivative_norm.end())); + SynchronousIterators begin(Iterators(dof_handler.begin_active(), + derivative_norm.begin())), + end(Iterators(dof_handler.end(), + derivative_norm.end())); // There is no need for a copier because there is no conflict between threads // to write in derivative_norm. Scratch and CopyData are also useless. - WorkStream::run(begin,end, + WorkStream::run(begin, + end, static_cast const &, internal::Assembler::Scratch const &,internal::Assembler::CopyData &)> > (std_cxx1x::bind(&DerivativeApproximation::template approximate &mapping, template class DH, class InputVector, int spacedim> void -DerivativeApproximation::approximate (SynchronousIterators::active_cell_iterator>,Vector::iterator> > const &cell, +DerivativeApproximation::approximate (SynchronousIterators::active_cell_iterator,Vector::iterator> > const &cell, const Mapping &mapping, const DH &dof_handler, const InputVector &solution, const unsigned int component) { + // if the cell is not locally owned, then there is nothing to do + if (std_cxx1x::get<0>(cell.iterators)->is_locally_owned() == false) + *std_cxx1x::get<1>(cell.iterators) = 0; + else + { typename DerivativeDescription::Derivative derivative; // call the function doing the actual // work on this cell @@ -690,6 +693,7 @@ DerivativeApproximation::approximate (SynchronousIterators(cell.iterators) = DerivativeDescription::derivative_norm (derivative); + } } -- 2.39.5