--- /dev/null
+New: The functions GridGenerator::hyper_shell() and
+GridGenerator::hyper_cube_with_cylindrical_hole() now support
+dim=2 and spacedim=3.
+<br>
+(Peter Munch, 2024/07/16)
* `triangulation.generate_hyper_shell(center, inner_radius, outer_radius,
* n_cells = 0, colorize = false)`.
*/
- template <int dim>
+ template <int dim, int spacedim>
void
- hyper_shell(Triangulation<dim> &tria,
- const Point<dim> ¢er,
- const double inner_radius,
- const double outer_radius,
- const unsigned int n_cells = 0,
- bool colorize = false);
+ hyper_shell(Triangulation<dim, spacedim> &tria,
+ const Point<spacedim> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells = 0,
+ bool colorize = false);
/**
* Produce an eccentric hyper-shell, the region between two spheres centered
* `triangulation.generate_hyper_cube_with_cylindrical_hole(inner_radius =
* 0.25, outer_radius = 0.5, L = 0.5, repetitions = 1, colorize = false)`.
*/
- template <int dim>
+ template <int dim, int spacedim>
void
- hyper_cube_with_cylindrical_hole(Triangulation<dim> &triangulation,
- const double inner_radius = .25,
- const double outer_radius = .5,
- const double L = .5,
- const unsigned int repetitions = 1,
- const bool colorize = false);
+ hyper_cube_with_cylindrical_hole(Triangulation<dim, spacedim> &triangulation,
+ const double inner_radius = .25,
+ const double outer_radius = .5,
+ const double L = .5,
+ const unsigned int repetitions = 1,
+ const bool colorize = false);
/**
* Produce a grid consisting of concentric shells. The primary difference
* Assign boundary number zero to the inner shell boundary and 1 to the
* outer.
*/
+ template <int spacdim>
void
- colorize_hyper_shell(Triangulation<2> &tria,
- const Point<2> &,
+ colorize_hyper_shell(Triangulation<2, spacdim> &tria,
+ const Point<spacdim> &,
const double,
const double)
{
// For the mesh based on cube,
// this is highly irregular
- for (Triangulation<2>::cell_iterator cell = tria.begin();
- cell != tria.end();
- ++cell)
+ for (auto cell = tria.begin(); cell != tria.end(); ++cell)
{
Assert(cell->face(2)->at_boundary(), ExcInternalError());
cell->face(2)->set_all_boundary_ids(1);
- template <>
+ template <int spacedim>
void
- hyper_shell(Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const unsigned int n_cells,
- const bool colorize)
+ hyper_shell_2D(Triangulation<2, spacedim> &tria,
+ const Point<spacedim> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells,
+ const bool colorize)
{
Assert((inner_radius > 0) && (inner_radius < outer_radius),
ExcInvalidRadii());
// first N ones are on the
// outer one, and all are
// numbered counter-clockwise
- std::vector<Point<2>> vertices(2 * N);
+ std::vector<Point<spacedim>> vertices(2 * N);
for (unsigned int i = 0; i < N; ++i)
{
- vertices[i] =
- Point<2>(std::cos(2 * pi * i / N), std::sin(2 * pi * i / N)) *
- outer_radius;
+ Point<spacedim> point;
+ point[0] = std::cos(2 * pi * i / N);
+ point[1] = std::sin(2 * pi * i / N);
+
+ vertices[i] = point * outer_radius;
vertices[i + N] = vertices[i] * (inner_radius / outer_radius);
vertices[i] += center;
colorize_hyper_shell(tria, center, inner_radius, outer_radius);
tria.set_all_manifold_ids(0);
- tria.set_manifold(0, SphericalManifold<2>(center));
+ tria.set_manifold(0, SphericalManifold<2, spacedim>(center));
+ }
+
+
+
+ template <>
+ void
+ hyper_shell(Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells,
+ const bool colorize)
+ {
+ hyper_shell_2D(tria, center, inner_radius, outer_radius, n_cells, colorize);
+ }
+
+
+
+ template <>
+ void
+ hyper_shell(Triangulation<2, 3> &tria,
+ const Point<3> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells,
+ const bool colorize)
+ {
+ hyper_shell_2D(tria, center, inner_radius, outer_radius, n_cells, colorize);
}
- template <>
+ template <int spacedim>
void
- hyper_cube_with_cylindrical_hole(Triangulation<2> &triangulation,
- const double inner_radius,
- const double outer_radius,
- const double, // width,
- const unsigned int, // width_repetition,
- const bool colorize)
+ hyper_cube_with_cylindrical_hole_2D(Triangulation<2, spacedim> &triangulation,
+ const double inner_radius,
+ const double outer_radius,
+ const double, // width,
+ const unsigned int, // width_repetition,
+ const bool colorize)
{
const int dim = 2;
Assert(inner_radius < outer_radius,
ExcMessage("outer_radius has to be bigger than inner_radius."));
- const Point<dim> center;
+ const Point<spacedim> center;
// We create a hyper_shell (i.e., an annulus) in two dimensions, and then we
// modify it by pulling the vertices on the diagonals out to where the
}
}
}
- triangulation.set_manifold(0, PolarManifold<2>(center));
+ triangulation.set_manifold(0, PolarManifold<2, spacedim>(center));
+ }
+
+
+
+ template <>
+ void
+ hyper_cube_with_cylindrical_hole(Triangulation<2, 2> &triangulation,
+ const double inner_radius,
+ const double outer_radius,
+ const double width,
+ const unsigned int width_repetition,
+ const bool colorize)
+ {
+ hyper_cube_with_cylindrical_hole_2D(triangulation,
+ inner_radius,
+ outer_radius,
+ width,
+ width_repetition,
+ colorize);
+ }
+
+
+
+ template <>
+ void
+ hyper_cube_with_cylindrical_hole(Triangulation<2, 3> &triangulation,
+ const double inner_radius,
+ const double outer_radius,
+ const double width,
+ const unsigned int width_repetition,
+ const bool colorize)
+ {
+ hyper_cube_with_cylindrical_hole_2D(triangulation,
+ inner_radius,
+ outer_radius,
+ width,
+ width_repetition,
+ colorize);
}
-template <int dim>
+template <int dim, int spacdim = dim>
void
test(std::ostream &out)
{
GridOut go;
go.set_flags(GridOutFlags::Ucd(false, true));
- Triangulation<dim> tr;
+ Triangulation<dim, spacdim> tr;
std::vector<double> radii;
radii.push_back(.2);
deallog.push("2d");
test<2>(deallog.get_file_stream());
deallog.pop();
+ deallog.push("2d-3d");
+ test<2, 3>(deallog.get_file_stream());
+ deallog.pop();
deallog.push("3d");
test<3>(deallog.get_file_stream());
deallog.pop();
Depth = 0.100000
Nzs = 2
No colorize ====================
+16 16 0 0 0
+1 0.300000 0.00000 0.00000
+2 0.300000 0.300000 0.00000
+3 1.83697e-17 0.300000 0.00000
+4 -0.300000 0.300000 0.00000
+5 -0.300000 3.67394e-17 0.00000
+6 -0.300000 -0.300000 0.00000
+7 -5.51091e-17 -0.300000 0.00000
+8 0.300000 -0.300000 0.00000
+9 0.200000 0.00000 0.00000
+10 0.141421 0.141421 0.00000
+11 1.22465e-17 0.200000 0.00000
+12 -0.141421 0.141421 0.00000
+13 -0.200000 2.44929e-17 0.00000
+14 -0.141421 -0.141421 0.00000
+15 -3.67394e-17 -0.200000 0.00000
+16 0.141421 -0.141421 0.00000
+1 0 quad 1 2 10 9
+2 0 quad 2 3 11 10
+3 0 quad 3 4 12 11
+4 0 quad 4 5 13 12
+5 0 quad 5 6 14 13
+6 0 quad 6 7 15 14
+7 0 quad 7 8 16 15
+8 0 quad 8 1 9 16
+9 1 line 9 10
+10 1 line 10 11
+11 1 line 11 12
+12 1 line 12 13
+13 1 line 13 14
+14 1 line 14 15
+15 1 line 15 16
+16 1 line 16 9
+Colorize ====================
+16 22 0 0 0
+1 0.300000 0.00000 0.00000
+2 0.300000 0.300000 0.00000
+3 1.83697e-17 0.300000 0.00000
+4 -0.300000 0.300000 0.00000
+5 -0.300000 3.67394e-17 0.00000
+6 -0.300000 -0.300000 0.00000
+7 -5.51091e-17 -0.300000 0.00000
+8 0.300000 -0.300000 0.00000
+9 0.200000 0.00000 0.00000
+10 0.141421 0.141421 0.00000
+11 1.22465e-17 0.200000 0.00000
+12 -0.141421 0.141421 0.00000
+13 -0.200000 2.44929e-17 0.00000
+14 -0.141421 -0.141421 0.00000
+15 -3.67394e-17 -0.200000 0.00000
+16 0.141421 -0.141421 0.00000
+1 0 quad 1 2 10 9
+2 0 quad 2 3 11 10
+3 0 quad 3 4 12 11
+4 0 quad 4 5 13 12
+5 0 quad 5 6 14 13
+6 0 quad 6 7 15 14
+7 0 quad 7 8 16 15
+8 0 quad 8 1 9 16
+9 1 line 1 2
+10 3 line 2 3
+11 3 line 3 4
+12 2 line 6 7
+13 2 line 7 8
+14 1 line 8 1
+15 4 line 9 10
+16 4 line 10 11
+17 4 line 11 12
+18 4 line 12 13
+19 4 line 13 14
+20 4 line 14 15
+21 4 line 15 16
+22 4 line 16 9
+ ====================
+ ====================
+Inner radius = 0.300000
+Outer radius = 0.400000
+Depth = 0.100000
+Nzs = 2
+No colorize ====================
+16 16 0 0 0
+1 0.400000 0.00000 0.00000
+2 0.400000 0.400000 0.00000
+3 2.44929e-17 0.400000 0.00000
+4 -0.400000 0.400000 0.00000
+5 -0.400000 4.89859e-17 0.00000
+6 -0.400000 -0.400000 0.00000
+7 -7.34788e-17 -0.400000 0.00000
+8 0.400000 -0.400000 0.00000
+9 0.300000 0.00000 0.00000
+10 0.212132 0.212132 0.00000
+11 1.83697e-17 0.300000 0.00000
+12 -0.212132 0.212132 0.00000
+13 -0.300000 3.67394e-17 0.00000
+14 -0.212132 -0.212132 0.00000
+15 -5.51091e-17 -0.300000 0.00000
+16 0.212132 -0.212132 0.00000
+1 0 quad 1 2 10 9
+2 0 quad 2 3 11 10
+3 0 quad 3 4 12 11
+4 0 quad 4 5 13 12
+5 0 quad 5 6 14 13
+6 0 quad 6 7 15 14
+7 0 quad 7 8 16 15
+8 0 quad 8 1 9 16
+9 1 line 9 10
+10 1 line 10 11
+11 1 line 11 12
+12 1 line 12 13
+13 1 line 13 14
+14 1 line 14 15
+15 1 line 15 16
+16 1 line 16 9
+Colorize ====================
+16 22 0 0 0
+1 0.400000 0.00000 0.00000
+2 0.400000 0.400000 0.00000
+3 2.44929e-17 0.400000 0.00000
+4 -0.400000 0.400000 0.00000
+5 -0.400000 4.89859e-17 0.00000
+6 -0.400000 -0.400000 0.00000
+7 -7.34788e-17 -0.400000 0.00000
+8 0.400000 -0.400000 0.00000
+9 0.300000 0.00000 0.00000
+10 0.212132 0.212132 0.00000
+11 1.83697e-17 0.300000 0.00000
+12 -0.212132 0.212132 0.00000
+13 -0.300000 3.67394e-17 0.00000
+14 -0.212132 -0.212132 0.00000
+15 -5.51091e-17 -0.300000 0.00000
+16 0.212132 -0.212132 0.00000
+1 0 quad 1 2 10 9
+2 0 quad 2 3 11 10
+3 0 quad 3 4 12 11
+4 0 quad 4 5 13 12
+5 0 quad 5 6 14 13
+6 0 quad 6 7 15 14
+7 0 quad 7 8 16 15
+8 0 quad 8 1 9 16
+9 1 line 1 2
+10 3 line 2 3
+11 3 line 3 4
+12 2 line 6 7
+13 2 line 7 8
+14 1 line 8 1
+15 4 line 9 10
+16 4 line 10 11
+17 4 line 11 12
+18 4 line 12 13
+19 4 line 13 14
+20 4 line 14 15
+21 4 line 15 16
+22 4 line 16 9
+ ====================
+ ====================
+Inner radius = 0.400000
+Outer radius = 0.500000
+Depth = 0.100000
+Nzs = 2
+No colorize ====================
+16 16 0 0 0
+1 0.500000 0.00000 0.00000
+2 0.500000 0.500000 0.00000
+3 3.06162e-17 0.500000 0.00000
+4 -0.500000 0.500000 0.00000
+5 -0.500000 6.12323e-17 0.00000
+6 -0.500000 -0.500000 0.00000
+7 -9.18485e-17 -0.500000 0.00000
+8 0.500000 -0.500000 0.00000
+9 0.400000 0.00000 0.00000
+10 0.282843 0.282843 0.00000
+11 2.44929e-17 0.400000 0.00000
+12 -0.282843 0.282843 0.00000
+13 -0.400000 4.89859e-17 0.00000
+14 -0.282843 -0.282843 0.00000
+15 -7.34788e-17 -0.400000 0.00000
+16 0.282843 -0.282843 0.00000
+1 0 quad 1 2 10 9
+2 0 quad 2 3 11 10
+3 0 quad 3 4 12 11
+4 0 quad 4 5 13 12
+5 0 quad 5 6 14 13
+6 0 quad 6 7 15 14
+7 0 quad 7 8 16 15
+8 0 quad 8 1 9 16
+9 1 line 9 10
+10 1 line 10 11
+11 1 line 11 12
+12 1 line 12 13
+13 1 line 13 14
+14 1 line 14 15
+15 1 line 15 16
+16 1 line 16 9
+Colorize ====================
+16 22 0 0 0
+1 0.500000 0.00000 0.00000
+2 0.500000 0.500000 0.00000
+3 3.06162e-17 0.500000 0.00000
+4 -0.500000 0.500000 0.00000
+5 -0.500000 6.12323e-17 0.00000
+6 -0.500000 -0.500000 0.00000
+7 -9.18485e-17 -0.500000 0.00000
+8 0.500000 -0.500000 0.00000
+9 0.400000 0.00000 0.00000
+10 0.282843 0.282843 0.00000
+11 2.44929e-17 0.400000 0.00000
+12 -0.282843 0.282843 0.00000
+13 -0.400000 4.89859e-17 0.00000
+14 -0.282843 -0.282843 0.00000
+15 -7.34788e-17 -0.400000 0.00000
+16 0.282843 -0.282843 0.00000
+1 0 quad 1 2 10 9
+2 0 quad 2 3 11 10
+3 0 quad 3 4 12 11
+4 0 quad 4 5 13 12
+5 0 quad 5 6 14 13
+6 0 quad 6 7 15 14
+7 0 quad 7 8 16 15
+8 0 quad 8 1 9 16
+9 1 line 1 2
+10 3 line 2 3
+11 3 line 3 4
+12 2 line 6 7
+13 2 line 7 8
+14 1 line 8 1
+15 4 line 9 10
+16 4 line 10 11
+17 4 line 11 12
+18 4 line 12 13
+19 4 line 13 14
+20 4 line 14 15
+21 4 line 15 16
+22 4 line 16 9
+ ====================
+ ====================
+Inner radius = 0.200000
+Outer radius = 0.300000
+Depth = 0.100000
+Nzs = 2
+No colorize ====================
48 32 0 0 0
1 0.300000 0.00000 0.00000
2 0.300000 0.300000 0.00000