From: Timo Heister Date: Tue, 4 Oct 2016 14:08:16 +0000 (-0400) Subject: fix colorized hyper_cube_slit X-Git-Tag: v8.5.0-rc1~610^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bfde4b506aae6567571a95a342ae992cf14d5f1;p=dealii.git fix colorized hyper_cube_slit GridGenerator::hyper_cube_slit() was setting the wrong boundary ids when colorize was set to true. --- diff --git a/include/deal.II/grid/grid_generator.h b/include/deal.II/grid/grid_generator.h index 9725be70de..399d5b81f7 100644 --- a/include/deal.II/grid/grid_generator.h +++ b/include/deal.II/grid/grid_generator.h @@ -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 diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index a4a7aa7ca8..89fca82001 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -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 index 0000000000..49a81b5ac2 --- /dev/null +++ b/tests/grid/grid_generator_hyper_cube_slit_01.cc @@ -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 +#include +#include +#include +#include + +#include +#include + + + +template +void test() +{ + deallog << "dim = " << dim << std::endl; + Triangulation tr; + GridGenerator::hyper_cube_slit(tr, -1, 1, true); + typename Triangulation::active_cell_iterator + cell = tr.begin_active(), + endc = tr.end(); + for (; cell!=endc; ++cell) + { + deallog << "cell:" << std::endl; + + for (unsigned int face=0; face::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 index 0000000000..db8d2de4ec --- /dev/null +++ b/tests/grid/grid_generator_hyper_cube_slit_01.output @@ -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: