]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
take over 32048,49
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 18 Dec 2013 17:34:49 +0000 (17:34 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 18 Dec 2013 17:34:49 +0000 (17:34 +0000)
git-svn-id: https://svn.dealii.org/branches/releases/Branch-8-1@32050 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/8.0.0-vs-8.1.0.h
deal.II/include/deal.II/numerics/derivative_approximation.h
deal.II/source/numerics/derivative_approximation.cc
tests/mpi/derivative_approximation_01.cc
tests/mpi/derivative_approximation_01.with_trilinos=true.mpirun=3.debug.output
tests/mpi/derivative_approximation_02.cc [new file with mode: 0644]
tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=1.output [new file with mode: 0644]
tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=3.output [new file with mode: 0644]
tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=7.output [new file with mode: 0644]

index bf47fc3f3298945b0dd9d0db5ed4570ce9a46939..7be343c267e1694cab3f9973c5bac2ee0c4df135 100644 (file)
@@ -259,6 +259,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: Move the implementation of Subscriptor::(un)subscribe() to
   the .cc file so that it is possible to link against the debug library
   without specifying <code>-DDEBUG</code>
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);
+      }
 }
 
 
index 11d0f1d958ae2077c932290cf7b82b1d07cc2846..955655f3acbf0eaacd7b37a7ed7338167d5ebcd0 100644 (file)
  --------------------------------------------------------
  An error occurred in line <3349> of file </ssd/deal-trunk/deal.II/include/deal.II/dofs/dof_accessor.templates.h> in function
      void dealii::DoFCellAccessor<DH, lda>::get_dof_values(const InputVector&, ForwardIterator, ForwardIterator) const [with InputVector = dealii::TrilinosWrappers::MPI::Vector, ForwardIterator = double*, DH = dealii::DoFHandler<2>, bool level_dof_access = false]
- The violated condition was: 
+ The violated condition was:
      this->is_artificial() == false
  The name and call sequence of the exception was:
      ExcMessage ("Can't ask for DoF indices on artificial cells.")
- Additional Information: 
+ Additional Information:
  Can't ask for DoF indices on artificial cells.
  --------------------------------------------------------
-  
+
  */
 
 #include "../tests.h"
@@ -85,8 +85,7 @@ void test()
                                                  vec_rel,
                                                  indicators);
 
-  deallog <<"output:" << indicators.l2_norm() << std::endl;
-
+  // we got here, so no exception.
   if (myid == 0)
     deallog << "OK" << std::endl;
 }
index 0deadca86b779f0f237c2bf93e174a7f4008b87b..03cc72804adeff2dc50a896a8504e5744256cd8d 100644 (file)
@@ -1,9 +1,6 @@
 
-DEAL:0::output:34.4565
 DEAL:0::OK
 
-DEAL:1::output:61.6543
 
 
-DEAL:2::output:47.0585
 
diff --git a/tests/mpi/derivative_approximation_02.cc b/tests/mpi/derivative_approximation_02.cc
new file mode 100644 (file)
index 0000000..af7e1b1
--- /dev/null
@@ -0,0 +1,110 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2009 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+
+// DerivativeApproximation didn't work in parallel at all. This test verifies
+// that it now does.
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/base/function.h>
+#include <deal.II/numerics/vector_tools.h>
+#include <deal.II/numerics/derivative_approximation.h>
+
+#include <fstream>
+#include <sstream>
+
+
+template <int dim>
+class Quadratic :
+  public Function<dim>
+{
+public:
+  double value (const Point<dim> &p, const unsigned int) const
+    {
+      return p*p;
+    }
+};
+
+
+template <int dim>
+void test()
+{
+  const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+  const unsigned int n_processes = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
+
+  parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
+
+  GridGenerator::hyper_cube(tr);
+  tr.refine_global(2);
+
+  const FE_Q<dim> fe(1);
+  DoFHandler<dim> dofh(tr);
+  dofh.distribute_dofs (fe);
+
+  IndexSet locally_relevant_set;
+  DoFTools::extract_locally_relevant_dofs (dofh,
+                                          locally_relevant_set);
+
+  // create a vector representing a function that is independent of the number
+  // of processors involved
+  TrilinosWrappers::MPI::Vector vec (dofh.locally_owned_dofs(), MPI_COMM_WORLD);
+  VectorTools::interpolate (dofh, Quadratic<dim>(), vec);
+  vec.compress(VectorOperation::insert);
+
+  // create such a vector with ghost elements and use it to compute
+  // derivative information
+  TrilinosWrappers::MPI::Vector vec_rel ( locally_relevant_set);
+  vec_rel = vec;
+
+  Vector<float> indicators(tr.n_active_cells());
+  DerivativeApproximation::approximate_gradient  (dofh,
+                                                 vec_rel,
+                                                 indicators);
+
+  // what we get must be a set of derivative indicators, one for each
+  // cell of the distributed mesh. they need to be the same, no matter
+  // how many processors we use. So, the sum of absolute values must
+  // be the same for any processor number
+  const double sum = Utilities::MPI::sum (indicators.l1_norm(), MPI_COMM_WORLD);
+  if (myid == 0)
+    deallog << sum << std::endl;
+}
+
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+
+  MPILogInitAll log;
+
+  test<2> ();
+  test<3> ();
+}
+
diff --git a/tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=1.output b/tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=1.output
new file mode 100644 (file)
index 0000000..380b2ea
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL:0::23.4892
+DEAL:0::116.543
diff --git a/tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=3.output b/tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=3.output
new file mode 100644 (file)
index 0000000..ece4add
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL:0::23.4892
+DEAL:0::116.543
+
+
+
+
diff --git a/tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=7.output b/tests/mpi/derivative_approximation_02.with_trilinos=true.mpirun=7.output
new file mode 100644 (file)
index 0000000..ce82c71
--- /dev/null
@@ -0,0 +1,15 @@
+
+DEAL:0::23.4892
+DEAL:0::116.543
+
+
+
+
+
+
+
+
+
+
+
+

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.