Reference documentation for deal.II version Git d9b14c2d54 2019-09-14 18:13:29 -0600
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
grid_generator.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_grid_generator_h
17 #define dealii_grid_generator_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/function.h>
24 #include <deal.II/base/point.h>
25 #include <deal.II/base/table.h>
26 
27 #include <deal.II/grid/tria.h>
28 
29 #include <array>
30 #include <map>
31 
32 DEAL_II_NAMESPACE_OPEN
33 
56 namespace GridGenerator
57 {
61 
90  template <int dim, int spacedim>
91  void
93  const double left = 0.,
94  const double right = 1.,
95  const bool colorize = false);
96 
121  template <int dim>
122  void
124  const std::vector<Point<dim>> &vertices);
125 
151  template <int dim, int spacedim>
152  void
154  const unsigned int repetitions,
155  const double left = 0.,
156  const double right = 1.);
157 
192  template <int dim, int spacedim>
193  void
195  const Point<dim> & p1,
196  const Point<dim> & p2,
197  const bool colorize = false);
198 
249  template <int dim, int spacedim>
250  void
252  const std::vector<unsigned int> &repetitions,
253  const Point<dim> & p1,
254  const Point<dim> & p2,
255  const bool colorize = false);
256 
272  template <int dim>
273  void
275  const std::vector<std::vector<double>> &step_sizes,
276  const Point<dim> & p_1,
277  const Point<dim> & p_2,
278  const bool colorize = false);
279 
290  template <int dim>
291  void
293  const std::vector<std::vector<double>> &spacing,
294  const Point<dim> & p,
295  const Table<dim, types::material_id> &material_id,
296  const bool colorize = false);
297 
324  template <int dim, int spacedim>
325  void
327  const std::vector<unsigned int> &holes);
328 
372  template <int dim>
373  void
375  const double inner_radius = 0.4,
376  const double outer_radius = 1.,
377  const double pad_bottom = 2.,
378  const double pad_top = 2.,
379  const double pad_left = 1.,
380  const double pad_right = 1.,
381  const Point<dim> center = Point<dim>(),
382  const types::manifold_id polar_manifold_id = 0,
383  const types::manifold_id tfi_manifold_id = 1,
384  const double L = 1.,
385  const unsigned int n_slices = 2,
386  const bool colorize = false);
387 
474  template <int dim>
475  void
477  const double shell_region_width = 0.03,
478  const unsigned int n_shells = 2,
479  const double skewness = 2.0,
480  const bool colorize = false);
481 
504  template <int dim, int spacedim>
505  void
507  const std::vector<Point<spacedim>> &vertices,
508  const bool colorize = false);
509 
520  template <int dim>
521  void
523  const Point<dim> (&corners)[dim],
524  const bool colorize = false);
525 
540  template <int dim>
541  void
543  const Point<dim> (&corners)[dim],
544  const bool colorize = false);
545 
556  template <int dim>
557  void
559  const unsigned int n_subdivisions,
560  const Point<dim> (&corners)[dim],
561  const bool colorize = false);
562 
570  template <int dim>
571  void
573 #ifndef _MSC_VER
574  const unsigned int (&n_subdivisions)[dim],
575 #else
576  const unsigned int *n_subdivisions,
577 #endif
578  const Point<dim> (&corners)[dim],
579  const bool colorize = false);
580 
604  template <int dim, int spacedim>
605  void
607  const Point<spacedim> & origin,
608  const std::array<Tensor<1, spacedim>, dim> &edges,
609  const std::vector<unsigned int> &subdivisions = {},
610  const bool colorize = false);
611 
627  template <int dim>
628  void
630  const double left = 0.,
631  const double right = 1.,
632  const double thickness = 1.,
633  const bool colorize = false);
634 
670  template <int dim>
671  void
673  const Point<dim> & center = Point<dim>(),
674  const double radius = 1.,
675  const bool attach_spherical_manifold_on_boundary_cells = false);
676 
702  template <int spacedim>
704  const Point<spacedim> &center = Point<spacedim>(),
705  const double radius = 1.);
706 
718  template <int dim>
719  void
721  const Point<dim> & center = Point<dim>(),
722  const double radius = 1.);
723 
735  template <int dim>
736  void
738  const Point<dim> & center = Point<dim>(),
739  const double radius = 1.);
740 
768  template <int dim>
769  void
771  const double radius = 1.,
772  const double half_length = 1.);
773 
805  template <int dim>
806  void
808  const double radius_0 = 1.0,
809  const double radius_1 = 0.5,
810  const double half_length = 1.0);
811 
841  template <int dim, int spacedim>
842  void
844  const std::vector<unsigned int> &sizes,
845  const bool colorize_cells = false);
846 
881  template <int dim>
882  void
884  const double left = -1.,
885  const double right = 1.,
886  const bool colorize = false);
887 
919  template <int dim, int spacedim>
920  void
922  const std::vector<unsigned int> &repetitions,
923  const Point<dim> & bottom_left,
924  const Point<dim> & top_right,
925  const std::vector<int> & n_cells_to_remove);
926 
945  template <int dim>
946  void
948  const double left = 0.,
949  const double right = 1.,
950  const bool colorize = false);
951 
990  template <int dim>
991  void
993  const Point<dim> & center,
994  const double inner_radius,
995  const double outer_radius,
996  const unsigned int n_cells = 0,
997  bool colorize = false);
998 
1031  template <int dim>
1032  void
1034  const Point<dim> & inner_center,
1035  const Point<dim> & outer_center,
1036  const double inner_radius,
1037  const double outer_radius,
1038  const unsigned int n_cells);
1039 
1065  template <int dim>
1066  void
1068  const Point<dim> & center,
1069  const double inner_radius,
1070  const double outer_radius,
1071  const unsigned int n_cells = 0,
1072  const bool colorize = false);
1073 
1074 
1099  template <int dim>
1100  void
1102  const Point<dim> & center,
1103  const double inner_radius,
1104  const double outer_radius,
1105  const unsigned int n_cells = 0,
1106  const bool colorize = false);
1107 
1134  template <int dim>
1135  void
1137  const double length,
1138  const double inner_radius,
1139  const double outer_radius,
1140  const unsigned int n_radial_cells = 0,
1141  const unsigned int n_axial_cells = 0);
1142 
1185  template <int dim, int spacedim>
1186  void
1188  const double R,
1189  const double r,
1190  const unsigned int n_cells_toroidal = 6);
1191 
1221  template <int dim>
1222  void
1224  const double inner_radius = .25,
1225  const double outer_radius = .5,
1226  const double L = .5,
1227  const unsigned int repetitions = 1,
1228  const bool colorize = false);
1229 
1301  template <int dim>
1302  void
1304  const Point<dim> & center,
1305  const double inner_radius = 0.125,
1306  const double outer_radius = 0.25,
1307  const unsigned int n_shells = 1,
1308  const double skewness = 0.1,
1309  const unsigned int n_cells_per_shell = 0,
1310  const bool colorize = false);
1311 
1325  void moebius(Triangulation<3, 3> &tria,
1326  const unsigned int n_cells,
1327  const unsigned int n_rotations,
1328  const double R,
1329  const double r);
1330 
1332 
1336 
1397  template <int dim, int spacedim>
1398  void
1399  merge_triangulations(const Triangulation<dim, spacedim> &triangulation_1,
1400  const Triangulation<dim, spacedim> &triangulation_2,
1402  const double duplicated_vertex_tolerance = 1.0e-12,
1403  const bool copy_manifold_ids = false);
1404 
1419  template <int dim, int spacedim>
1420  void
1422  const std::initializer_list<const Triangulation<dim, spacedim> *const>
1423  & triangulations,
1425  const double duplicated_vertex_tolerance = 1.0e-12,
1426  const bool copy_manifold_ids = false);
1427 
1464  template <int dim, int spacedim>
1465  void
1467  const Triangulation<dim, spacedim> &triangulation_1,
1468  const Triangulation<dim, spacedim> &triangulation_2,
1469  Triangulation<dim, spacedim> & result);
1470 
1506  template <int dim, int spacedim>
1507  void
1509  const Triangulation<dim, spacedim> &input_triangulation,
1511  & cells_to_remove,
1513 
1568  void
1570  const Triangulation<2, 2> & input,
1571  const unsigned int n_slices,
1572  const double height,
1573  Triangulation<3, 3> & result,
1574  const bool copy_manifold_ids = false,
1575  const std::vector<types::manifold_id> &manifold_priorities = {});
1576 
1597  void
1599  const Triangulation<2, 2> & input,
1600  const std::vector<double> & slice_coordinates,
1601  Triangulation<3, 3> & result,
1602  const bool copy_manifold_ids = false,
1603  const std::vector<types::manifold_id> &manifold_priorities = {});
1604 
1605 
1640  template <int dim, int spacedim1, int spacedim2>
1641  void
1643  Triangulation<dim, spacedim2> & out_tria);
1644 
1646 
1652 
1654 #ifdef _MSC_VER
1655  // Microsoft's VC++ has a bug where it doesn't want to recognize that
1656  // an implementation (definition) of the extract_boundary_mesh function
1657  // matches a declaration. This can apparently only be avoided by
1658  // doing some contortion with the return type using the following
1659  // intermediate type. This is only used when using MS VC++ and uses
1660  // the direct way of doing it otherwise
1661  template <template <int, int> class MeshType, int dim, int spacedim>
1662  struct ExtractBoundaryMesh
1663  {
1664  using return_type =
1665  std::map<typename MeshType<dim - 1, spacedim>::cell_iterator,
1666  typename MeshType<dim, spacedim>::face_iterator>;
1667  };
1668 #endif
1669 
1745  template <template <int, int> class MeshType, int dim, int spacedim>
1746 #ifndef _MSC_VER
1747  std::map<typename MeshType<dim - 1, spacedim>::cell_iterator,
1748  typename MeshType<dim, spacedim>::face_iterator>
1749 #else
1750  typename ExtractBoundaryMesh<MeshType, dim, spacedim>::return_type
1751 #endif
1752  extract_boundary_mesh(const MeshType<dim, spacedim> & volume_mesh,
1753  MeshType<dim - 1, spacedim> & surface_mesh,
1754  const std::set<types::boundary_id> &boundary_ids =
1755  std::set<types::boundary_id>());
1756 
1758 
1759 
1763 
1765 
1774  int,
1775  << "The number of repetitions " << arg1 << " must be >=1.");
1780  int,
1781  << "The vector of repetitions must have " << arg1
1782  << " elements.");
1783 
1788  "The input to this function is oriented in a way that will"
1789  " cause all cells to have negative measure.");
1791 
1792 #ifndef DOXYGEN
1793  // These functions are only implemented with specializations; declare them
1794  // here
1795  template <>
1797  const double,
1798  const double,
1799  const double,
1800  const unsigned int,
1801  const bool);
1802 
1803  template <>
1805  const double,
1806  const double,
1807  const double,
1808  const unsigned int,
1809  const bool);
1810 
1811  template <>
1813  const double,
1814  const double,
1815  const double,
1816  const unsigned int,
1817  const bool);
1818 
1819  template <>
1821  const double,
1822  const unsigned int,
1823  const double,
1824  const bool);
1825 
1826  template <>
1828  const double,
1829  const unsigned int,
1830  const double,
1831  const bool);
1832 
1833  template <>
1835  const double,
1836  const unsigned int,
1837  const double,
1838  const bool);
1839 #endif
1840 } // namespace GridGenerator
1841 
1842 
1843 
1844 DEAL_II_NAMESPACE_CLOSE
1845 
1846 #endif
void create_union_triangulation(const Triangulation< dim, spacedim > &triangulation_1, const Triangulation< dim, spacedim > &triangulation_2, Triangulation< dim, spacedim > &result)
unsigned int manifold_id
Definition: types.h:137
void simplex(Triangulation< dim, dim > &tria, const std::vector< Point< dim >> &vertices)
Triangulation of a d-simplex with (d+1) vertices and mesh cells.
void channel_with_cylinder(Triangulation< dim > &tria, const double shell_region_width=0.03, const unsigned int n_shells=2, const double skewness=2.0, const bool colorize=false)
void concentric_hyper_shells(Triangulation< dim > &triangulation, const Point< dim > &center, const double inner_radius=0.125, const double outer_radius=0.25, const unsigned int n_shells=1, const double skewness=0.1, const unsigned int n_cells_per_shell=0, const bool colorize=false)
void general_cell(Triangulation< dim, spacedim > &tria, const std::vector< Point< spacedim >> &vertices, const bool colorize=false)
void truncated_cone(Triangulation< dim > &tria, const double radius_0=1.0, const double radius_1=0.5, const double half_length=1.0)
void hyper_rectangle(Triangulation< dim, spacedim > &tria, const Point< dim > &p1, const Point< dim > &p2, const bool colorize=false)
void moebius(Triangulation< 3, 3 > &tria, const unsigned int n_cells, const unsigned int n_rotations, const double R, const double r)
void flatten_triangulation(const Triangulation< dim, spacedim1 > &in_tria, Triangulation< dim, spacedim2 > &out_tria)
void quarter_hyper_shell(Triangulation< dim > &tria, const Point< dim > &center, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, const bool colorize=false)
void enclosed_hyper_cube(Triangulation< dim > &tria, const double left=0., const double right=1., const double thickness=1., const bool colorize=false)
void subdivided_parallelepiped(Triangulation< dim > &tria, const unsigned int n_subdivisions, const Point< dim >(&corners)[dim], const bool colorize=false)
static ::ExceptionBase & ExcInvalidRepetitionsDimension(int arg1)
void parallelogram(Triangulation< dim > &tria, const Point< dim >(&corners)[dim], const bool colorize=false)
void hyper_shell(Triangulation< dim > &tria, const Point< dim > &center, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, bool colorize=false)
static ::ExceptionBase & ExcInvalidInputOrientation()
void cylinder_shell(Triangulation< dim > &tria, const double length, const double inner_radius, const double outer_radius, const unsigned int n_radial_cells=0, const unsigned int n_axial_cells=0)
void hyper_cross(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &sizes, const bool colorize_cells=false)
A center cell with stacks of cell protruding from each surface.
void hyper_L(Triangulation< dim > &tria, const double left=-1., const double right=1., const bool colorize=false)
void half_hyper_ball(Triangulation< dim > &tria, const Point< dim > &center=Point< dim >(), const double radius=1.)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
void hyper_sphere(Triangulation< spacedim - 1, spacedim > &tria, const Point< spacedim > &center=Point< spacedim >(), const double radius=1.)
void cylinder(Triangulation< dim > &tria, const double radius=1., const double half_length=1.)
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
#define DeclException0(Exception0)
Definition: exceptions.h:473
void quarter_hyper_ball(Triangulation< dim > &tria, const Point< dim > &center=Point< dim >(), const double radius=1.)
void subdivided_hyper_cube(Triangulation< dim, spacedim > &tria, const unsigned int repetitions, const double left=0., const double right=1.)
void create_triangulation_with_removed_cells(const Triangulation< dim, spacedim > &input_triangulation, const std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > &cells_to_remove, Triangulation< dim, spacedim > &result)
void subdivided_hyper_L(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &repetitions, const Point< dim > &bottom_left, const Point< dim > &top_right, const std::vector< int > &n_cells_to_remove)
void extrude_triangulation(const Triangulation< 2, 2 > &input, const unsigned int n_slices, const double height, Triangulation< 3, 3 > &result, const bool copy_manifold_ids=false, const std::vector< types::manifold_id > &manifold_priorities={})
void hyper_cube_slit(Triangulation< dim > &tria, const double left=0., const double right=1., const bool colorize=false)
void subdivided_hyper_rectangle(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &repetitions, const Point< dim > &p1, const Point< dim > &p2, const bool colorize=false)
void merge_triangulations(const Triangulation< dim, spacedim > &triangulation_1, const Triangulation< dim, spacedim > &triangulation_2, Triangulation< dim, spacedim > &result, const double duplicated_vertex_tolerance=1.0e-12, const bool copy_manifold_ids=false)
static ::ExceptionBase & ExcInvalidRadii()
void cheese(Triangulation< dim, spacedim > &tria, const std::vector< unsigned int > &holes)
Rectangular domain with rectangular pattern of holes.
__global__ void set(Number *val, const Number s, const size_type N)
void torus(Triangulation< dim, spacedim > &tria, const double R, const double r, const unsigned int n_cells_toroidal=6)
void parallelepiped(Triangulation< dim > &tria, const Point< dim >(&corners)[dim], const bool colorize=false)
void half_hyper_shell(Triangulation< dim > &tria, const Point< dim > &center, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, const bool colorize=false)
void eccentric_hyper_shell(Triangulation< dim > &triangulation, const Point< dim > &inner_center, const Point< dim > &outer_center, const double inner_radius, const double outer_radius, const unsigned int n_cells)
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
std::map< typename MeshType< dim - 1, spacedim >::cell_iterator, typename MeshType< dim, spacedim >::face_iterator > extract_boundary_mesh(const MeshType< dim, spacedim > &volume_mesh, MeshType< dim - 1, spacedim > &surface_mesh, const std::set< types::boundary_id > &boundary_ids=std::set< types::boundary_id >())
void hyper_ball(Triangulation< dim > &tria, const Point< dim > &center=Point< dim >(), const double radius=1., const bool attach_spherical_manifold_on_boundary_cells=false)
Definition: table.h:699
void plate_with_a_hole(Triangulation< dim > &tria, const double inner_radius=0.4, const double outer_radius=1., const double pad_bottom=2., const double pad_top=2., const double pad_left=1., const double pad_right=1., const Point< dim > center=Point< dim >(), const types::manifold_id polar_manifold_id=0, const types::manifold_id tfi_manifold_id=1, const double L=1., const unsigned int n_slices=2, const bool colorize=false)
Rectangular plate with an (offset) cylindrical hole.
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)
static ::ExceptionBase & ExcInvalidRepetitions(int arg1)