]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a nasty bug in DerivativeApproximation which simply did not work at all in parallel.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 18 Dec 2013 17:30:18 +0000 (17:30 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 18 Dec 2013 17:30:18 +0000 (17:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@32048 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/numerics/derivative_approximation.h
deal.II/source/numerics/derivative_approximation.cc

index 63dd4ad503e3441df5649d9b407d38209ed363af..e239c682800938d5b65699410f32ef3b27c58db6 100644 (file)
@@ -59,6 +59,12 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> Fixed: The DerivativeApproximation class did not work for
+  parallel programs. This is now fixed.
+  <br>
+  (Wolfgang Bangerth, 2013/12/18)
+  </li>
+
   <li> Fixed: VectorTools::project_boundary_values could not deal with
   function values close to (but not exactly equal to) zero. This is now fixed.
   <br>
index fb7062f195d7bc3228487eb9790dc1a7efb6ccd9..002ec011373f2737a599a0307b9e0b6594ae8dc1 100644 (file)
@@ -568,7 +568,7 @@ private:
   template <class DerivativeDescription, int dim,
             template <int, int> class DH, class InputVector, int spacedim>
   static void
-  approximate (SynchronousIterators<std_cxx1x::tuple<FilteredIterator<typename DH<dim,spacedim>::active_cell_iterator>,
+  approximate (SynchronousIterators<std_cxx1x::tuple<typename DH<dim,spacedim>::active_cell_iterator,
                Vector<float>::iterator> > const &cell,
                const Mapping<dim,spacedim>    &mapping,
                const DH<dim,spacedim>         &dof,
index dd2a9ca41df429cad3da6ca08bae470a973913d5..44b53627405f8050e658b5b07a917e2b5e077bc8 100644 (file)
@@ -646,19 +646,17 @@ approximate_derivative (const Mapping<dim,spacedim>    &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<typename DH<dim,spacedim>::active_cell_iterator> CellFilter;
-
-  typedef std_cxx1x::tuple<CellFilter,Vector<float>::iterator>
+  typedef std_cxx1x::tuple<typename DH<dim,spacedim>::active_cell_iterator,Vector<float>::iterator>
   Iterators;
-  SynchronousIterators<Iterators> begin(Iterators (CellFilter(IteratorFilters::LocallyOwnedCell(),
-                                                              dof_handler.begin_active()),derivative_norm.begin())),
-                                                                                       end(Iterators (CellFilter(IteratorFilters::LocallyOwnedCell(),dof_handler.end()),
-                                                                                           derivative_norm.end()));
+  SynchronousIterators<Iterators> 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<std_cxx1x::function<void (SynchronousIterators<Iterators> const &,
                                                         internal::Assembler::Scratch const &,internal::Assembler::CopyData &)> >
                   (std_cxx1x::bind(&DerivativeApproximation::template approximate<DerivativeDescription,dim,DH,
@@ -676,12 +674,17 @@ approximate_derivative (const Mapping<dim,spacedim>    &mapping,
 template <class DerivativeDescription, int dim,
           template <int, int> class DH, class InputVector, int spacedim>
 void
-DerivativeApproximation::approximate (SynchronousIterators<std_cxx1x::tuple<FilteredIterator<typename DH<dim,spacedim>::active_cell_iterator>,Vector<float>::iterator> > const &cell,
+DerivativeApproximation::approximate (SynchronousIterators<std_cxx1x::tuple<typename DH<dim,spacedim>::active_cell_iterator,Vector<float>::iterator> > const &cell,
                                       const Mapping<dim,spacedim>                  &mapping,
                                       const DH<dim,spacedim>                       &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<std_cxx1x::tuple<Filt
   // evaluate the norm and fill the vector
   //*derivative_norm_on_this_cell
   *std_cxx1x::get<1>(cell.iterators) = DerivativeDescription::derivative_norm (derivative);
+      }
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.