From 4f8621c2ff23ebaca649a83302093b14d58dafef Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Tue, 15 Oct 2013 17:34:45 +0000 Subject: [PATCH] Replace distance by using SynchronousIterators in derivative_approximation. git-svn-id: https://svn.dealii.org/trunk@31240 0785d39b-7218-0410-832d-ea1e28bc413d --- .../numerics/derivative_approximation.h | 8 ++-- .../numerics/derivative_approximation.cc | 37 +++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/deal.II/include/deal.II/numerics/derivative_approximation.h b/deal.II/include/deal.II/numerics/derivative_approximation.h index 3fd49856c4..31a3b118c8 100644 --- a/deal.II/include/deal.II/numerics/derivative_approximation.h +++ b/deal.II/include/deal.II/numerics/derivative_approximation.h @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include #include @@ -673,12 +675,12 @@ private: template class DH, class InputVector, int spacedim> static void - approximate (const typename DH::active_cell_iterator &cell, + approximate (SynchronousIterators + ::active_cell_iterator,Vector::iterator> > const &cell, const Mapping &mapping, const DH &dof, const InputVector &solution, - const unsigned int component, - Vector &derivative_norm); + const unsigned int component); /** * Compute the derivative approximation on diff --git a/deal.II/source/numerics/derivative_approximation.cc b/deal.II/source/numerics/derivative_approximation.cc index 397e688c60..cb8825c807 100644 --- a/deal.II/source/numerics/derivative_approximation.cc +++ b/deal.II/source/numerics/derivative_approximation.cc @@ -650,20 +650,25 @@ approximate_derivative (const Mapping &mapping, // Only act on the locally owned cells typedef FilteredIterator::active_cell_iterator> CellFilter; - - // There is no need for a copier because there is no conflict between threads + + 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())); + + // 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(CellFilter(IteratorFilters::LocallyOwnedCell(),dof_handler.begin_active()), - CellFilter(IteratorFilters::LocallyOwnedCell(),dof_handler.end()), - static_cast::active_cell_iterator const&, + WorkStream::run(begin,end, + static_cast const&, internal::Assembler::Scratch const&,internal::Assembler::CopyData &)> > (std_cxx1x::bind(DerivativeApproximation::template approximate, std_cxx1x::_1, std_cxx1x::cref(mapping), std_cxx1x::cref(dof_handler), - std_cxx1x::cref(solution),component, - std_cxx1x::ref(derivative_norm))), + std_cxx1x::cref(solution),component)), static_cast > (internal::Assembler::copier),internal::Assembler::Scratch (), internal::Assembler::CopyData ()); @@ -674,27 +679,21 @@ approximate_derivative (const Mapping &mapping, template class DH, class InputVector, int spacedim> void -DerivativeApproximation::approximate (const typename DH::active_cell_iterator &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, - Vector &derivative_norm) + const unsigned int component) { - // iterators over all cells and the - // respective entries in the output - // vector: - Vector::iterator derivative_norm_on_this_cell = derivative_norm.begin() + - std::distance(dof_handler.begin_active(),cell); - typename DerivativeDescription::Derivative derivative; // call the function doing the actual // work on this cell DerivativeApproximation::template approximate_cell - (mapping,dof_handler,solution,component,cell,derivative); + (mapping,dof_handler,solution,component,std_cxx1x::get<0>(cell.iterators),derivative); // evaluate the norm and fill the vector - *derivative_norm_on_this_cell - = DerivativeDescription::derivative_norm (derivative); + //*derivative_norm_on_this_cell + *std_cxx1x::get<1>(cell.iterators) = DerivativeDescription::derivative_norm (derivative); } -- 2.39.5