]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test for multiple subdomains and convert huge unsigned to negative values
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 5 Jul 2015 09:42:29 +0000 (11:42 +0200)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Sun, 5 Jul 2015 11:42:24 +0000 (13:42 +0200)
source/grid/grid_out.cc
tests/grid/grid_out_vtk_01.cc [moved from tests/deal.II/grid_out_06.cc with 100% similarity]
tests/grid/grid_out_vtk_01.output [moved from tests/deal.II/grid_out_06.output with 100% similarity]
tests/grid/grid_out_vtk_02.cc [new file with mode: 0644]
tests/grid/grid_out_vtk_02.mpirun=3.output [new file with mode: 0644]

index 73efbe4b419d9cfc184aa0f5929fa76783ca6211..d2898116d8810979c29890407e7a0b4fdd84e7c2 100644 (file)
@@ -2442,10 +2442,10 @@ namespace
             patch.data(0, v) = cell->level();
             patch.data(1, v) = cell->material_id();
             if (!cell->has_children())
-              patch.data(2, v) = cell->subdomain_id();
+              patch.data(2, v) = static_cast<int>(cell->subdomain_id());
             else
               patch.data(2, v) = -1;
-            patch.data(3, v) = cell->level_subdomain_id();
+            patch.data(3, v) = static_cast<int>(cell->level_subdomain_id());
           }
         patches.push_back (patch);
       }
diff --git a/tests/grid/grid_out_vtk_02.cc b/tests/grid/grid_out_vtk_02.cc
new file mode 100644 (file)
index 0000000..a26b55f
--- /dev/null
@@ -0,0 +1,112 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2009 - 2014 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check level_subdomain_id for distributed Triangulation
+
+#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_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/grid/grid_out.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/lac/trilinos_vector.h>
+
+#include <fstream>
+
+template<int dim>
+void output(parallel::distributed::Triangulation<dim> &tr, std::ostream& stream)
+{
+  GridOut out;
+  out.write_vtk(tr, stream);
+}
+
+template<int dim>
+void test()
+{
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+  if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
+    deallog << "hyper_cube" << std::endl;
+
+  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(2);
+  DoFHandler<dim> dofh(tr);
+
+  const std::string
+    filename = ("mesh" + Utilities::int_to_string(dim)
+               + "d." +
+               Utilities::int_to_string(tr.locally_owned_subdomain(), 4) +
+               ".vtk");
+  std::ofstream stream(filename.c_str());
+  output(tr, stream);
+
+  //tr.begin_active()->set_level_subdomain_id(1+myid);
+
+  for (unsigned int i=0; i<10; ++i)
+    {
+
+      MPI_Barrier(MPI_COMM_WORLD);
+      if (myid==i)
+        {
+          deallog << "ID = " << i << std::endl;
+          for (unsigned int lvl=0; lvl<tr.n_levels(); ++lvl)
+            {
+              typename Triangulation<dim>::cell_iterator
+              cell = tr.begin(lvl),
+              endc = tr.end(lvl);
+
+              for (; cell!=endc; ++cell)
+                if (cell->level_subdomain_id()!=4294967294)
+                  deallog << cell->level_subdomain_id();
+                else
+                  deallog << "-";
+              deallog << std::endl;
+            }
+          deallog << std::endl;
+        }
+    }
+
+  if (myid==0)
+    deallog << "my levels: " << tr.n_levels() << "<= global levels:" << tr.n_global_levels() << std::endl;
+
+
+}
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll log;
+
+  deallog.push("2d");
+  test<2>();
+  deallog.pop();
+}
diff --git a/tests/grid/grid_out_vtk_02.mpirun=3.output b/tests/grid/grid_out_vtk_02.mpirun=3.output
new file mode 100644 (file)
index 0000000..0504869
--- /dev/null
@@ -0,0 +1,29 @@
+
+DEAL:0:2d::hyper_cube
+DEAL:0:2d::ID = 0
+DEAL:0:2d::0
+DEAL:0:2d::0123
+DEAL:0:2d::00001-1-22--3---
+DEAL:0:2d::
+DEAL:0:2d::my levels: 3<= global levels:3
+
+DEAL:1:2d::ID = 1
+DEAL:1:2d::0
+DEAL:1:2d::0123
+DEAL:1:2d::-0-01111-2--33--
+DEAL:1:2d::
+
+
+DEAL:2:2d::ID = 2
+DEAL:2:2d::0
+DEAL:2:2d::0123
+DEAL:2:2d::--00--1-22223-3-
+DEAL:2:2d::
+
+
+DEAL:3:2d::ID = 3
+DEAL:3:2d::0
+DEAL:3:2d::0123
+DEAL:3:2d::---0--11-2-23333
+DEAL:3:2d::
+

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.