]> https://gitweb.dealii.org/ - dealii.git/commitdiff
simplify (failing) test
authorTimo Heister <timo.heister@gmail.com>
Mon, 2 Sep 2013 18:51:39 +0000 (18:51 +0000)
committerTimo Heister <timo.heister@gmail.com>
Mon, 2 Sep 2013 18:51:39 +0000 (18:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@30549 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/mg_05.cc [new file with mode: 0644]
tests/mpi/mg_05/ncpu_10/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/mg_05.cc b/tests/mpi/mg_05.cc
new file mode 100644 (file)
index 0000000..a4880bb
--- /dev/null
@@ -0,0 +1,164 @@
+// ---------------------------------------------------------------------
+// $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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// simplify test to show bug: missing level dofs:
+/*
+An error occurred in line <126> of file <mg_05.cc> in function
+    void test() [with int dim = 2]
+The violated condition was: 
+    cell->neighbor(f)->level_subdomain_id()<100
+The name and call sequence of the exception was:
+    ExcInternalError()
+Additional Information: 
+(none)
+*/
+
+#include "../tests.h"
+#include "coarse_grid_common.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/numerics/data_out.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_dgp.h>
+#include <deal.II/lac/trilinos_vector.h>
+
+#include <fstream>
+
+template<int dim>
+void output(parallel::distributed::Triangulation<dim> &tr)
+{
+  const std::string filename = ("mg_05/mesh." +
+                                Utilities::int_to_string
+                                (tr.locally_owned_subdomain(), 4) +
+                                ".svg");
+  std::ofstream stream(filename.c_str());
+  /*
+  GridOutFlags::XFig flags;
+  flags.color_by = GridOutFlags::XFig::level_subdomain_id;
+  GridOut out;
+  out.set_flags(flags);
+
+  out.write_xfig(tr, stream);
+  */
+  GridOut grid_out;
+  GridOutFlags::Svg svg_flags;
+  svg_flags.coloring = GridOutFlags::Svg::subdomain_id;
+  svg_flags.label_material_id = false;
+  svg_flags.label_level_number = false;
+  svg_flags.label_cell_index = false;
+  svg_flags.label_subdomain_id = false;
+  svg_flags.label_level_subdomain_id = true;
+  svg_flags.background = GridOutFlags::Svg::transparent;
+  svg_flags.polar_angle = 60;
+  svg_flags.convert_level_number_to_height = true;
+  grid_out.set_flags(svg_flags);
+  grid_out.write_svg(tr, stream);
+
+
+}
+
+template<int dim>
+void test()
+{
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+  parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD,
+                                               Triangulation<dim>::none,
+                                               parallel::distributed::Triangulation<dim>::construct_multigrid_hierarchy);
+  GridGenerator::hyper_cube(tr);
+  tr.refine_global(3);
+
+  for (unsigned int ii=0;ii<5;++ii)
+    {
+      typename Triangulation<dim>::active_cell_iterator
+        cell = tr.begin_active(),
+        endc = tr.end();
+      
+      for (; cell!=endc; ++cell)
+       if (std::rand()%42==1)
+         cell->set_refine_flag ();
+      
+      tr.execute_coarsening_and_refinement ();
+      
+      DoFHandler<dim> dofh(tr);
+      
+                                      //output(tr);
+      
+      static const FE_Q<dim> fe(1);
+      dofh.distribute_dofs (fe);
+      dofh.distribute_mg_dofs (fe);
+      
+      {
+       for (unsigned int lvl=0; lvl<tr.n_levels(); ++lvl)
+         {
+           deallog << "level " << lvl << ": "<< std::endl;
+           typename DoFHandler<dim>::cell_iterator
+             cell = dofh.begin(lvl),
+             endc = dofh.end(lvl);
+
+           for (; cell!=endc; ++cell)
+             {
+               if (cell->level_subdomain_id()!=tr.locally_owned_subdomain())
+                 continue;
+               for (unsigned int f=0;f<GeometryInfo<dim>::faces_per_cell;++f)
+                 {
+                   if (cell->at_boundary(f))
+                     continue;
+
+                   deallog << cell->neighbor(f)->level_subdomain_id() << std::endl;
+                                                    // is cell level-artificial?
+                   Assert(cell->neighbor(f)->level_subdomain_id()<100, ExcInternalError());
+               
+                   std::vector<types::global_dof_index> dofs(fe.n_dofs_per_cell());
+                   cell->neighbor(f)->get_mg_dof_indices(dofs);
+                   for (unsigned int i=0;i<fe.n_dofs_per_cell();++i)
+                     {
+                       Assert(dofs[i]!=numbers::invalid_dof_index, ExcInternalError());
+                     }
+                 
+                 }
+             }
+         }
+      }
+    }
+  
+  if (myid==0)
+    deallog << "OK" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll log(__FILE__);
+
+  deallog.push("2d");
+  test<2>();
+  deallog.pop();
+}
diff --git a/tests/mpi/mg_05/ncpu_10/cmp/generic b/tests/mpi/mg_05/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..0f6b464
--- /dev/null
@@ -0,0 +1,39 @@
+
+DEAL:0:2d::hyper_cube
+DEAL:0:2d::level 0: - - - -  | 
+DEAL:0:2d::OK
+
+DEAL:1:2d::level 0: 0 1 2 3  | 
+DEAL:1:2d::level 1: 0 1 2 3  | 1 4 3 5  | 2 3 6 7  | 3 5 7 8  | 
+DEAL:1:2d::level 2: 0 1 2 3  | 1 4 3 5  | 2 3 6 7  | 3 5 7 8  | 4 9 5 10  | 9 - 10 -  | 5 10 8 13  | 10 - 13 -  | 6 7 15 16  | 7 8 16 17  | 15 16 - -  | 16 17 - -  | 8 13 17 21  | 13 - 21 -  | 17 21 - -  | 21 - - -  | 
+
+
+DEAL:2:2d::level 0: - - - -  | 
+
+
+DEAL:3:2d::level 0: 0 1 2 3  | 
+DEAL:3:2d::level 1: 0 1 2 3  | 1 4 3 5  | 2 3 6 7  | 3 5 7 8  | 
+DEAL:3:2d::level 2: - 1 - 3  | 1 4 3 5  | - 3 - 7  | 3 5 7 8  | 4 9 5 10  | 9 11 10 12  | 5 10 8 13  | 10 12 13 14  | - 7 - 16  | 7 8 16 17  | - 16 - -  | 16 17 - -  | 8 13 17 21  | 13 14 21 22  | 17 21 - -  | 21 22 - -  | 
+
+
+DEAL:4:2d::level 0: - - - -  | 
+
+
+DEAL:5:2d::level 0: - - - -  | 
+
+
+DEAL:6:2d::level 0: 0 1 2 3  | 
+DEAL:6:2d::level 1: 0 1 2 3  | 1 4 3 5  | 2 3 6 7  | 3 5 7 8  | 
+DEAL:6:2d::level 2: - - 2 3  | - - 3 5  | 2 3 6 7  | 3 5 7 8  | - - 5 10  | - - 10 -  | 5 10 8 13  | 10 - 13 -  | 6 7 15 16  | 7 8 16 17  | 15 16 18 19  | 16 17 19 20  | 8 13 17 21  | 13 - 21 -  | 17 21 20 23  | 21 - 23 -  | 
+
+
+DEAL:7:2d::level 0: - - - -  | 
+
+
+DEAL:8:2d::level 0: 0 1 2 3  | 
+DEAL:8:2d::level 1: 0 1 2 3  | 1 4 3 5  | 2 3 6 7  | 3 5 7 8  | 
+DEAL:8:2d::level 2: - - - 3  | - - 3 5  | - 3 - 7  | 3 5 7 8  | - - 5 10  | - - 10 12  | 5 10 8 13  | 10 12 13 14  | - 7 - 16  | 7 8 16 17  | - 16 - 19  | 16 17 19 20  | 8 13 17 21  | 13 14 21 22  | 17 21 20 23  | 21 22 23 24  | 
+
+
+DEAL:9:2d::level 0: - - - -  | 
+

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.