-
Notifications
You must be signed in to change notification settings - Fork 707
/
grid_generator.h
1574 lines (1500 loc) · 69.7 KB
/
grid_generator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ---------------------------------------------------------------------
//
// Copyright (C) 1999 - 2018 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.
//
// ---------------------------------------------------------------------
#ifndef dealii_grid_generator_h
#define dealii_grid_generator_h
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
#include <deal.II/base/function.h>
#include <deal.II/base/point.h>
#include <deal.II/base/table.h>
#include <deal.II/grid/tria.h>
#include <array>
#include <map>
DEAL_II_NAMESPACE_OPEN
/**
* This namespace provides a collection of functions for generating
* triangulations for some basic geometries.
*
* Some of these functions receive a flag @p colorize (see
* @ref GlossColorization "the glossary entry on colorization").
* If this is set, parts of the boundary receive different
* @ref GlossBoundaryIndicator "boundary indicators"
* allowing them to be distinguished for the purpose of evaluating
* different boundary conditions.
*
* If the domain is curved, each of the domain parts that should be
* refined by following an appropriate Manifold description will
* receive a different
* @ref GlossManifoldIndicator "manifold indicator",
* and the correct Manifold descriptor will be attached to
* the Triangulation. Notice that if you later transform the
* triangulation, you have to make sure you attach the correct new Manifold
* to the triangulation.
*
* @ingroup grid
*/
namespace GridGenerator
{
/**
* @name Creating meshes for basic geometries
*/
///@{
/**
* Initialize the given triangulation with a hypercube (line in 1D, square
* in 2D, etc) consisting of exactly one cell. The hypercube volume is the
* tensor product interval $[left,right]^{\text{dim}}$ in the present number
* of dimensions, where the limits are given as arguments. They default to
* zero and unity, then producing the unit hypercube.
*
* If the argument @p colorize is false, then all boundary indicators are
* set to zero (the default boundary indicator) for 2d and 3d. If it is
* true, the boundary is
* @ref GlossColorization "colorized" as in hyper_rectangle(). In 1d the
* indicators are always colorized, see hyper_rectangle().
*
* @image html hyper_cubes.png
*
* If @p dim < @p spacedim, this will create a @p dim dimensional object in
* the first @p dim coordinate directions embedded into the @p spacedim
* dimensional space with the remaining entries set to zero. For example, a
* <tt>Triangulation@<2,3@></tt> will be a square in the xy plane with z=0.
*
* See also subdivided_hyper_cube() for a coarse mesh consisting of several
* cells. See hyper_rectangle(), if different lengths in different ordinate
* directions are required.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim, int spacedim>
void
hyper_cube(Triangulation<dim, spacedim> &tria,
const double left = 0.,
const double right = 1.,
const bool colorize = false);
/**
* \brief %Triangulation of a d-simplex with (d+1) vertices and mesh cells.
*
* The @p vertices argument contains a vector with all d+1 vertices of the
* simplex. They must be given in an order such that the vectors from the
* first vertex to each of the others form a right-handed system. And I am
* not happy about the discrimination involved here.
*
* The meshes generated in two and three dimensions are
*
* @image html simplex_2d.png
* @image html simplex_3d.png
*
* @param tria The Triangulation to create. It needs to be empty upon
* calling this function.
*
* @param vertices The dim+1 corners of the simplex.
*
* @note Implemented for <tt>Triangulation@<2,2@></tt>,
* <tt>Triangulation@<3,3@></tt>.
*
* @author Guido Kanschat
* @date 2015
*/
template <int dim>
void
simplex(Triangulation<dim, dim> & tria,
const std::vector<Point<dim>> &vertices);
/**
* Same as hyper_cube(), but with the difference that not only one cell is
* created but each coordinate direction is subdivided into @p repetitions
* cells. Thus, the number of cells filling the given volume is
* <tt>repetitions<sup>dim</sup></tt>.
*
* If @p dim < @p spacedim, this will create a @p dim dimensional object in
* the first @p dim coordinate directions embedded into the @p spacedim
* dimensional space with the remaining entries set to zero. For example, a
* <tt>Triangulation@<2,3@></tt> will be a square in the xy plane with z=0.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
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.);
/**
* Create a coordinate-parallel brick from the two diagonally opposite
* corner points @p p1 and @p p2.
*
* If the @p colorize flag is <code>true</code>, then the @p boundary_ids of
* the boundary faces are assigned, such that the lower one in @p
* x-direction is 0, the upper one is 1. The indicators for the surfaces in
* @p y-direction are 2 and 3, the ones for @p z are 4 and 5. This
* corresponds to the numbers of faces of the unit square of cube as laid
* out in the documentation of the GeometryInfo class; see also
* @ref GlossColorization "the glossary entry on colorization". Importantly,
* however, in 3d @ref GlossColorization "colorization" does not set @p
* boundary_ids of <i>edges</i>, but only of <i>faces</i>, because each
* boundary edge is shared between two faces and it is not clear how the
* boundary id of an edge should be set in that case.
*
* Additionally, if @p colorize is @p true, material ids are assigned to the
* cells according to the octant their center is in: being in the right half
* space for any coordinate direction <i>x<sub>i</sub></i> adds
* 2<sup>i</sup>. For instance, a cell with center point (1,-1,1) yields a
* material id 5, assuming that the center of the hyper rectangle lies at
* the origin. No manifold id is set for the cells.
*
* If @p dim < @p spacedim, this will create a @p dim dimensional object in
* the first @p dim coordinate directions embedded into the @p spacedim
* dimensional space with the remaining entries set to zero. For example, a
* <tt>Triangulation@<2,3@></tt> will be a rectangle in the xy plane with
* z=0, defined by the two opposing corners @p p1 and @p p2.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim, int spacedim>
void
hyper_rectangle(Triangulation<dim, spacedim> &tria,
const Point<dim> & p1,
const Point<dim> & p2,
const bool colorize = false);
/**
* Create a coordinate-parallel brick from the two diagonally opposite
* corner points @p p1 and @p p2. The number of cells in coordinate
* direction @p i is given by the integer <tt>repetitions[i]</tt>.
*
* To get cells with an aspect ratio different from that of the domain, use
* different numbers of subdivisions, given by @p repetitions, in different
* coordinate directions. The minimum number of subdivisions in each
* direction is 1.
*
* If the @p colorize flag is <code>true</code>, then the @p boundary_ids of
* the surfaces are assigned, such that the lower one in @p x-direction is
* 0, the upper one is 1 (the left and the right vertical face). The
* indicators for the surfaces in @p y-direction are 2 and 3, the ones for
* @p z are 4 and 5. Additionally, material ids are assigned to the cells
* according to the octant their center is in: being in the right half plane
* for any coordinate direction <i>x<sub>i</sub></i> adds 2<sup>i</sup> (see
* @ref GlossColorization "the glossary entry on colorization"). For
* instance, the center point (1,-1,1) yields a material id 5 (this means
* that in 2d only material ids 0,1,2,3 are assigned independent from the
* number of repetitions).
*
* Note that the @p colorize flag is ignored in 1d and is assumed to always
* be true. That means the boundary indicator is 0 on the left and 1 on the
* right. See step-15 for details.
*
* If @p dim < @p spacedim, this will create a @p dim dimensional object in
* the first @p dim coordinate directions embedded into the @p spacedim
* dimensional space with the remaining entries set to zero. For example, a
* <tt>Triangulation@<2,3@></tt> will be a rectangle in the xy plane with
* z=0, defined by the two opposing corners @p p1 and @p p2.
*
* @note For an example of the use of this function see the step-28 tutorial
* program.
*
* @param tria The Triangulation to create. It needs to be empty upon
* calling this function.
*
* @param repetitions A vector of @p dim positive values denoting the number
* of cells to generate in that direction.
*
* @param p1 First corner point.
*
* @param p2 Second corner opposite to @p p1.
*
* @param colorize Assign different boundary ids if set to true. The same
* comments apply as for the hyper_rectangle() function.
*
*/
template <int dim, int spacedim>
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);
/**
* Like the previous function. However, here the second argument does not
* denote the number of subdivisions in each coordinate direction, but a
* sequence of step sizes for each coordinate direction. The domain will
* therefore be subdivided into <code>step_sizes[i].size()</code> cells in
* coordinate direction <code>i</code>, with width
* <code>step_sizes[i][j]</code> for the <code>j</code>th cell.
*
* This function is therefore the right one to generate graded meshes where
* cells are concentrated in certain areas, rather than a uniformly
* subdivided mesh as the previous function generates.
*
* The step sizes have to add up to the dimensions of the hyper rectangle
* specified by the points @p p1 and @p p2.
*/
template <int dim>
void
subdivided_hyper_rectangle(Triangulation<dim> & tria,
const std::vector<std::vector<double>> &step_sizes,
const Point<dim> & p_1,
const Point<dim> & p_2,
const bool colorize = false);
/**
* Like the previous function, but with the following twist: the @p
* material_id argument is a dim-dimensional array that, for each cell,
* indicates which material_id should be set. In addition, and this is the
* major new functionality, if the material_id of a cell is <tt>(unsigned
* char)(-1)</tt>, then that cell is deleted from the triangulation, i.e.
* the domain will have a void there.
*
* @note If you need a lot of holes, you may consider cheese().
*/
template <int dim>
void
subdivided_hyper_rectangle(Triangulation<dim> & tria,
const std::vector<std::vector<double>> &spacing,
const Point<dim> & p,
const Table<dim, types::material_id> &material_id,
const bool colorize = false);
/**
* \brief Rectangular domain with rectangular pattern of holes
*
* The domain itself is rectangular, very much as if it had been generated
* by subdivided_hyper_rectangle(). The argument <code>holes</code>
* specifies how many square holes the domain should have in each coordinate
* direction. The total number of mesh cells in that direction is then twice
* this number plus one.
*
* The number of holes in one direction must be at least one.
*
* An example with two by three holes is
*
* @image html cheese_2d.png
*
* If @p dim < @p spacedim, this will create a @p dim dimensional object in
* the first @p dim coordinate directions embedded into the @p spacedim
* dimensional space with the remaining entries set to zero.
*
* @param tria The Triangulation to create. It needs to be empty upon
* calling this function.
*
* @param holes Positive number of holes in each of the dim directions.
* @author Guido Kanschat
* @date 2015
*/
template <int dim, int spacedim>
void
cheese(Triangulation<dim, spacedim> & tria,
const std::vector<unsigned int> &holes);
/**
* \brief Rectangular plate with an (offset) cylindrical hole.
*
* Generate a rectangular plate with an (offset) cylindrical hole. The
* geometry consists of 2 regions:
* The first is a square region with length @p outer_radius and a hole of radius @p inner_radius .
* Cells in this region will have TransfiniteInterpolationManifold with
* manifold id @p tfi_manifold_id attached to them. Additionally, the boundary
* faces of the hole will be associated with a PolarManifold (in 2D) or
* CylindricalManifold (in 3D). The center of this
* region can be prescribed via @p center , namely the axis of the hole will
* be located at @p center .
* The second region describes the remainder of the bulk material. It is
* specified via padding
* parameters @p pad_bottom, @p padding_top, @p padding_left and @p padding_right.
* All cells in this region will have a FlatManifold attached to them.
* The final width of the plate will be <code>padding_left + 2*outer_radius +
* padding_right</code>, while its length is <code>padding_top +
* 2*outer_radius + padding_bottom</code>. Three out of four paddings are
* allowed to be zero.
*
* Here is the non-symmetric grid (after one global refinement, colored
* according to manifold id) in 2D:
*
* @image html plate_with_a_hole.png
*
* and in 3D:
*
* @image html plate_with_a_hole_3D.png
*
* In 3D, triangulation will be extruded in the z-direction by the total
* height of @p L using @p n_slices slices (minimum is 2).
* If the @p colorize flag is <code>true</code>, the boundary_ids of the
* boundary faces are assigned such that the lower one in the x-direction is
* 0, and the upper one is 1 (see
* @ref GlossColorization "the glossary entry on colorization"). The
* indicators for the surfaces in the y-direction are 2 and 3, and the ones
* for the z-direction are 5 and 6. The hole boundary has indicator 4.
*
* @author Denis Davydov, 2018
*/
template <int dim>
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);
/**
* A general quadrilateral in 2d or a general hexahedron in 3d. It is the
* responsibility of the user to provide the vertices in the right order (see
* the documentation of the GeometryInfo class) because the vertices are
* stored in the same order as they are given. It is also important to make
* sure that the volume of the cell is positive.
*
* If the argument @p colorize is false, then all boundary indicators are
* set to zero for 2d and 3d. If it is true, the boundary is colorized as in
* hyper_rectangle() (see
* @ref GlossColorization "the glossary entry on colorization"). In 1d the
* indicators are always colorized, see hyper_rectangle().
*
* @author Bruno Turcksin
*/
template <int dim>
void
general_cell(Triangulation<dim> & tria,
const std::vector<Point<dim>> &vertices,
const bool colorize = false);
/**
* A parallelogram. The first corner point is the origin. The @p dim
* adjacent points are the ones given in the second argument and the fourth
* point will be the sum of these two vectors. Colorizing is done in the
* same way as in hyper_rectangle().
*
* @note This function is implemented in 2d only.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
parallelogram(Triangulation<dim> &tria,
const Point<dim> (&corners)[dim],
const bool colorize = false);
/**
* A parallelepiped. The first corner point is the origin. The @p dim
* adjacent points are vectors describing the edges of the parallelepiped
* with respect to the origin. Additional points are sums of these dim
* vectors. Colorizing is done according to hyper_rectangle().
*
* @note This function silently reorders the vertices on the cells to
* lexicographic ordering (see <code>GridReordering::reorder_grid</code>).
* In other words, if reordering of the vertices does occur, the ordering of
* vertices in the array of <code>corners</code> will no longer refer to the
* same triangulation.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
parallelepiped(Triangulation<dim> &tria,
const Point<dim> (&corners)[dim],
const bool colorize = false);
/**
* A subdivided parallelepiped. The first corner point is the origin. The @p
* dim adjacent points are vectors describing the edges of the
* parallelepiped with respect to the origin. Additional points are sums of
* these dim vectors. The variable @p n_subdivisions designates the number
* of subdivisions in each of the @p dim directions. Colorizing is done
* according to hyper_rectangle().
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
subdivided_parallelepiped(Triangulation<dim> &tria,
const unsigned int n_subdivisions,
const Point<dim> (&corners)[dim],
const bool colorize = false);
/**
* A subdivided parallelepiped, i.e., the same as above, but where the
* number of subdivisions in each of the @p dim directions may vary.
* Colorizing is done according to hyper_rectangle().
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
subdivided_parallelepiped(Triangulation<dim> &tria,
#ifndef _MSC_VER
const unsigned int (&n_subdivisions)[dim],
#else
const unsigned int *n_subdivisions,
#endif
const Point<dim> (&corners)[dim],
const bool colorize = false);
/**
* A subdivided parallelepiped.
*
* @param tria The Triangulation to create. It needs to be empty upon
* calling this function.
*
* @param origin First corner of the parallelepiped.
*
* @param edges An array of @p dim tensors describing the length and
* direction of the edges from @p origin.
*
* @param subdivisions Number of subdivisions in each of the dim directions.
* Each entry must be positive. An empty vector is equivalent to one
* subdivision in each direction.
*
* @param colorize Assign different boundary ids if set to true (see
* @ref GlossColorization "the glossary entry on colorization").
*
* @note Implemented for all combinations of @p dim and @p spacedim.
*
* @note You likely need to help the compiler by explicitly specifying the
* two template parameters when calling this function.
*/
template <int dim, int spacedim>
void
subdivided_parallelepiped(Triangulation<dim, spacedim> & tria,
const Point<spacedim> & origin,
const std::array<Tensor<1, spacedim>, dim> &edges,
const std::vector<unsigned int> &subdivisions = {},
const bool colorize = false);
/**
* Hypercube with a layer of hypercubes around it. The first two parameters
* give the lower and upper bound of the inner hypercube in all coordinate
* directions. @p thickness marks the size of the layer cells.
*
* If the flag @p colorize is set, the outer cells get material ids
* according to the following scheme: extending over the inner cube in (+/-)
* x-direction: 1/2. In y-direction 4/8, in z-direction 16/32. The cells at
* corners and edges (3d) get these values bitwise or'd (see also @ref
* GlossColorization "the glossary entry on colorization").
*
* Presently only available in 2d and 3d.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
enclosed_hyper_cube(Triangulation<dim> &tria,
const double left = 0.,
const double right = 1.,
const double thickness = 1.,
const bool colorize = false);
/**
* Initialize the given triangulation with several coarse mesh cells
* that cover a hyperball, i.e. a circle or a
* ball around @p center with given @p radius.
*
* In order to avoid degenerate cells at the boundaries, the circle is
* triangulated by five cells, the ball by seven cells. Specifically, these
* cells are one cell in the center plus one "cap" cell on each of the faces
* of this center cell. This ensures that under repeated refinement, none
* of the cells at the outer boundary will degenerate to have an interior
* angle approaching 180 degrees. The diameter of the
* center cell is chosen so that the aspect ratio of the boundary cells
* after one refinement is optimized.
*
* This function is declared to exist for triangulations of all space
* dimensions, but throws an error if called in 1d.
*
* By default, the manifold_id is set to 0 on the boundary faces, 1 on the
* the boundary cells, and types::flat_manifold_id on the central cell and on
* internal faces.
*
* A SphericalManifold is attached by default to the boundary faces for
* correct placement of boundary vertices upon refinement and to be able to
* use higher order mappings. However, it turns out that this strategy may
* not be the optimal one to create a good a mesh for a hyperball. The
* "Possibilities for extensions" section of step-6 has an extensive
* discussion of how one would construct better meshes and what one needs to
* do for it. Selecting the argument @p
* attach_spherical_manifold_on_boundary_cells to true attaches a
* SphericalManifold manifold also to the boundary cells, and not only to the
* boundary faces.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
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);
/**
* Creates a hyper sphere, i.e., a surface of a ball in @p spacedim
* dimensions. This function only exists for dim+1=spacedim in 2 and 3 space
* dimensions. (To create a mesh of a ball, use GridGenerator::hyper_ball().)
*
* By default, all manifold ids of the triangulation are set to zero, and a
* SphericalManifold is attached to the grid.
*
* The following pictures are generated with:
* @code
* Triangulation<2,3> triangulation;
* GridGenerator::hyper_sphere(triangulation);
* triangulation.refine_global(3);
* @endcode
*
* See the
* @ref manifold "documentation module on manifolds"
* for more details.
*
* @image html sphere.png
* @image html sphere_section.png
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int spacedim>
void hyper_sphere(Triangulation<spacedim - 1, spacedim> &tria,
const Point<spacedim> ¢er = Point<spacedim>(),
const double radius = 1.);
/**
* This class produces a hyper-ball intersected with the positive orthant
* relative to @p center, which contains three elements in 2d and four in 3d.
*
* The boundary indicators for the final triangulation are 0 for the curved
* boundary and 1 for the cut plane. The manifold id for the curved boundary
* is set to zero, and a SphericalManifold is attached to it.
*
* @note The triangulation passed as argument needs to be empty when calling
* this function.
*/
template <int dim>
void
quarter_hyper_ball(Triangulation<dim> &tria,
const Point<dim> & center = Point<dim>(),
const double radius = 1.);
/**
* This class produces a half hyper-ball around @p center, which contains
* four elements in 2d and 6 in 3d. The cut plane is perpendicular to the
* <i>x</i>-axis.
*
* The boundary indicators for the final triangulation are 0 for the curved
* boundary and 1 for the cut plane. The manifold id for the curved boundary
* is set to zero, and a SphericalManifold is attached to it.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
half_hyper_ball(Triangulation<dim> &tria,
const Point<dim> & center = Point<dim>(),
const double radius = 1.);
/**
* Create a cylinder around the $x$-axis. The cylinder extends from
* <tt>x=-half_length</tt> to <tt>x=+half_length</tt> and its projection
* into the @p yz-plane is a circle of radius @p radius.
*
* In two dimensions, the cylinder is a rectangle from
* <tt>x=-half_length</tt> to <tt>x=+half_length</tt> and from
* <tt>y=-radius</tt> to <tt>y=radius</tt>.
*
* The boundaries are colored according to the following scheme: 0 for the
* hull of the cylinder, 1 for the left hand face and 2 for the right hand
* face (see
* @ref GlossColorization "the glossary entry on colorization").
*
* If you want the cylinder to revolve around a different axis than the
* $x$-axis, then simply rotate the mesh generated by this function using
* the GridTools::transform() function using a rotation operator as
* argument.
*
* The manifold id for the hull of the cylinder is set to zero, and a
* CylindricalManifold is attached to it.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
cylinder(Triangulation<dim> &tria,
const double radius = 1.,
const double half_length = 1.);
/**
* Create a cut cone around the x-axis. The cone extends from
* <tt>x=-half_length</tt> to <tt>x=half_length</tt> and its projection into
* the @p yz-plane is a circle of radius @p radius_0 at
* <tt>x=-half_length</tt> and a circle of radius @p radius_1 at
* <tt>x=+half_length</tt>. In between the radius is linearly decreasing.
*
* In two dimensions, the cone is a trapezoid from <tt>x=-half_length</tt>
* to <tt>x=+half_length</tt> and from <tt>y=-radius_0</tt> to
* <tt>y=radius_0</tt> at <tt>x=-half_length</tt> and from
* <tt>y=-radius_1</tt> to <tt>y=radius_1</tt> at <tt>x=+half_length</tt>.
* In between the range of <tt>y</tt> is linearly decreasing.
*
* The boundaries are colored according to the following scheme: 0 for the
* hull of the cone, 1 for the left hand face, and 2 for the right hand face
* (see
* @ref GlossColorization "the glossary entry on colorization").
* Both the boundary indicators and the manifold indicators are set.
*
* In three dimensions, the manifold id of the hull is set to zero, and a
* CylindricalManifold is attached to it.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*
* @author Markus Bürg, 2009
*/
template <int dim>
void
truncated_cone(Triangulation<dim> &tria,
const double radius_0 = 1.0,
const double radius_1 = 0.5,
const double half_length = 1.0);
/**
* \brief A center cell with stacks of cell protruding from each surface.
*
* Each of the square mesh cells is Cartesian and has size one in each
* coordinate direction. The center of cell number zero is the origin.
*
* @param tria A Triangulation object which has to be empty.
*
* @param sizes A vector of integers of dimension
* GeometryInfo<dim>::faces_per_cell with the following meaning: the legs of
* the cross are stacked on the faces of the center cell, in the usual order
* of deal.II cells, namely first $-x$, then $x$, then $-y$ and so on. The
* corresponding entries in <code>sizes</code> name the number of cells
* stacked on this face. All numbers may be zero, thus L- and T-shaped
* domains are specializations of this domain.
*
* @param colorize_cells If colorization is enabled, then the material id of
* a cells corresponds to the leg it is in. The id of the center cell is
* zero, and then the legs are numbered starting at one (see
* @ref GlossColorization "the glossary entry on colorization").
*
* Examples in two and three dimensions are
*
* @image html hyper_cross_2d.png
* @image html hyper_cross_3d.png
*
* @author Guido Kanschat
* @date 2015
*/
template <int dim, int spacedim>
void
hyper_cross(Triangulation<dim, spacedim> & tria,
const std::vector<unsigned int> &sizes,
const bool colorize_cells = false);
/**
* Initialize the given triangulation with a hyper-L (in 2d or 3d)
* consisting of exactly <tt>2^dim-1</tt> cells. It produces the
* hypercube with the interval [<i>left,right</i>] without the
* hypercube made out of the interval [<i>(left+right)/2,right</i>]
* for each coordinate. Because the domain is about the simplest one
* with a reentrant (i.e., non-convex) corner, solutions of many
* partial differential equation have singularities at this
* corner. That is, at the corner, the gradient or a higher
* derivative (depending on the boundary conditions chosen) does not
* remain bounded. As a consequence, this domain is often used to
* test convergence of schemes when the solution lacks regularity.
*
* If the @p colorize flag is <code>true</code>, the @p boundary_ids of the
* surfaces are assigned such that the left boundary is 0 and the others are
* assigned counterclockwise in ascending order (see
* @ref GlossColorization "the glossary entry on colorization"). The @p
* colorize option only works in two dimensions.
*
* This function will create the classical L-shape in 2d
* and it will look like the following in 3d:
*
* @image html hyper_l.png
*
* @note The 3d domain is also often referred to as the "Fichera corner",
* named after Gaetano Fichera (1922-1996) who first computed an
* approximation of the corner singularity exponent of the lowest
* eigenfunction of the domain.
*
* This function exists for triangulations of all space
* dimensions, but throws an error if called in 1d.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
hyper_L(Triangulation<dim> &tria,
const double left = -1.,
const double right = 1.,
const bool colorize = false);
/**
* Initialize the given Triangulation with a hypercube with a slit. In each
* coordinate direction, the hypercube extends from @p left to @p right.
*
* In 2d, the split goes in vertical direction from <tt>x=(left+right)/2,
* y=left</tt> to the center of the square at <tt>x=y=(left+right)/2</tt>.
*
* In 3d, the 2d domain is just extended in the <i>z</i>-direction, such
* that a plane cuts the lower half of a rectangle in two. This function is
* 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 (see
* @ref GlossColorization "the glossary entry on colorization").
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
void
hyper_cube_slit(Triangulation<dim> &tria,
const double left = 0.,
const double right = 1.,
const bool colorize = false);
/**
* Produce a hyper-shell, the region between two spheres around
* <tt>center</tt>, with given <tt>inner_radius</tt> and
* <tt>outer_radius</tt>. The number <tt>n_cells</tt> indicates the number
* 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 <code>true</code>, 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 (see
* @ref GlossColorization "the glossary entry on colorization").
*
* All manifold ids are set to zero, and a SphericalManifold is attached to
* every cell and face of the triangulation.
*
* In 2d, the number <tt>n_cells</tt> of elements for this initial
* triangulation can be chosen arbitrarily. If the number of initial cells
* is zero (as is the default), then it is computed adaptively such that the
* resulting elements have the least aspect ratio.
*
* In 3d, only certain numbers are allowed, 6 (or the default 0) for a
* surface based on a hexahedron (i.e. 6 panels on the inner sphere extruded
* in radial direction to form 6 cells), 12 for the rhombic dodecahedron,
* and 96. This choice dates from an older version of deal.II before the
* Manifold classes were implemented: today all three choices are roughly
* equivalent (after performing global refinement, of course).
*
* The grids with 12 and 96 cells are plotted below:
*
* @image html hypershell3d-12.png
* @image html hypershell3d-96.png
*
* @note This function is declared to exist for triangulations of all space
* dimensions, but throws an error if called in 1d.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
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);
/**
* Produce a half hyper-shell, i.e. the space between two circles in two
* space dimensions and the region between two spheres in 3d, with given
* inner and outer radius and a given number of elements for this initial
* triangulation. However, opposed to the previous function, it does not
* produce a whole shell, but only one half of it, namely that part for
* which the first component is restricted to non-negative values. The
* purpose of this class is to enable computations for solutions which have
* rotational symmetry, in which case the half shell in 2d represents a
* shell in 3d.
*
* If the number of initial cells is zero (as is the default), then it is
* computed adaptively such that the resulting elements have the least
* aspect ratio.
*
* If colorize is set to <code>true</code>, the inner, outer, and the part
* of the boundary where $x=0$, get indicator 0, 1, and 2,
* respectively. Otherwise all indicators are set to 0 (see
* @ref GlossColorization "the glossary entry on colorization").
*
* All manifold ids are set to zero, and a SphericalManifold is attached
* to the triangulation.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
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);
/**
* Produce a domain that is the intersection between a hyper-shell with
* given inner and outer radius, i.e. the space between two circles in two
* space dimensions and the region between two spheres in 3d, and the
* positive quadrant (in 2d) or octant (in 3d). In 2d, this is indeed a
* quarter of the full annulus, while the function is a misnomer in 3d
* because there the domain is not a quarter but one eighth of the full
* shell.
*
* If the number of initial cells is zero (as is the default), then it is
* computed adaptively such that the resulting elements have the least
* aspect ratio in 2d.
*
* If @p colorize is set to <code>true</code>, the inner, outer, left, and
* right boundary get indicator 0, 1, 2, and 3 in 2d,
* respectively. Otherwise all indicators are set to 0. In 3d indicator 2 is
* at the face $x=0$, 3 at $y=0$, 4 at $z=0$ (see
* @ref GlossColorization "the glossary entry on colorization").
*
* All manifold ids are set to zero, and a SphericalManifold is attached
* to the triangulation.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
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);
/**
* Produce a domain that is the space between two cylinders in 3d, with
* given length, inner and outer radius and a given number of elements. The
* cylinder shell is built around the $z$-axis with the two faces located
* at $z = 0$ and $z = $ @p length.
*
* If @p n_radial_cells is zero (as is the
* default), then it is computed adaptively such that the resulting elements
* have the least aspect ratio. The same holds for @p n_axial_cells.
*
* @note Although this function is declared as a template, it does not make
* sense in 1D and 2D. Also keep in mind that this object is rotated
* and positioned differently than the one created by cylinder().
*
* All manifold ids are set to zero, and a CylindricalManifold is attached
* to the triangulation.
*
* @note The triangulation passed as argument needs to be empty when calling this function.
*/
template <int dim>
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);
/**
* Produce the volume or surface mesh of a torus. The axis of the torus is
* the $y$-axis while the plane of the torus is the $x$-$z$ plane.
*
* If @p dim is 3, the mesh will be the volume of the torus and this
* function attaches a TorusManifold to all boundary cells and faces (which
* are marked with a manifold id of 0).
*
* If @p dim is 2, the mesh will describe the surface of the torus and this
* function attaches a TorusManifold to all cells and faces (which are
* marked with a manifold id of 0).
*
* @param tria The triangulation to be filled.
*
* @param R The radius of the circle, which forms the middle line of the
* torus containing the loop of cells. Must be greater than @p r.
*
* @param r The inner radius of the torus.
*
* @note Implemented for Triangulation<2,3> and Triangulation<3,3>.
*/
template <int dim, int spacedim>
void
torus(Triangulation<dim, spacedim> &tria, const double R, const double r);
/**
* This class produces a square in the <i>xy</i>-plane with a cylindrical
* hole in the middle. The square and the circle are centered at the
* origin. In 3d, this geometry is extruded in $z$ direction to the interval
* $[0,L]$.
*
* The inner boundary has a manifold id of $0$ and a boundary id of
* $6$. This function attaches a PolarManifold or CylindricalManifold to the
* interior boundary in 2d and 3d respectively. The other faces have
* boundary ids of $0, 1, 2, 3, 4$, or $5$ given in the standard order of
* faces in 2d or 3d.
*
* @image html cubes_hole.png
*
* It is implemented in 2d and 3d, and takes the following arguments:
*
* @param triangulation The triangulation to be filled.
* @param inner_radius Radius of the internal hole.
* @param outer_radius Half of the edge length of the square.
* @param L Extension in @p z-direction (only used in 3d).
* @param repetitions Number of subdivisions along the @p z-direction.
* @param colorize Whether to assign different boundary indicators to
* different faces
* (see @ref GlossColorization "the glossary entry on colorization").
* The colors are given in lexicographic ordering for the
* flat faces (0 to 3 in 2d, 0 to 5 in 3d) plus the curved hole (4 in 2d,
* and 6 in 3d). If @p colorize is set to false, then flat faces get the
* number 0 and the hole gets number 1.
*/
template <int dim>
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);
/**
* Produce a grid consisting of concentric shells. The primary difference
* between this function and GridGenerator::hyper_shell is that this
* function permits unevenly spaced (in the radial direction) coarse level
* cells.
*
* The parameters @p center, @p inner_radius, and @p outer_radius behave in
* the same way as the first three arguments to