]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix colorized hyper_cube_slit
authorTimo Heister <timo.heister@gmail.com>
Tue, 4 Oct 2016 14:08:16 +0000 (10:08 -0400)
committerTimo Heister <timo.heister@gmail.com>
Tue, 4 Oct 2016 14:08:16 +0000 (10:08 -0400)
GridGenerator::hyper_cube_slit() was setting the wrong boundary ids when
colorize was set to true.

include/deal.II/grid/grid_generator.h
source/grid/grid_generator.cc
tests/grid/grid_generator_hyper_cube_slit_01.cc [new file with mode: 0644]
tests/grid/grid_generator_hyper_cube_slit_01.output [new file with mode: 0644]

index 9725be70deb92f80ebc831ff52427cdf985efef0..399d5b81f7e14fa5e4dd57b45156d0e44457d393 100644 (file)
@@ -667,6 +667,9 @@ namespace GridGenerator
    * declared to exist for triangulations of all space dimensions, but throws
    * an error if called in 1d.
    *
+   * If @p colorize is set to @p true, the faces forming the slit are marked
+   * with boundary id 1 and 2, respectively.
+   *
    * @note The triangulation needs to be void upon calling this function.
    */
   template <int dim>
index a4a7aa7ca802622437f3363309ecb3f97ca675ce..89fca820011b1f050af7ba93112e685c45ed6c87 100644 (file)
@@ -2166,7 +2166,7 @@ namespace GridGenerator
         Triangulation<2>::cell_iterator cell = tria.begin();
         cell->face(1)->set_boundary_id(1);
         ++cell;
-        cell->face(3)->set_boundary_id(2);
+        cell->face(0)->set_boundary_id(2);
       }
   }
 
@@ -2765,11 +2765,10 @@ namespace GridGenerator
 
     if (colorize)
       {
-        Assert(false, ExcNotImplemented());
         Triangulation<3>::cell_iterator cell = tria.begin();
         cell->face(1)->set_boundary_id(1);
         ++cell;
-        cell->face(3)->set_boundary_id(2);
+        cell->face(0)->set_boundary_id(2);
       }
   }
 
diff --git a/tests/grid/grid_generator_hyper_cube_slit_01.cc b/tests/grid/grid_generator_hyper_cube_slit_01.cc
new file mode 100644 (file)
index 0000000..49a81b5
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 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.
+//
+// ---------------------------------------------------------------------
+
+// Test output for GridGenerator::hyper_cube_slit()
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+
+#include <fstream>
+#include <iomanip>
+
+
+
+template <int dim>
+void test()
+{
+  deallog << "dim = " << dim << std::endl;
+  Triangulation<dim> tr;
+  GridGenerator::hyper_cube_slit(tr, -1, 1, true);
+  typename Triangulation<dim>::active_cell_iterator
+    cell = tr.begin_active(),
+    endc = tr.end();
+  for (; cell!=endc; ++cell)
+    {
+      deallog << "cell:" << std::endl;
+      
+      for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+       {
+         if (cell->face(face)->at_boundary() && cell->face(face)->boundary_id() != 0)
+           deallog << "boundary id = " << (int)cell->face(face)->boundary_id()
+                   << " center = " << cell->face(face)->center()
+                   << " faceidx = " << face
+                   << std::endl;
+       }
+    }
+}
+
+
+int main()
+{
+  initlog();
+  test<2>();
+  test<3>();
+}
diff --git a/tests/grid/grid_generator_hyper_cube_slit_01.output b/tests/grid/grid_generator_hyper_cube_slit_01.output
new file mode 100644 (file)
index 0000000..db8d2de
--- /dev/null
@@ -0,0 +1,15 @@
+
+DEAL::dim = 2
+DEAL::cell:
+DEAL::boundary id = 1 center = 0.00000 -0.500000 faceidx = 1
+DEAL::cell:
+DEAL::boundary id = 2 center = 0.00000 -0.500000 faceidx = 0
+DEAL::cell:
+DEAL::cell:
+DEAL::dim = 3
+DEAL::cell:
+DEAL::boundary id = 1 center = 0.00000 -0.500000 0.00000 faceidx = 1
+DEAL::cell:
+DEAL::boundary id = 2 center = 0.00000 -0.500000 0.00000 faceidx = 0
+DEAL::cell:
+DEAL::cell:

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.