--- /dev/null
+Improved: GridGenerator::subdivided_hyper_cube() gained an option to also set boundary ids.
+<br>
+(Bruno Blais, 2019/12/05)
* @param left Lower bound for the interval used to create the hyper cube.
*
* @param right Upper bound for the interval used to create the hyper cube.
+ *
+ * @param colorize Assign different boundary ids if set to true.
*/
template <int dim, int spacedim>
void
subdivided_hyper_cube(Triangulation<dim, spacedim> &tria,
const unsigned int repetitions,
- const double left = 0.,
- const double right = 1.);
+ const double left = 0.,
+ const double right = 1.,
+ const bool colorize = false);
/**
* Create a coordinate-parallel brick from the two diagonally opposite
subdivided_hyper_cube(Triangulation<dim, spacedim> &tria,
const unsigned int repetitions,
const double left,
- const double right)
+ const double right,
+ const bool colorize)
{
Assert(repetitions >= 1, ExcInvalidRepetitions(repetitions));
Assert(left < right,
}
std::vector<unsigned int> reps(dim, repetitions);
- subdivided_hyper_rectangle(tria, reps, p0, p1);
+ subdivided_hyper_rectangle(tria, reps, p0, p1, colorize);
}
Triangulation<deal_II_dimension, deal_II_space_dimension> &,
const unsigned int,
const double,
- const double);
+ const double,
+ const bool);
template void
arguments,
tria);
else if (name == "subdivided_hyper_cube")
- parse_and_create<dim, spacedim, unsigned int, double, double>(
+ parse_and_create<dim, spacedim, unsigned int, double, double, bool>(
subdivided_hyper_cube, arguments, tria);
else if (name == "hyper_rectangle")
parse_and_create<dim,
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// Test for GridGenerator::subdivided_hyper_cube() with colorized boundary
+// conditions
+
+#include <deal.II/base/tensor.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include "../tests.h"
+
+template <int dim>
+void
+test()
+{
+ deallog << "dim = " << dim << std::endl;
+ Triangulation<dim> tr;
+ GridGenerator::subdivided_hyper_cube(tr, 1, -1, 1, true);
+ for (const auto &cell : tr.active_cell_iterators())
+ {
+ deallog << "cell:" << std::endl;
+
+ for (const auto &face : cell->face_iterators())
+ {
+ if (face->at_boundary())
+ deallog << "boundary id = " << face->boundary_id()
+ << " center = " << face->center()
+ << " faceidx = " << face->index() << std::endl;
+ }
+ }
+}
+
+int
+main()
+{
+ initlog();
+ test<2>();
+ test<3>();
+}
--- /dev/null
+
+DEAL::dim = 2
+DEAL::cell:
+DEAL::boundary id = 0 center = -1.00000 0.00000 faceidx = 1
+DEAL::boundary id = 1 center = 1.00000 0.00000 faceidx = 2
+DEAL::boundary id = 2 center = 0.00000 -1.00000 faceidx = 0
+DEAL::boundary id = 3 center = 0.00000 1.00000 faceidx = 3
+DEAL::dim = 3
+DEAL::cell:
+DEAL::boundary id = 0 center = -1.00000 0.00000 0.00000 faceidx = 2
+DEAL::boundary id = 1 center = 1.00000 0.00000 0.00000 faceidx = 3
+DEAL::boundary id = 2 center = 0.00000 -1.00000 0.00000 faceidx = 0
+DEAL::boundary id = 3 center = 0.00000 1.00000 0.00000 faceidx = 4
+DEAL::boundary id = 4 center = 0.00000 0.00000 -1.00000 faceidx = 1
+DEAL::boundary id = 5 center = 0.00000 0.00000 1.00000 faceidx = 5