From: Wolfgang Bangerth Date: Sat, 17 Jan 2015 16:33:04 +0000 (-0600) Subject: Also colorize the edges, not just the faces, of a hypershell. X-Git-Tag: v8.3.0-rc1~528^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b039de51f0acaf06c867c1874b03db0998d7e17;p=dealii.git Also colorize the edges, not just the faces, of a hypershell. --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 3a30356d57..c6ce5b1279 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -213,6 +213,14 @@ inconvenience this causes.

Specific improvements

    +
  1. Fixed: In 3d, when you set the colorize flag of + GridGenerator::hyper_shell(), the faces of the domain were colored but + the edges were not. This was an oversight because to refine correctly, + the edges also have to have the appropriate boundary indicator set. +
    + (Wolfgang Bangerth, 2015/01/16) +
  2. +
  3. New: dealii::multithread_info.n_cpus returns the correct number of CPU on FreeBSD.
    diff --git a/include/deal.II/grid/grid_generator.h b/include/deal.II/grid/grid_generator.h index 8a4b2528d4..8cc20b629d 100644 --- a/include/deal.II/grid/grid_generator.h +++ b/include/deal.II/grid/grid_generator.h @@ -428,9 +428,10 @@ namespace GridGenerator * of cells of the resulting triangulation, i.e., how many cells form the * ring (in 2d) or the shell (in 3d). * - * If the flag @p colorize is @p true, then the outer boundary will have the - * indicator 1, while the inner boundary has id zero. If the flag is @p - * false, both have indicator zero. + * If the flag @p colorize is @p true, then the outer boundary will + * have the indicator 1, while the inner boundary has id zero. In + * 3d, this applies to both the faces and the edges of these + * boundaries. If the flag is @p false, both have indicator zero. * * In 2d, the number n_cells of elements for this initial * triangulation can be chosen arbitrarily. If the number of initial cells diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index caf976491b..845ffb1546 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -173,7 +173,7 @@ namespace GridGenerator cell != tria.end (); ++cell) { Assert(cell->face(2)->at_boundary(), ExcInternalError()); - cell->face (2)->set_boundary_indicator (1); + cell->face (2)->set_all_boundary_indicators (1); } } @@ -196,23 +196,28 @@ namespace GridGenerator { Triangulation<3>::cell_iterator cell = tria.begin(); - cell->face(4)->set_boundary_indicator(1); Assert (cell->face(4)->at_boundary(), ExcInternalError()); + cell->face(4)->set_all_boundary_indicators(1); - (++cell)->face(2)->set_boundary_indicator(1); + ++cell; Assert (cell->face(2)->at_boundary(), ExcInternalError()); + cell->face(2)->set_all_boundary_indicators(1); - (++cell)->face(2)->set_boundary_indicator(1); + ++cell; Assert (cell->face(2)->at_boundary(), ExcInternalError()); + cell->face(2)->set_all_boundary_indicators(1); - (++cell)->face(0)->set_boundary_indicator(1); + ++cell; Assert (cell->face(0)->at_boundary(), ExcInternalError()); + cell->face(0)->set_all_boundary_indicators(1); - (++cell)->face(2)->set_boundary_indicator(1); + ++cell; Assert (cell->face(2)->at_boundary(), ExcInternalError()); + cell->face(2)->set_all_boundary_indicators(1); - (++cell)->face(0)->set_boundary_indicator(1); + ++cell; Assert (cell->face(0)->at_boundary(), ExcInternalError()); + cell->face(0)->set_all_boundary_indicators(1); } else if (tria.n_cells() == 12) { @@ -222,7 +227,7 @@ namespace GridGenerator cell != tria.end(); ++cell) { Assert (cell->face(5)->at_boundary(), ExcInternalError()); - cell->face(5)->set_boundary_indicator(1); + cell->face(5)->set_all_boundary_indicators(1); } } else if (tria.n_cells() == 96) @@ -243,7 +248,7 @@ namespace GridGenerator cell != tria.end(); ++cell) if (cell->face(5)->at_boundary()) { - cell->face(5)->set_boundary_indicator(1); + cell->face(5)->set_all_boundary_indicators(1); ++count; } Assert (count == 48, ExcInternalError()); diff --git a/tests/deal.II/grid_hyper_shell_06.cc b/tests/deal.II/grid_hyper_shell_06.cc new file mode 100644 index 0000000000..fd1463b2b3 --- /dev/null +++ b/tests/deal.II/grid_hyper_shell_06.cc @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2007 - 2015 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. +// +// --------------------------------------------------------------------- + + +// GridGenerator::hyper_shell colorized the faces but forgot the +// edges. This is not useful because the colorization is usually done +// so that one can attach a boundary or manifold object to these parts +// of the boundary + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +std::ofstream logfile("output"); + + +template +void check (double r1, double r2, unsigned int n) +{ + Point center; + Triangulation tria (Triangulation::none); + GridGenerator::hyper_shell (tria, center, r1, r2, n, true); + static const HyperShellBoundary boundary(center); + tria.set_boundary(0, boundary); + + for (typename Triangulation::cell_iterator cell=tria.begin(); + cell != tria.end(); ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->at_boundary()) + for (unsigned int l=0; l::lines_per_face; ++l) + Assert (cell->face(f)->line(l)->boundary_indicator() + == + cell->face(f)->boundary_indicator(), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + +int main() +{ + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check<3> (.5, 1, 6); + check<3> (.5, 1, 12); + check<3> (.5, 1, 96); +} diff --git a/tests/deal.II/grid_hyper_shell_06.output b/tests/deal.II/grid_hyper_shell_06.output new file mode 100644 index 0000000000..fb71de2867 --- /dev/null +++ b/tests/deal.II/grid_hyper_shell_06.output @@ -0,0 +1,4 @@ + +DEAL::OK +DEAL::OK +DEAL::OK