Debian Codegraph @

include/deal.II/base/geometry_info.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 1998 - 2025 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_geometry_info_h
16 #define dealii_geometry_info_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/ndarray.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/base/std_cxx20/iota_view.h>
25 #include <deal.II/base/tensor.h>
26
27 #include <array>
28 #include <cstdint>
29
30
31
32 DEAL_II_NAMESPACE_OPEN
33
34 #ifndef DOXYGEN
35 namespace internal
36 {
37 namespace GeometryInfoHelper
38 {
39 // A struct that holds the values for all the arrays we want to initialize
40 // in GeometryInfo
41 template <int dim>
42 struct Initializers;
43
44 template <>
45 struct Initializers<1>
46 {
47 static constexpr std::array<unsigned int, 2>
48 ucd_to_deal()
49 {
50 return {{0, 1}};
51 }
52
53 static constexpr std::array<unsigned int, 2>
54 unit_normal_direction()
55 {
56 return {{0, 0}};
57 }
58
59 static constexpr std::array<int, 2>
60 unit_normal_orientation()
61 {
62 return {{-1, 1}};
63 }
64
65 static constexpr std::array<Tensor<1, 1>, 2>
66 unit_normal_vector()
67 {
68 return {{Tensor<1, 1>{{-1}}, Tensor<1, 1>{{1}}}};
69 }
70
71 static constexpr dealii::ndarray<Tensor<1, 1>, 2, 0>
72 unit_tangential_vectors()
73 {
74 return {{{{}}, {{}}}};
75 }
76
77 static constexpr std::array<unsigned int, 2>
78 opposite_face()
79 {
80 return {{1, 0}};
81 }
82
83 static constexpr std::array<unsigned int, 2>
84 dx_to_deal()
85 {
86 return {{0, 1}};
87 }
88
89 static constexpr dealii::ndarray<unsigned int, 2, 1>
90 vertex_to_face()
91 {
92 return {{{{0}}, {{1}}}};
93 }
94 };
95
96 template <>
97 struct Initializers<2>
98 {
99 static constexpr std::array<unsigned int, 4>
100 ucd_to_deal()
101 {
102 return {{0, 1, 3, 2}};
103 }
104
105 static constexpr std::array<unsigned int, 4>
106 unit_normal_direction()
107 {
108 return {{0, 0, 1, 1}};
109 }
110
111 static constexpr std::array<int, 4>
112 unit_normal_orientation()
113 {
114 return {{-1, 1, -1, 1}};
115 }
116
117 static constexpr std::array<Tensor<1, 2>, 4>
118 unit_normal_vector()
119 {
120 return {{Tensor<1, 2>{{-1., 0.}},
121 Tensor<1, 2>{{1., 0.}},
122 Tensor<1, 2>{{0., -1.}},
123 Tensor<1, 2>{{0., 1.}}}};
124 }
125
126 static constexpr dealii::ndarray<Tensor<1, 2>, 4, 1>
127 unit_tangential_vectors()
128 {
129 return {{{{Tensor<1, 2>{{0, -1}}}},
130 {{Tensor<1, 2>{{0, 1}}}},
131 {{Tensor<1, 2>{{1, 0}}}},
132 {{Tensor<1, 2>{{-1, 0}}}}}};
133 }
134
135 static constexpr std::array<unsigned int, 4>
136 opposite_face()
137 {
138 return {{1, 0, 3, 2}};
139 }
140
141 static constexpr std::array<unsigned int, 4>
142 dx_to_deal()
143 {
144 return {{0, 2, 1, 3}};
145 }
146
147 static constexpr dealii::ndarray<unsigned int, 4, 2>
148 vertex_to_face()
149 {
150 return {{{{0, 2}}, {{1, 2}}, {{0, 3}}, {{1, 3}}}};
151 }
152 };
153
154 template <>
155 struct Initializers<3>
156 {
157 static constexpr std::array<unsigned int, 8>
158 ucd_to_deal()
159 {
160 return {{0, 4, 5, 1, 2, 6, 7, 3}};
161 }
162
163 static constexpr std::array<unsigned int, 6>
164 unit_normal_direction()
165 {
166 return {{0, 0, 1, 1, 2, 2}};
167 }
168
169 static constexpr std::array<int, 6>
170 unit_normal_orientation()
171 {
172 return {{-1, 1, -1, 1, -1, 1}};
173 }
174
175 static constexpr std::array<Tensor<1, 3>, 6>
176 unit_normal_vector()
177 {
178 return {{Tensor<1, 3>{{-1, 0, 0}},
179 Tensor<1, 3>{{1, 0, 0}},
180 Tensor<1, 3>{{0, -1, 0}},
181 Tensor<1, 3>{{0, 1, 0}},
182 Tensor<1, 3>{{0, 0, -1}},
183 Tensor<1, 3>{{0, 0, 1}}}};
184 }
185
186 static constexpr dealii::ndarray<Tensor<1, 3>, 6, 2>
187 unit_tangential_vectors()
188 {
189 return {{{{Tensor<1, 3>{{0, -1, 0}}, Tensor<1, 3>{{0, 0, 1}}}},
190 {{Tensor<1, 3>{{0, 1, 0}}, Tensor<1, 3>{{0, 0, 1}}}},
191 {{Tensor<1, 3>{{0, 0, -1}}, Tensor<1, 3>{{1, 0, 0}}}},
192 {{Tensor<1, 3>{{0, 0, 1}}, Tensor<1, 3>{{1, 0, 0}}}},
193 {{Tensor<1, 3>{{-1, 0, 0}}, Tensor<1, 3>{{0, 1, 0}}}},
194 {{Tensor<1, 3>{{1, 0, 0}}, Tensor<1, 3>{{0, 1, 0}}}}}};
195 }
196
197 static constexpr std::array<unsigned int, 6>
198 opposite_face()
199 {
200 return {{1, 0, 3, 2, 5, 4}};
201 }
202
203 static constexpr std::array<unsigned int, 8>
204 dx_to_deal()
205 {
206 return {{0, 4, 2, 6, 1, 5, 3, 7}};
207 }
208
209 static constexpr dealii::ndarray<unsigned int, 8, 3>
210 vertex_to_face()
211 {
212 return {{{{0, 2, 4}},
213 {{1, 2, 4}},
214 {{0, 3, 4}},
215 {{1, 3, 4}},
216 {{0, 2, 5}},
217 {{1, 2, 5}},
218 {{0, 3, 5}},
219 {{1, 3, 5}}}};
220 }
221 };
222
223 template <>
224 struct Initializers<4>
225 {
226 static constexpr std::array<unsigned int, 16>
227 ucd_to_deal()
228 {
229 return {{numbers::invalid_unsigned_int,
230 numbers::invalid_unsigned_int,
231 numbers::invalid_unsigned_int,
232 numbers::invalid_unsigned_int,
233 numbers::invalid_unsigned_int,
234 numbers::invalid_unsigned_int,
235 numbers::invalid_unsigned_int,
236 numbers::invalid_unsigned_int,
237 numbers::invalid_unsigned_int,
238 numbers::invalid_unsigned_int,
239 numbers::invalid_unsigned_int,
240 numbers::invalid_unsigned_int,
241 numbers::invalid_unsigned_int,
242 numbers::invalid_unsigned_int,
243 numbers::invalid_unsigned_int,
244 numbers::invalid_unsigned_int}};
245 }
246
247 static constexpr std::array<unsigned int, 8>
248 unit_normal_direction()
249 {
250 return {{0, 0, 1, 1, 2, 2, 3, 3}};
251 }
252
253 static constexpr std::array<int, 8>
254 unit_normal_orientation()
255 {
256 return {{-1, 1, -1, 1, -1, 1, -1, 1}};
257 }
258
259 static constexpr std::array<Tensor<1, 4>, 8>
260 unit_normal_vector()
261 {
262 return {{Tensor<1, 4>{{-1, 0, 0, 0}},
263 Tensor<1, 4>{{1, 0, 0, 0}},
264 Tensor<1, 4>{{0, -1, 0, 0}},
265 Tensor<1, 4>{{0, 1, 0, 0}},
266 Tensor<1, 4>{{0, 0, -1, 0}},
267 Tensor<1, 4>{{0, 0, 1, 0}},
268 Tensor<1, 4>{{0, 0, 0, -1}},
269 Tensor<1, 4>{{0, 0, 0, 1}}}};
270 }
271
272 static constexpr dealii::ndarray<Tensor<1, 4>, 8, 3>
273 unit_tangential_vectors()
274 {
275 return {{{{Tensor<1, 4>{{0, -1, 0, 0}},
276 Tensor<1, 4>{{0, 0, 1, 0}},
277 Tensor<1, 4>{{0, 0, 0, 1}}}},
278 {{Tensor<1, 4>{{0, 1, 0, 0}},
279 Tensor<1, 4>{{0, 0, 1, 0}},
280 Tensor<1, 4>{{0, 0, 0, 1}}}},
281 {{Tensor<1, 4>{{0, 0, -1, 0}},
282 Tensor<1, 4>{{0, 0, 0, 1}},
283 Tensor<1, 4>{{1, 0, 0, 0}}}},
284 {{Tensor<1, 4>{{0, 0, 1, 0}},
285 Tensor<1, 4>{{0, 0, 0, 1}},
286 Tensor<1, 4>{{1, 0, 0, 0}}}},
287 {{Tensor<1, 4>{{0, 0, 0, -1}},
288 Tensor<1, 4>{{1, 0, 0, 0}},
289 Tensor<1, 4>{{0, 1, 0, 0}}}},
290 {{Tensor<1, 4>{{0, 0, 0, 1}},
291 Tensor<1, 4>{{1, 0, 0, 0}},
292 Tensor<1, 4>{{0, 1, 0, 0}}}},
293 {{Tensor<1, 4>{{-1, 0, 0, 0}},
294 Tensor<1, 4>{{0, 1, 0, 0}},
295 Tensor<1, 4>{{0, 0, 1, 0}}}},
296 {{Tensor<1, 4>{{1, 0, 0, 0}},
297 Tensor<1, 4>{{0, 1, 0, 0}},
298 Tensor<1, 4>{{0, 0, 1, 0}}}}}};
299 }
300
301 static constexpr std::array<unsigned int, 8>
302 opposite_face()
303 {
304 return {{1, 0, 3, 2, 5, 4, 7, 6}};
305 }
306
307 static constexpr std::array<unsigned int, 16>
308 dx_to_deal()
309 {
310 return {{numbers::invalid_unsigned_int,
311 numbers::invalid_unsigned_int,
312 numbers::invalid_unsigned_int,
313 numbers::invalid_unsigned_int,
314 numbers::invalid_unsigned_int,
315 numbers::invalid_unsigned_int,
316 numbers::invalid_unsigned_int,
317 numbers::invalid_unsigned_int,
318 numbers::invalid_unsigned_int,
319 numbers::invalid_unsigned_int,
320 numbers::invalid_unsigned_int,
321 numbers::invalid_unsigned_int,
322 numbers::invalid_unsigned_int,
323 numbers::invalid_unsigned_int,
324 numbers::invalid_unsigned_int,
325 numbers::invalid_unsigned_int}};
326 }
327
328 static constexpr dealii::ndarray<unsigned int, 16, 4>
329 vertex_to_face()
330 {
331 return {{{{numbers::invalid_unsigned_int,
332 numbers::invalid_unsigned_int,
333 numbers::invalid_unsigned_int,
334 numbers::invalid_unsigned_int}},
335 {{numbers::invalid_unsigned_int,
336 numbers::invalid_unsigned_int,
337 numbers::invalid_unsigned_int,
338 numbers::invalid_unsigned_int}},
339 {{numbers::invalid_unsigned_int,
340 numbers::invalid_unsigned_int,
341 numbers::invalid_unsigned_int,
342 numbers::invalid_unsigned_int}},
343 {{numbers::invalid_unsigned_int,
344 numbers::invalid_unsigned_int,
345 numbers::invalid_unsigned_int,
346 numbers::invalid_unsigned_int}},
347 {{numbers::invalid_unsigned_int,
348 numbers::invalid_unsigned_int,
349 numbers::invalid_unsigned_int,
350 numbers::invalid_unsigned_int}},
351 {{numbers::invalid_unsigned_int,
352 numbers::invalid_unsigned_int,
353 numbers::invalid_unsigned_int,
354 numbers::invalid_unsigned_int}},
355 {{numbers::invalid_unsigned_int,
356 numbers::invalid_unsigned_int,
357 numbers::invalid_unsigned_int,
358 numbers::invalid_unsigned_int}},
359 {{numbers::invalid_unsigned_int,
360 numbers::invalid_unsigned_int,
361 numbers::invalid_unsigned_int,
362 numbers::invalid_unsigned_int}},
363 {{numbers::invalid_unsigned_int,
364 numbers::invalid_unsigned_int,
365 numbers::invalid_unsigned_int,
366 numbers::invalid_unsigned_int}},
367 {{numbers::invalid_unsigned_int,
368 numbers::invalid_unsigned_int,
369 numbers::invalid_unsigned_int,
370 numbers::invalid_unsigned_int}},
371 {{numbers::invalid_unsigned_int,
372 numbers::invalid_unsigned_int,
373 numbers::invalid_unsigned_int,
374 numbers::invalid_unsigned_int}},
375 {{numbers::invalid_unsigned_int,
376 numbers::invalid_unsigned_int,
377 numbers::invalid_unsigned_int,
378 numbers::invalid_unsigned_int}},
379 {{numbers::invalid_unsigned_int,
380 numbers::invalid_unsigned_int,
381 numbers::invalid_unsigned_int,
382 numbers::invalid_unsigned_int}},
383 {{numbers::invalid_unsigned_int,
384 numbers::invalid_unsigned_int,
385 numbers::invalid_unsigned_int,
386 numbers::invalid_unsigned_int}},
387 {{numbers::invalid_unsigned_int,
388 numbers::invalid_unsigned_int,
389 numbers::invalid_unsigned_int,
390 numbers::invalid_unsigned_int}},
391 {{numbers::invalid_unsigned_int,
392 numbers::invalid_unsigned_int,
393 numbers::invalid_unsigned_int,
394 numbers::invalid_unsigned_int}}}};
395 }
396 };
397 } // namespace GeometryInfoHelper
398 } // namespace internal
399 #endif // DOXYGEN
400
401
402 /**
403 * A class that can represent the kinds of objects a triangulation is made up
404 * of: vertices, lines, quads and hexes.
405 *
406 * The class is rather primitive: it only stores a single integer that
407 * represents the dimensionality of the object represented. In other words,
408 * this class is useful primarily as a way to pass around an object whose data
409 * type explains what it does (unlike just passing around an integer), and for
410 * providing symbolic names for these objects such as
411 * GeometryPrimitive::vertex instead of an integer zero.
412 *
413 * Since the ability to identify such objects with the integral dimension of
414 * the object represented, this class provides conversion operators to and
415 * from unsigned integers.
416 */
417 class GeometryPrimitive
418 {
419 public:
420 /**
421 * An enumeration providing symbolic names for the objects that can be
422 * represented by this class. The numeric values of these symbolic names
423 * equal the geometric dimensionality of the represented objects to make
424 * conversion from and to integer variables simpler.
425 */
426 enum Object
427 {
428 /**
429 * A vertex.
430 */
431 vertex = 0,
432 /**
433 * A line.
434 */
435 line = 1,
436 /**
437 * A quadrilateral.
438 */
439 quad = 2,
440 /**
441 * A hexahedron.
442 */
443 hex = 3
444 };
445
446 /**
447 * Constructor. Initialize the object with the given argument representing a
448 * vertex, line, etc.
449 */
450 GeometryPrimitive(const Object object);
451
452 /**
453 * Constructor. Initialize the object with an integer that should represent
454 * the dimensionality of the geometric object in question. This will usually
455 * be a number between zero (a vertex) and three (a hexahedron).
456 */
457 GeometryPrimitive(const unsigned int object_dimension);
458
459 /**
460 * Return the integral dimension of the object currently represented, i.e.
461 * zero for a vertex, one for a line, etc.
462 */
463 operator unsigned int() const;
464
465 private:
466 /**
467 * The object currently represented.
468 */
469 Object object;
470 };
471
472
473
474 /**
475 * A class that provides possible choices for isotropic and anisotropic
476 * refinement flags in the current space dimension.
477 *
478 * This general template is unused except in some weird template constructs.
479 * Actual use is made, however, of the specializations
480 * <code>RefinementPossibilities@<1@></code>,
481 * <code>RefinementPossibilities@<2@></code>, and
482 * <code>RefinementPossibilities@<3@></code>.
483 */
484 template <int dim>
485 struct RefinementPossibilities
486 {
487 /**
488 * Possible values for refinement cases in the current dimension.
489 *
490 * Note the construction of the values: the lowest bit describes a cut of
491 * the x-axis, the second to lowest bit corresponds to a cut of the y-axis
492 * and the third to lowest bit corresponds to a cut of the z-axis. Thus, the
493 * following relations hold (among others):
494 *
495 * @code
496 * cut_xy == cut_x | cut_y
497 * cut_xyz == cut_xy | cut_xz
498 * cut_x == cut_xy & cut_xz
499 * @endcode
500 *
501 * Only those cuts that are reasonable in a given space dimension are
502 * offered, of course.
503 *
504 * In addition, the tag <code>isotropic_refinement</code> denotes isotropic
505 * refinement in the space dimension selected by the template argument of
506 * this class.
507 *
508 * If you choose anisotropic refinement, for example by passing as argument
509 * to CellIterator::set_refine_flag()
510 * one of the flags RefinementCase::cut_x, RefinementCase::cut_y,
511 * RefinementCase::cut_z, or a combination of these, then keep in mind
512 * that refining in x-, y-, or z-direction happens with regard to the
513 * <em>local</em> coordinate system of the cell. In other words, these
514 * flags determine which edges and faces of the cell will be cut into new
515 * edges and faces. On the other hand, this process is independent of
516 * how the cell is oriented within the <em>global</em> coordinate system,
517 * and you should not assume any particular orientation of the cell's
518 * local coordinate system within the global coordinate system of the
519 * space it lives in.
520 */
521 enum Possibilities : std::uint8_t
522 {
523 /**
524 * Do not perform refinement.
525 */
526 no_refinement = 0,
527
528 /**
529 * Perform isotropic refinement. This implies
530 * refining in all coordinate directions. For the
531 * current general template class -- which is never used
532 * because there are specializations for the 1d, 2d, and 3d
533 * cases --, we simply set this number to a value that has
534 * all bits set. The specializations in
535 * RefinementPossibilities<1>, RefinementPossibilities<2>,
536 * and RefinementPossibilities<3> set the corresponding `enum` element
537 * to more reasonable values.
538 */
539 isotropic_refinement = 0xFF
540 };
541 };
542
543
544
545 /**
546 * A class that provides possible choices for isotropic and anisotropic
547 * refinement flags in the current space dimension.
548 *
549 * This specialization is used for <code>dim=1</code>, where it offers
550 * refinement in x-direction.
551 */
552 template <>
553 struct RefinementPossibilities<1>
554 {
555 /**
556 * Possible values for refinement cases in the current dimension.
557 *
558 * Note the construction of the values: the lowest bit describes a cut of
559 * the x-axis, the second to lowest bit corresponds to a cut of the y-axis
560 * and the third to lowest bit corresponds to a cut of the z-axis. Thus, the
561 * following relations hold (among others):
562 *
563 * @code
564 * cut_xy == cut_x | cut_y
565 * cut_xyz == cut_xy | cut_xz
566 * cut_x == cut_xy & cut_xz
567 * @endcode
568 *
569 * Only those cuts that are reasonable in a given space dimension are
570 * offered, of course.
571 *
572 * In addition, the tag <code>isotropic_refinement</code> denotes isotropic
573 * refinement in the space dimension selected by the template argument of
574 * this class.
575 *
576 * If you choose anisotropic refinement, for example by passing as argument
577 * to CellIterator::set_refine_flag()
578 * one of the flags RefinementCase::cut_x, RefinementCase::cut_y,
579 * RefinementCase::cut_z, or a combination of these, then keep in mind
580 * that refining in x-, y-, or z-direction happens with regard to the
581 * <em>local</em> coordinate system of the cell. In other words, these
582 * flags determine which edges and faces of the cell will be cut into new
583 * edges and faces. On the other hand, this process is independent of
584 * how the cell is oriented within the <em>global</em> coordinate system,
585 * and you should not assume any particular orientation of the cell's
586 * local coordinate system within the global coordinate system of the
587 * space it lives in.
588 */
589 enum Possibilities : std::uint8_t
590 {
591 /**
592 * Do not refine.
593 */
594 no_refinement = 0,
595 /**
596 * Perform a cut in the x-direction.
597 */
598 cut_x = 1,
599 /**
600 * Perform isotropic refinement.
601 */
602 isotropic_refinement = cut_x
603 };
604 };
605
606
607
608 /**
609 * A class that provides possible choices for isotropic and anisotropic
610 * refinement flags in the current space dimension.
611 *
612 * This specialization is used for <code>dim=2</code>, where it offers
613 * refinement in x- and y-direction separately, as well as isotropic
614 * refinement in both directions at the same time.
615 */
616 template <>
617 struct RefinementPossibilities<2>
618 {
619 /**
620 * Possible values for refinement cases in the current dimension.
621 *
622 * Note the construction of the values: the lowest bit describes a cut of
623 * the x-axis, the second to lowest bit corresponds to a cut of the y-axis
624 * and the third to lowest bit corresponds to a cut of the z-axis. Thus, the
625 * following relations hold (among others):
626 *
627 * @code
628 * cut_xy == cut_x | cut_y
629 * cut_xyz == cut_xy | cut_xz
630 * cut_x == cut_xy & cut_xz
631 * @endcode
632 *
633 * Only those cuts that are reasonable in a given space dimension are
634 * offered, of course.
635 *
636 * In addition, the tag <code>isotropic_refinement</code> denotes isotropic
637 * refinement in the space dimension selected by the template argument of
638 * this class.
639 *
640 * If you choose anisotropic refinement, for example by passing as argument
641 * to CellIterator::set_refine_flag()
642 * one of the flags RefinementCase::cut_x, RefinementCase::cut_y,
643 * RefinementCase::cut_z, or a combination of these, then keep in mind
644 * that refining in x-, y-, or z-direction happens with regard to the
645 * <em>local</em> coordinate system of the cell. In other words, these
646 * flags determine which edges and faces of the cell will be cut into new
647 * edges and faces. On the other hand, this process is independent of
648 * how the cell is oriented within the <em>global</em> coordinate system,
649 * and you should not assume any particular orientation of the cell's
650 * local coordinate system within the global coordinate system of the
651 * space it lives in.
652 */
653 enum Possibilities : std::uint8_t
654 {
655 /**
656 * Do not refine.
657 */
658 no_refinement = 0,
659 /**
660 * Perform a cut in the x-direction.
661 */
662 cut_x = 1,
663 /**
664 * Perform a cut in the y-direction.
665 */
666 cut_y = 2,
667 /**
668 * Perform cuts in the x- and y-directions.
669 */
670 cut_xy = cut_x | cut_y,
671
672 /**
673 * Perform isotropic refinement.
674 */
675 isotropic_refinement = cut_xy
676 };
677 };
678
679
680
681 /**
682 * A class that provides possible choices for isotropic and anisotropic
683 * refinement flags in the current space dimension.
684 *
685 * This specialization is used for <code>dim=3</code>, where it offers
686 * refinement in x-, y- and z-direction separately, as well as combinations of
687 * these and isotropic refinement in all directions at the same time.
688 */
689 template <>
690 struct RefinementPossibilities<3>
691 {
692 /**
693 * Possible values for refinement cases in the current dimension.
694 *
695 * Note the construction of the values: the lowest bit describes a cut of
696 * the x-axis, the second to lowest bit corresponds to a cut of the y-axis
697 * and the third to lowest bit corresponds to a cut of the z-axis. Thus, the
698 * following relations hold (among others):
699 *
700 * @code
701 * cut_xy == cut_x | cut_y
702 * cut_xyz == cut_xy | cut_xz
703 * cut_x == cut_xy & cut_xz
704 * @endcode
705 *
706 * Only those cuts that are reasonable in a given space dimension are
707 * offered, of course.
708 *
709 * In addition, the tag <code>isotropic_refinement</code> denotes isotropic
710 * refinement in the space dimension selected by the template argument of
711 * this class.
712 *
713 * If you choose anisotropic refinement, for example by passing as argument
714 * to CellIterator::set_refine_flag()
715 * one of the flags RefinementCase::cut_x, RefinementCase::cut_y,
716 * RefinementCase::cut_z, or a combination of these, then keep in mind
717 * that refining in x-, y-, or z-direction happens with regard to the
718 * <em>local</em> coordinate system of the cell. In other words, these
719 * flags determine which edges and faces of the cell will be cut into new
720 * edges and faces. On the other hand, this process is independent of
721 * how the cell is oriented within the <em>global</em> coordinate system,
722 * and you should not assume any particular orientation of the cell's
723 * local coordinate system within the global coordinate system of the
724 * space it lives in.
725 */
726 enum Possibilities : std::uint8_t
727 {
728 /**
729 * Do not refine.
730 */
731 no_refinement = 0,
732 /**
733 * Perform a cut in the x-direction.
734 */
735 cut_x = 1,
736 /**
737 * Perform a cut in the y-direction.
738 */
739 cut_y = 2,
740 /**
741 * Perform a cut in the x and y-directions.
742 */
743 cut_xy = cut_x | cut_y,
744 /**
745 * Perform a cut in the z-direction.
746 */
747 cut_z = 4,
748 /**
749 * Perform a cuts in the x- and y-directions.
750 */
751 cut_xz = cut_x | cut_z,
752 /**
753 * Perform a cuts in the x- and y-directions.
754 */
755 cut_yz = cut_y | cut_z,
756 /**
757 * Perform a cuts in the x-, y-, and z-directions.
758 */
759 cut_xyz = cut_x | cut_y | cut_z,
760
761 /**
762 * Perform isotropic refinement.
763 */
764 isotropic_refinement = cut_xyz
765 };
766 };
767
768
769
770 /**
771 * A class storing the possible anisotropic and isotropic refinement cases of
772 * an object with <code>dim</code> dimensions (for example, for a line
773 * <code>dim=1</code> in whatever space dimension we are, for a quad
774 * <code>dim=2</code>, etc.). Possible values of this class are the ones
775 * listed in the enumeration declared within the base class; see there for
776 * more information.
777 */
778 template <int dim>
779 class RefinementCase : public RefinementPossibilities<dim>
780 {
781 public:
782 /**
783 * A variable indicating the number of possible refinement cases.
784 */
785 static constexpr unsigned int n_refinement_cases = (1 << dim);
786
787 /**
788 * Default constructor. Initialize the refinement case with no_refinement.
789 */
790 RefinementCase();
791
792 /**
793 * Constructor. Take and store a value indicating a particular refinement
794 * from the list of possible refinements specified in the base class.
795 */
796 RefinementCase(
797 const typename RefinementPossibilities<dim>::Possibilities refinement_case);
798
799 /**
800 * Constructor. Take and store a value indicating a particular refinement as
801 * a bit field. To avoid implicit conversions to and from integral values,
802 * this constructor is marked as explicit.
803 */
804 explicit RefinementCase(const std::uint8_t refinement_case);
805
806 /**
807 * Return the numeric value stored by this class. While the presence of this
808 * operator might seem dangerous, it is useful in cases where one would like
809 * to have code like <tt>switch (refinement_flag)... case
810 * RefinementCase<dim>::cut_x: ... </tt>, which can be written as
811 * <code>switch (static_cast@<std::uint8_t@>(refinement_flag)</code>.
812 * Another application is to use an object of the current type as an index
813 * into an array; however, this use is deprecated as it assumes a certain
814 * mapping from the symbolic flags defined in the RefinementPossibilities
815 * base class to actual numerical values (the array indices).
816 */
817 DEAL_II_HOST_DEVICE
818 operator std::uint8_t() const;
819
820 /**
821 * Return the union of the refinement flags represented by the current
822 * object and the one given as argument.
823 */
824 RefinementCase
825 operator|(const RefinementCase &r) const;
826
827 /**
828 * Return the intersection of the refinement flags represented by the
829 * current object and the one given as argument.
830 */
831 RefinementCase
832 operator&(const RefinementCase &r) const;
833
834 /**
835 * Return the negation of the refinement flags represented by the current
836 * object. For example, in 2d, if the current object holds the flag
837 * <code>cut_x</code>, then the returned value will be <code>cut_y</code>;
838 * if the current value is <code>isotropic_refinement</code> then the result
839 * will be <code>no_refinement</code>; etc.
840 */
841 RefinementCase
842 operator~() const;
843
844
845 /**
846 * Return the flag that corresponds to cutting a cell along the axis given
847 * as argument. For example, if <code>i=0</code> then the returned value is
848 * <tt>RefinementPossibilities<dim>::cut_x</tt>.
849 */
850 static RefinementCase
851 cut_axis(const unsigned int i);
852
853 /**
854 * Return an array that lists all possible refinement cases possible in
855 * the given space dimension. For example, for `dim==1`, it returns an
856 * array that only contains `{ RefinementCase::no_refinement,
857 * RefinementCase::cut_x }`. In `dim==2`, it returns
858 * `{ RefinementCase::no_refinement, RefinementCase::cut_x,
859 * RefinementCase::cut_y, RefinementCase::cut_xy }`.
860 */
861 static std::array<RefinementCase<dim>, n_refinement_cases>
862 all_refinement_cases();
863
864 /**
865 * Return the amount of memory occupied by an object of this type.
866 */
867 static std::size_t
868 memory_consumption();
869
870 /**
871 * Read or write the data of this object to or from a stream for the purpose
872 * of serialization using the [BOOST serialization
873 * library](https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/index.html).
874 */
875 template <class Archive>
876 void
877 serialize(Archive &ar, const unsigned int version);
878
879 /**
880 * Exception.
881 */
882 DeclException1(
883 ExcInvalidRefinementCase,
884 int,
885 << "The refinement flags given (" << arg1
886 << ") contain set bits that do not "
887 << "make sense for the space dimension of the object to which they are applied.");
888
889 private:
890 /**
891 * Store the refinement case as a bit field with as many bits as are
892 * necessary in any given dimension.
893 */
894 std::uint8_t value : (dim > 0 ? dim : 1);
895 };
896
897
898
899 namespace internal
900 {
901 /**
902 * A class that provides all possible situations a face (in the current
903 * space dimension @p dim) might be subdivided into subfaces. For
904 * <code>dim=1</code> and <code>dim=2</code> they correspond to the cases
905 * given in <code>RefinementPossibilities@<dim-1@></code>. However,
906 * <code>SubfacePossibilities@<3@></code> includes the refinement cases of
907 * <code>RefinementPossibilities@<2@></code>, but additionally some subface
908 * possibilities a face might be subdivided into which occur through
909 * repeated anisotropic refinement steps performed on one of two neighboring
910 * cells.
911 *
912 * This general template is unused except in some weird template constructs.
913 * Actual is made, however, of the specializations
914 * <code>SubfacePossibilities@<1@></code>,
915 * <code>SubfacePossibilities@<2@></code> and
916 * <code>SubfacePossibilities@<3@></code>.
917 */
918 template <int dim>
919 struct SubfacePossibilities
920 {
921 /**
922 * Possible cases of faces being subdivided into subface.
923 */
924 enum Possibilities
925 {
926 /**
927 * Do not refine.
928 */
929 case_none = 0,
930
931 /**
932 * Refine isotropically.
933 */
934 case_isotropic = static_cast<std::uint8_t>(-1)
935 };
936 };
937
938
939 /**
940 * A class that provides all possible situations a face (in the current
941 * space dimension @p dim) might be subdivided into subfaces.
942 *
943 * For <code>dim=0</code> we provide a dummy implementation only.
944 */
945 template <>
946 struct SubfacePossibilities<0>
947 {
948 /**
949 * Possible cases of faces being subdivided into subface.
950 *
951 * Dummy implementation.
952 */
953 enum Possibilities
954 {
955 /**
956 * Do not refine.
957 */
958 case_none = 0,
959
960 /**
961 * Refine isotropically.
962 */
963 case_isotropic = case_none
964 };
965 };
966
967
968
969 /**
970 * A class that provides all possible situations a face (in the current
971 * space dimension @p dim) might be subdivided into subfaces.
972 *
973 * For <code>dim=1</code> there are no faces. Thereby, there are no subface
974 * possibilities.
975 */
976 template <>
977 struct SubfacePossibilities<1>
978 {
979 /**
980 * Possible cases of faces being subdivided into subface.
981 *
982 * In 1d there are no faces, thus no subface possibilities.
983 */
984 enum Possibilities
985 {
986 /**
987 * Do not refine.
988 */
989 case_none = 0,
990
991 /**
992 * Refine isotropically.
993 */
994 case_isotropic = case_none
995 };
996 };
997
998
999
1000 /**
1001 * A class that provides all possible situations a face (in the current
1002 * space dimension @p dim) might be subdivided into subfaces.
1003 *
1004 * This specialization is used for <code>dim=2</code>, where it offers the
1005 * following possibilities: a face (line) being refined
1006 * (<code>case_x</code>) or not refined (<code>case_no</code>).
1007 */
1008 template <>
1009 struct SubfacePossibilities<2>
1010 {
1011 /**
1012 * Possible cases of faces being subdivided into subface.
1013 *
1014 * In 2d there are following possibilities: a face (line) being refined *
1015 * (<code>case_x</code>) or not refined (<code>case_no</code>).
1016 */
1017 enum Possibilities
1018 {
1019 /**
1020 * Do not refine.
1021 */
1022 case_none = 0,
1023 /**
1024 * Cut in the x-direction.
1025 */
1026 case_x = 1,
1027 /**
1028 * Refine isotropically.
1029 */
1030 case_isotropic = case_x
1031 };
1032 };
1033
1034
1035
1036 /**
1037 * A class that provides all possible situations a face (in the current
1038 * space dimension @p dim) might be subdivided into subfaces.
1039 *
1040 * This specialization is used for dim=3, where it offers following
1041 * possibilities: a face (quad) being refined in x- or y-direction (in the
1042 * face-intern coordinate system) separately, (<code>case_x</code> or
1043 * (<code>case_y</code>), and in both directions (<code>case_x</code> which
1044 * corresponds to (<code>case_isotropic</code>). Additionally, it offers the
1045 * possibilities a face can have through repeated anisotropic refinement
1046 * steps performed on one of the two neighboring cells. It might be
1047 * possible for example, that a face (quad) is refined with
1048 * <code>cut_x</code> and afterwards the left child is again refined with
1049 * <code>cut_y</code>, so that there are three active subfaces. Note,
1050 * however, that only refinement cases are allowed such that each line on a
1051 * face between two hexes has not more than one hanging node. Furthermore,
1052 * it is not allowed that two neighboring hexes are refined such that one of
1053 * the hexes refines the common face with <code>cut_x</code> and the other
1054 * hex refines that face with <code>cut_y</code>. In fact,
1055 * Triangulation::prepare_coarsening_and_refinement takes care of this
1056 * situation and ensures that each face of a refined cell is completely
1057 * contained in a single face of neighboring cells.
1058 *
1059 * The following drawings explain the SubfacePossibilities and give the
1060 * corresponding subface numbers:
1061 * @code
1062 *
1063 * *-------*
1064 * | |
1065 * | 0 | case_none
1066 * | |
1067 * *-------*
1068 *
1069 * *---*---*
1070 * | | |
1071 * | 0 | 1 | case_x
1072 * | | |
1073 * *---*---*
1074 *
1075 * *---*---*
1076 * | 1 | |
1077 * *---* 2 | case_x1y
1078 * | 0 | |
1079 * *---*---*
1080 *
1081 * *---*---*
1082 * | | 2 |
1083 * | 0 *---* case_x2y
1084 * | | 1 |
1085 * *---*---*
1086 *
1087 * *---*---*
1088 * | 1 | 3 |
1089 * *---*---* case_x1y2y (successive refinement: first cut_x, then cut_y for both children)
1090 * | 0 | 2 |
1091 * *---*---*
1092 *
1093 * *-------*
1094 * | 1 |
1095 * *-------* case_y
1096 * | 0 |
1097 * *-------*
1098 *
1099 * *-------*
1100 * | 2 |
1101 * *---*---* case_y1x
1102 * | 0 | 1 |
1103 * *---*---*
1104 *
1105 * *---*---*
1106 * | 1 | 2 |
1107 * *---*---* case_y2x
1108 * | 0 |
1109 * *-------*
1110 *
1111 * *---*---*
1112 * | 2 | 3 |
1113 * *---*---* case_y1x2x (successive refinement: first cut_y, then cut_x for both children)
1114 * | 0 | 1 |
1115 * *---+---*
1116 *
1117 * *---*---*
1118 * | 2 | 3 |
1119 * *---*---* case_xy (one isotropic refinement step)
1120 * | 0 | 1 |
1121 * *---*---*
1122 *
1123 * @endcode
1124 */
1125 template <>
1126 struct SubfacePossibilities<3>
1127 {
1128 /**
1129 * Possible cases of faces being subdivided into subface.
1130 *
1131 * See documentation to the SubfacePossibilities<3> for more details on
1132 * the subface possibilities.
1133 */
1134 enum Possibilities
1135 {
1136 case_none = 0,
1137 case_x = 1,
1138 case_x1y = 2,
1139 case_x2y = 3,
1140 case_x1y2y = 4,
1141 case_y = 5,
1142 case_y1x = 6,
1143 case_y2x = 7,
1144 case_y1x2x = 8,
1145 case_xy = 9,
1146
1147 case_isotropic = case_xy
1148 };
1149 };
1150
1151
1152
1153 /**
1154 * A class that provides all possible cases a face (in the current space
1155 * dimension @p dim) might be subdivided into subfaces.
1156 */
1157 template <int dim>
1158 class SubfaceCase : public SubfacePossibilities<dim>
1159 {
1160 public:
1161 /**
1162 * Constructor. Take and store a value indicating a particular subface
1163 * possibility in the list of possible situations specified in the base
1164 * class.
1165 */
1166 SubfaceCase(const typename SubfacePossibilities<dim>::Possibilities
1167 subface_possibility);
1168
1169 /**
1170 * Return the numeric value stored by this class. While the presence of
1171 * this operator might seem dangerous, it is useful in cases where one
1172 * would like to have code like <code>switch (subface_case)... case
1173 * SubfaceCase::case_x: ... </code>, which can be written as <code>switch
1174 * (static_cast@<std::uint8_t@>(subface_case)</code>. Another application
1175 * is to use an object of the current type as an index into an array;
1176 * however, this use is deprecated as it assumes a certain mapping from
1177 * the symbolic flags defined in the SubfacePossibilities base class to
1178 * actual numerical values (the array indices).
1179 */
1180 operator std::uint8_t() const;
1181
1182 /**
1183 * Return the amount of memory occupied by an object of this type.
1184 */
1185 static constexpr std::size_t
1186 memory_consumption();
1187
1188 /**
1189 * Exception.
1190 */
1191 DeclException1(
1192 ExcInvalidSubfaceCase,
1193 int,
1194 << "The subface case given (" << arg1 << ") does not make sense "
1195 << "for the space dimension of the object to which they are applied.");
1196
1197 private:
1198 /**
1199 * Store the refinement case as a bit field with as many bits as are
1200 * necessary in any given dimension.
1201 */
1202 std::uint8_t value : (dim == 3 ? 4 : 1);
1203 };
1204
1205 } // namespace internal
1206
1207
1208
1209 template <int dim>
1210 struct GeometryInfo;
1211
1212
1213
1214 /**
1215 * This class provides a description of zero-dimensional cells. It has been
1216 * superseded by the ReferenceCell class -- see there for more information.
1217 *
1218 * Topological description of zero dimensional cells, i.e. points. This class
1219 * might not look too useful but often is if in a certain dimension we would
1220 * like to enquire information about objects with dimension one lower than the
1221 * present, e.g. about faces.
1222 *
1223 * This class contains as static members information on vertices and faces of
1224 * a @p dim-dimensional grid cell. The interface is the same for all
1225 * dimensions. If a value is of no use in a low dimensional cell, it is
1226 * (correctly) set to zero, e.g. #max_children_per_face in 1d.
1227 *
1228 * This information should always replace hard-coded numbers of vertices,
1229 * neighbors and so on, since it can be used dimension independently.
1230 *
1231 * @ingroup grid geomprimitives
1232 */
1233 template <>
1234 struct GeometryInfo<0>
1235 {
1236 /**
1237 * Maximum number of children of a cell, i.e. the number of children of an
1238 * isotropically refined cell.
1239 *
1240 * If a cell is refined anisotropically, the actual number of children may
1241 * be less than the value given here.
1242 */
1243 static constexpr unsigned int max_children_per_cell = 1;
1244
1245 /**
1246 * Number of faces a cell has.
1247 */
1248 static constexpr unsigned int faces_per_cell = 0;
1249
1250 /**
1251 * Return an object that can be thought of as an array containing all
1252 * indices from zero to `faces_per_cell`. This allows to write code
1253 * using range-based for loops of the following kind:
1254 * @code
1255 * for (auto &cell : triangulation.active_cell_iterators())
1256 * for (auto face_index : GeometryInfo<dim>::face_indices())
1257 * if (cell->face(face_index)->at_boundary())
1258 * ... do something ...
1259 * @endcode
1260 * Here, we are looping over all faces of all cells, with `face_index`
1261 * taking on all valid indices.
1262 *
1263 * Of course, since this class is for the case `dim==0`, the
1264 * returned object is actually an empty array.
1265 */
1266 static std::array<unsigned int, 0>
1267 face_indices();
1268
1269 /**
1270 * Maximum number of children of a refined face, i.e. the number of children
1271 * of an isotropically refined face.
1272 *
1273 * If a cell is refined anisotropically, the actual number of children may
1274 * be less than the value given here.
1275 */
1276 static constexpr unsigned int max_children_per_face = 0;
1277
1278 /**
1279 * Return the number of children of a cell (or face) refined with
1280 * <tt>ref_case</tt>. Since we are concerned here with points, the number of
1281 * children is equal to one.
1282 */
1283 static unsigned int
1284 n_children(const RefinementCase<0> &refinement_case);
1285
1286 /**
1287 * Number of vertices a cell has.
1288 */
1289 static constexpr unsigned int vertices_per_cell = 1;
1290
1291 /**
1292 * Return an object that can be thought of as an array containing all
1293 * indices from zero to `vertices_per_cell`. This allows to write code
1294 * using range-based for loops of the following kind:
1295 * @code
1296 * for (auto &cell : triangulation.active_cell_iterators())
1297 * for (auto vertex_index : GeometryInfo<dim>::vertex_indices())
1298 * if (cell->vertex(vertex_index) satisfies some condition)
1299 * ... do something ...
1300 * @endcode
1301 * Here, we are looping over all vertices of all cells, with `vertex_index`
1302 * taking on all valid indices.
1303 *
1304 * Of course, since this class is for the case `dim==0`, the
1305 * returned object is a array with just one entry: zero. That's
1306 * because an of dimension zero is really just a single point,
1307 * corresponding to a vertex itself.
1308 */
1309 static std::array<unsigned int, vertices_per_cell>
1310 vertex_indices();
1311
1312 /**
1313 * Map face vertex number to cell vertex number, i.e. give the cell vertex
1314 * number of the <tt>vertex</tt>th vertex of face <tt>face</tt>, e.g.
1315 * <tt>GeometryInfo<2>::face_to_cell_vertices(3,0)=2</tt>, see the image
1316 * under point N4 in the 2d section of this class's documentation.
1317 *
1318 * Through the <tt>face_orientation</tt>, <tt>face_flip</tt> and
1319 * <tt>face_rotation</tt> arguments this function handles faces oriented in
1320 * the standard and non-standard orientation. <tt>face_orientation</tt>
1321 * defaults to <tt>true</tt>, <tt>face_flip</tt> and <tt>face_rotation</tt>
1322 * default to <tt>false</tt> (standard orientation). In 2d only
1323 * <tt>face_orientation</tt> is considered. See this
1324 * @ref GlossCombinedOrientation "glossary"
1325 * article for more information.
1326 *
1327 * As the children of a cell are ordered according to the vertices of the
1328 * cell, this call is passed down to the child_cell_on_face() function.
1329 * Hence this function is simply a wrapper of child_cell_on_face() giving it
1330 * a suggestive name.
1331 *
1332 * Of course, since this class is for the case `dim==0`, this function
1333 * is not implemented.
1334 */
1335 static unsigned int
1336 face_to_cell_vertices(const unsigned int face,
1337 const unsigned int vertex,
1338 const bool face_orientation = true,
1339 const bool face_flip = false,
1340 const bool face_rotation = false);
1341
1342 /**
1343 * Map face line number to cell line number, i.e. give the cell line number
1344 * of the <tt>line</tt>th line of face <tt>face</tt>, e.g.
1345 * <tt>GeometryInfo<3>::face_to_cell_lines(5,0)=4</tt>.
1346 *
1347 * Through the <tt>face_orientation</tt>, <tt>face_flip</tt> and
1348 * <tt>face_rotation</tt> arguments this function handles faces oriented in
1349 * the standard and non-standard orientation. <tt>face_orientation</tt>
1350 * defaults to <tt>true</tt>, <tt>face_flip</tt> and <tt>face_rotation</tt>
1351 * default to <tt>false</tt> (standard orientation) and has no effect in 2d.
1352 *
1353 * Of course, since this class is for the case `dim==0`, this function
1354 * is not implemented.
1355 */
1356 static unsigned int
1357 face_to_cell_lines(const unsigned int face,
1358 const unsigned int line,
1359 const bool face_orientation = true,
1360 const bool face_flip = false,
1361 const bool face_rotation = false);
1362
1363 /**
1364 * Number of vertices each face has. Since this is not useful in one
1365 * dimension, we provide a useless number (in the hope that a compiler may
1366 * warn when it sees constructs like <tt>for (i=0; i<vertices_per_face;
1367 * ++i)</tt>, at least if @p i is an <tt>unsigned int</tt>.
1368 */
1369 static constexpr unsigned int vertices_per_face = 0;
1370
1371 /**
1372 * Number of lines each face has.
1373 */
1374 static constexpr unsigned int lines_per_face = 0;
1375
1376 /**
1377 * Number of quads on each face.
1378 */
1379 static constexpr unsigned int quads_per_face = 0;
1380
1381 /**
1382 * Number of lines of a cell.
1383 */
1384 static constexpr unsigned int lines_per_cell = 0;
1385
1386 /**
1387 * Number of quadrilaterals of a cell.
1388 */
1389 static constexpr unsigned int quads_per_cell = 0;
1390
1391 /**
1392 * Number of hexahedra of a cell.
1393 */
1394 static constexpr unsigned int hexes_per_cell = 0;
1395
1396 /**
1397 * Rearrange vertices for UCD output. For a cell being written in UCD
1398 * format, each entry in this field contains the number of a vertex in
1399 * <tt>deal.II</tt> that corresponds to the UCD numbering at this location.
1400 *
1401 * Typical example: write a cell and arrange the vertices, such that UCD
1402 * understands them.
1403 *
1404 * @code
1405 * for (i=0; i< n_vertices; ++i)
1406 * out << cell->vertex(ucd_to_deal[i]);
1407 * @endcode
1408 *
1409 * As the vertex numbering in deal.II versions <= 5.1 happened to coincide
1410 * with the UCD numbering, this field can also be used like a
1411 * old_to_lexicographic mapping.
1412 */
1413 static const std::array<unsigned int, vertices_per_cell> ucd_to_deal;
1414
1415 /**
1416 * Rearrange vertices for OpenDX output. For a cell being written in OpenDX
1417 * format, each entry in this field contains the number of a vertex in
1418 * <tt>deal.II</tt> that corresponds to the DX numbering at this location.
1419 *
1420 * Typical example: write a cell and arrange the vertices, such that OpenDX
1421 * understands them.
1422 *
1423 * @code
1424 * for (i=0; i< n_vertices; ++i)
1425 * out << cell->vertex(dx_to_deal[i]);
1426 * @endcode
1427 */
1428 static const std::array<unsigned int, vertices_per_cell> dx_to_deal;
1429 };
1430
1431
1432
1433 /**
1434 * This class provides dimension independent information to all topological
1435 * structures that make up the unit, or
1436 * @ref GlossReferenceCell "reference cell".
1437 * That said, this class only describes information about hypercube reference
1438 * cells (i.e., lines, quadrilaterals, or hexahedra), which historically
1439 * were the only kinds of cells supported by deal.II. This is no longer the
1440 * case today, and consequently this class has been
1441 * superseded by the ReferenceCell class -- see there for more information.
1442 * The rest of this class's documentation is therefore partly historical.
1443 *
1444 *
1445 * It is the one central point in the library where information about the
1446 * numbering of vertices, lines, or faces of the reference cell is collected.
1447 * Consequently, the information of this class is used extensively in the
1448 * geometric description of Triangulation objects, as well as in various other
1449 * parts of the code. In particular, it also serves as the focus of writing
1450 * code in a dimension independent way; for example, instead of writing a loop
1451 * over vertices 0<=v<4 in 2d, one would write it as
1452 * 0<=v<GeometryInfo<dim>::vertices_per_cell, thus allowing the code to work
1453 * in 3d as well without changes.
1454 *
1455 * The most frequently used parts of the class are its static members like
1456 * vertices_per_cell, faces_per_cell, etc. However, the class also offers
1457 * information about more abstract questions like the orientation of faces,
1458 * etc. The following documentation gives a textual description of many of
1459 * these concepts.
1460 *
1461 *
1462 * <h3>Implementation conventions for two spatial dimensions</h3>
1463 *
1464 * From version 5.2 onwards deal.II is based on a numbering scheme that uses a
1465 * lexicographic ordering (with x running fastest) wherever possible, hence
1466 * trying to adopt a kind of 'canonical' ordering.
1467 *
1468 * The ordering of vertices and faces (lines) in 2d is defined by
1469 *
1470 * - Vertices are numbered in lexicographic ordering
1471 *
1472 * - Faces (lines in 2d): first the two faces with normals in x- and then
1473 * y-direction. For each two faces: first the face with normal in negative
1474 * coordinate direction, then the one with normal in positive direction, i.e.
1475 * the faces are ordered according to their normals pointing in -x, x, -y, y
1476 * direction.
1477 *
1478 * - The direction of a line is represented by the direction of point 0
1479 * towards point 1 and is always in one of the coordinate directions
1480 *
1481 * - Face lines in 3d are ordered, such that the induced 2d local coordinate
1482 * system (x,y) implies (right hand rule) a normal in face normal direction,
1483 * see N2/.
1484 *
1485 * The resulting numbering of vertices and faces (lines) in 2d as well as the
1486 * directions of lines is shown in the following.
1487 * @verbatim
1488 * 3
1489 * 2-->--3
1490 * | |
1491 * 0^ ^1
1492 * | |
1493 * 0-->--1
1494 * 2
1495 * @endverbatim
1496 *
1497 * Note that the orientation of lines has to be correct upon construction of a
1498 * grid; however, it is automatically preserved upon refinement.
1499 *
1500 * Further we define that child lines have the same direction as their parent,
1501 * i.e. that <tt>line->child(0)->vertex(0)==line->vertex(0)</tt> and
1502 * <tt>line->child(1)->vertex(1)==line->vertex(1)</tt>. This also implies,
1503 * that the first sub-line (<tt>line->child(0)</tt>) is the one at vertex(0)
1504 * of the old line.
1505 *
1506 * Similarly we define, that the four children of a quad are adjacent to the
1507 * vertex with the same number of the old quad.
1508 *
1509 * Note that information about several of these conventions can be extracted
1510 * at run- or compile-time from the member functions and variables of the
1511 * present class.
1512 *
1513 *
1514 * <h4>Coordinate systems</h4>
1515 *
1516 * When explicit coordinates are required for points in a cell (e.g for
1517 * quadrature formulae or the point of definition of trial functions), we
1518 * define the following coordinate system for the unit cell:
1519 * @verbatim
1520 * y^ 2-----3
1521 * | | |
1522 * | | |
1523 * | | |
1524 * | 0-----1
1525 * *------------>x
1526 * @endverbatim
1527 *
1528 * Here, vertex 0 is the origin of the coordinate system, vertex 1 has
1529 * coordinates <tt>(1,0)</tt>, vertex 2 at <tt>(0,1)</tt> and vertex 3 at
1530 * <tt>(1,1)</tt>. The GeometryInfo<dim>::unit_cell_vertex() function can be
1531 * used to query this information at run-time.
1532 *
1533 *
1534 * <h3>Implementation conventions for three spatial dimensions</h3>
1535 *
1536 * By convention, we will use the following numbering conventions for
1537 * vertices, lines and faces of hexahedra in three space dimensions. Before
1538 * giving these conventions we declare the following sketch to be the standard
1539 * way of drawing 3d pictures of hexahedra:
1540 * @verbatim
1541 * *-------* *-------*
1542 * /| | / /|
1543 * / | | / / |
1544 * z / | | / / |
1545 * ^ * | | *-------* |
1546 * | ^y | *-------* | | *
1547 * | / | / / | | /
1548 * | / | / / | | /
1549 * |/ |/ / | |/
1550 * *------>x *-------* *-------*
1551 * @endverbatim
1552 * The left part of the picture shows the left, bottom and back face of the
1553 * cube, while the right one shall be the top, right and front face. You may
1554 * recover the whole cube by moving the two parts together into one.
1555 *
1556 * Note again that information about several of the following conventions can
1557 * be extracted at run- or compile-time from the member functions and
1558 * variables of the present class.
1559 *
1560 * <h4>Vertices</h4>
1561 *
1562 * The ordering of vertices in 3d is defined by the same rules as in the 2d
1563 * case. In particular, the following is still true:
1564 *
1565 * - Vertices are numbered in lexicographic ordering.
1566 *
1567 * Hence, the vertices are numbered as follows
1568 * @verbatim
1569 * 6-------7 6-------7
1570 * /| | / /|
1571 * / | | / / |
1572 * / | | / / |
1573 * 4 | | 4-------5 |
1574 * | 2-------3 | | 3
1575 * | / / | | /
1576 * | / / | | /
1577 * |/ / | |/
1578 * 0-------1 0-------1
1579 * @endverbatim
1580 *
1581 * We note, that first the vertices on the bottom face (z=0) are numbered
1582 * exactly the same way as are the vertices on a quadrilateral. Then the
1583 * vertices on the top face (z=1) are numbered similarly by moving the bottom
1584 * face to the top. Again, the GeometryInfo<dim>::unit_cell_vertex() function
1585 * can be used to query this information at run-time.
1586 *
1587 *
1588 * <h4>Lines</h4>
1589 *
1590 * Here, the same holds as for the vertices:
1591 *
1592 * - Line ordering in 3d:
1593 * <ul>
1594 * <li>first the lines of face (z=0) in 2d line ordering,
1595 * <li>then the lines of face (z=1) in 2d line ordering,
1596 * <li>finally the lines in z direction in lexicographic ordering
1597 * </ul>
1598 * @verbatim
1599 * *---7---* *---7---*
1600 * /| | / /|
1601 * 4 | 11 4 5 11
1602 * / 10 | / / |
1603 * * | | *---6---* |
1604 * | *---3---* | | *
1605 * | / / | 9 /
1606 * 8 0 1 8 | 1
1607 * |/ / | |/
1608 * *---2---* *---2---*
1609 * @endverbatim
1610 * As in 2d lines are directed in coordinate directions.
1611 * @verbatim
1612 * *--->---* *--->---*
1613 * /| | / /|
1614 * ^ | ^ ^ ^ ^
1615 * / ^ | / / |
1616 * * | | *--->---* |
1617 * | *--->---* | | *
1618 * | / / | ^ /
1619 * ^ ^ ^ ^ | ^
1620 * |/ / | |/
1621 * *--->---* *--->---*
1622 * @endverbatim
1623 *
1624 * The fact that edges (just as vertices and faces) are entities that are
1625 * stored in their own right rather than constructed from cells each time they
1626 * are needed, means that adjacent cells actually have pointers to edges that
1627 * are thus shared between them. This implies that the convention that sets of
1628 * parallel edges have parallel directions is not only a local condition.
1629 * Before a list of cells is passed to an object of the Triangulation class
1630 * for creation of a triangulation, you therefore have to make sure that cells
1631 * are oriented in a compatible fashion, so that edge directions are globally
1632 * according to above convention. However, the
1633 * GridTools::consistently_order_cells() function can do this for you, by
1634 * reorienting cells and edges of an arbitrary list of input cells that need not
1635 * be already sorted.
1636 *
1637 * <h4>Faces</h4>
1638 *
1639 * The numbering of faces in 3d is defined by a rule analogous to 2d:
1640 *
1641 * - Faces (quads in 3d): first the two faces with normals in x-, then y- and
1642 * z-direction. For each two faces: first the face with normal in negative
1643 * coordinate direction, then the one with normal in positive direction, i.e.
1644 * the faces are ordered according to their normals pointing in -x, x, -y, y,
1645 * -z, z direction.
1646 *
1647 * Therefore, the faces are numbered in the ordering: left, right, front,
1648 * back, bottom and top face:
1649 * @verbatim
1650 * *-------* *-------*
1651 * /| | / /|
1652 * / | 3 | / 5 / |
1653 * / | | / / |
1654 * * | | *-------* |
1655 * | 0 *-------* | | 1 *
1656 * | / / | | /
1657 * | / 4 / | 2 | /
1658 * |/ / | |/
1659 * *-------* *-------*
1660 * @endverbatim
1661 *
1662 * The <em>standard</em> direction of the faces is such, that the induced 2d
1663 * local coordinate system (x,y) implies (right hand rule) a normal in face
1664 * normal direction, see N2a). In the following we show the local coordinate
1665 * system and the numbering of face lines:
1666 * <ul>
1667 * <li> Faces 0 and 1:
1668 * @verbatim
1669 * Face 0 Face 1
1670 * *-------* *-------*
1671 * /| | / /|
1672 * 3 1 | / 3 1
1673 * y/ | | / y/ |
1674 * * |x | *-------* |x
1675 * | *-------* | | *
1676 * 0 / / | 0 /
1677 * | 2 / | | 2
1678 * |/ / | |/
1679 * *-------* *-------*
1680 * @endverbatim
1681 *
1682 * <li> Faces 2 and 3:
1683 * @verbatim
1684 * x Face 3 Face 2
1685 * *---1---* *-------*
1686 * /| | / /|
1687 * / | 3 / / |
1688 * / 2 | x/ / |
1689 * * | | *---1---* |
1690 * | *---0---*y | | *
1691 * | / / | 3 /
1692 * | / / 2 | /
1693 * |/ / | |/
1694 * *-------* *---0---*y
1695 * @endverbatim
1696 *
1697 * <li> Faces 4 and 5:
1698 * @verbatim
1699 * Face 4 y Face 5
1700 * *-------* *---3---*
1701 * /| | / /|
1702 * / | | 0 1 |
1703 * / | | / / |
1704 * * |y | *---2---* x |
1705 * | *---3---* | | *
1706 * | / / | | /
1707 * | 0 1 | | /
1708 * |/ / | |/
1709 * *---2---* x *-------*
1710 * @endverbatim
1711 * </ul>
1712 *
1713 * The face line numbers (0,1,2,3) correspond to following cell line numbers.
1714 * <ul>
1715 * <li> Face 0: lines 8, 10, 0, 4;
1716 * <li> Face 1: lines 9, 11, 1, 5;
1717 * <li> Face 2: lines 2, 6, 8, 9;
1718 * <li> Face 3: lines 3, 7, 10, 11;
1719 * <li> Face 4: lines 0, 1, 2, 3;
1720 * <li> Face 5: lines 4, 5, 6, 7;
1721 * </ul>
1722 * You can get these numbers using the GeometryInfo<3>::face_to_cell_lines()
1723 * function.
1724 *
1725 * The face normals can be deduced from the face orientation by applying the
1726 * right hand side rule (x,y -> normal). We note, that in the standard
1727 * orientation of faces in 2d, faces 0 and 2 have normals that point into the
1728 * cell, and faces 1 and 3 have normals pointing outward. In 3d, faces 0, 2,
1729 * and 4 have normals that point into the cell, while the normals of faces 1,
1730 * 3, and 5 point outward. This information, again, can be queried from
1731 * GeometryInfo<dim>::unit_normal_orientation.
1732 *
1733 * However, it turns out that a significant number of 3d meshes cannot satisfy
1734 * this convention. This is due to the fact that the face convention for one
1735 * cell already implies something for the neighbor, since they share a common
1736 * face and fixing it for the first cell also fixes the normal vectors of the
1737 * opposite faces of both cells. It is easy to construct cases of loops of
1738 * cells for which this leads to cases where we cannot find orientations for
1739 * all faces that are consistent with this convention.
1740 *
1741 * For this reason, above convention is only what we call the <em>standard
1742 * orientation</em>. deal.II actually allows faces in 3d to have either the
1743 * standard direction, or its opposite, in which case the lines that make up a
1744 * cell would have reverted orders, and the above line equivalences would not
1745 * hold any more. You can ask a cell whether a given face has standard
1746 * orientation by calling <tt>cell->face_orientation(face_no)</tt>: if the
1747 * result is @p true, then the face has standard orientation, otherwise its
1748 * normal vector is pointing the other direction. There are not very many
1749 * places in application programs where you need this information actually,
1750 * but a few places in the library make use of this. More information on the
1751 * topic can be found in this
1752 * @ref GlossCombinedOrientation "glossary"
1753 * article.
1754 *
1755 * In order to allow all kinds of meshes in 3d, including
1756 * <em>Moebius</em>-loops, a face might even be rotated looking from one cell,
1757 * whereas it is according to the standard looking at it from the neighboring
1758 * cell sharing that particular face. In order to cope with this, two flags
1759 * <tt>face_flip</tt> and <tt>face_rotation</tt> are available, to represent
1760 * rotations by 180 and 90 degree, respectively. Setting both flags amounts to
1761 * a rotation of 270 degrees (all counterclockwise). You can ask the cell for
1762 * these flags like for the <tt>face_orientation</tt>. In order to enable
1763 * rotated faces, even lines can deviate from their standard direction in 3d.
1764 * This information is available as the <tt>line_orientation</tt> flag for
1765 * cells and faces in 3d. Again, this is something that should be internal to
1766 * the library and application program will probably never have to bother
1767 * about it. For more information on this see also
1768 * @ref GlossCombinedOrientation "this glossary entry".
1769 *
1770 *
1771 * <h4>Children</h4>
1772 *
1773 * The eight children of an isotropically refined cell are numbered according
1774 * to the vertices they are adjacent to:
1775 * @verbatim
1776 * *----*----* *----*----*
1777 * /| 6 | 7 | / 6 / 7 /|
1778 * *6| | | *----*----*7|
1779 * /| *----*----* / 4 / 5 /| *
1780 * * |/| | | *----*----* |/|
1781 * |4* | 2 | 3 | | 4 | 5 |5*3|
1782 * |/|2*----*----* | | |/| *
1783 * * |/ 2 / 3 / *----*----* |/
1784 * |0*----*----* | | |1*
1785 * |/0 / 1 / | 0 | 1 |/
1786 * *----*----* *----*----*
1787 * @endverbatim
1788 *
1789 * Taking into account the orientation of the faces, the following children
1790 * are adjacent to the respective faces:
1791 * <ul>
1792 * <li> Face 0: children 0, 2, 4, 6;
1793 * <li> Face 1: children 1, 3, 5, 7;
1794 * <li> Face 2: children 0, 4, 1, 5;
1795 * <li> Face 3: children 2, 6, 3, 7;
1796 * <li> Face 4: children 0, 1, 2, 3;
1797 * <li> Face 5: children 4, 5, 6, 7.
1798 * </ul>
1799 * You can get these numbers using the GeometryInfo<3>::child_cell_on_face()
1800 * function. As each child is adjacent to the vertex with the same number
1801 * these numbers are also given by the
1802 * GeometryInfo<3>::face_to_cell_vertices() function.
1803 *
1804 * Note that, again, the above list only holds for faces in their standard
1805 * orientation. If a face is not in standard orientation, then the children at
1806 * positions 1 and 2 (counting from 0 to 3) would be swapped. In fact, this is
1807 * what the child_cell_on_face and the face_to_cell_vertices functions of
1808 * GeometryInfo<3> do, when invoked with a <tt>face_orientation=false</tt>
1809 * argument.
1810 *
1811 * The information which child cell is at which position of which face is most
1812 * often used when computing jump terms across faces with hanging nodes, using
1813 * objects of type FESubfaceValues. Sitting on one cell, you would look at a
1814 * face and figure out which child of the neighbor is sitting on a given
1815 * subface between the present and the neighboring cell. To avoid having to
1816 * query the standard orientation of the faces of the two cells every time in
1817 * such cases, you should use a function call like
1818 * <tt>cell->neighbor_child_on_subface(face_no,subface_no)</tt>, which returns
1819 * the correct result both in 2d (where face orientations are immaterial) and
1820 * 3d (where it is necessary to use the face orientation as additional
1821 * argument to <tt>GeometryInfo<3>::child_cell_on_face</tt>).
1822 *
1823 * For anisotropic refinement, the child cells can not be numbered according
1824 * to adjacent vertices, thus the following conventions are used:
1825 * @verbatim
1826 * RefinementCase<3>::cut_x
1827 *
1828 * *----*----* *----*----*
1829 * /| | | / / /|
1830 * / | | | / 0 / 1 / |
1831 * / | 0 | 1 | / / / |
1832 * * | | | *----*----* |
1833 * | 0 | | | | | | 1 |
1834 * | *----*----* | | | *
1835 * | / / / | 0 | 1 | /
1836 * | / 0 / 1 / | | | /
1837 * |/ / / | | |/
1838 * *----*----* *----*----*
1839 * @endverbatim
1840 *
1841 * @verbatim
1842 * RefinementCase<3>::cut_y
1843 *
1844 * *---------* *---------*
1845 * /| | / 1 /|
1846 * * | | *---------* |
1847 * /| | 1 | / 0 /| |
1848 * * |1| | *---------* |1|
1849 * | | | | | | | |
1850 * |0| *---------* | |0| *
1851 * | |/ 1 / | 0 | |/
1852 * | *---------* | | *
1853 * |/ 0 / | |/
1854 * *---------* *---------*
1855 * @endverbatim
1856 *
1857 * @verbatim
1858 * RefinementCase<3>::cut_z
1859 *
1860 * *---------* *---------*
1861 * /| 1 | / /|
1862 * / | | / 1 / |
1863 * / *---------* / / *
1864 * * 1/| | *---------* 1/|
1865 * | / | 0 | | 1 | / |
1866 * |/ *---------* | |/ *
1867 * * 0/ / *---------* 0/
1868 * | / 0 / | | /
1869 * |/ / | 0 |/
1870 * *---------* *---------*
1871 * @endverbatim
1872 *
1873 * @verbatim
1874 * RefinementCase<3>::cut_xy
1875 *
1876 * *----*----* *----*----*
1877 * /| | | / 2 / 3 /|
1878 * * | | | *----*----* |
1879 * /| | 2 | 3 | / 0 / 1 /| |
1880 * * |2| | | *----*----* |3|
1881 * | | | | | | | | | |
1882 * |0| *----*----* | | |1| *
1883 * | |/ 2 / 3 / | 0 | 1 | |/
1884 * | *----*----* | | | *
1885 * |/ 0 / 1 / | | |/
1886 * *----*----* *----*----*
1887 * @endverbatim
1888 *
1889 * @verbatim
1890 * RefinementCase<3>::cut_xz
1891 *
1892 * *----*----* *----*----*
1893 * /| 1 | 3 | / / /|
1894 * / | | | / 1 / 3 / |
1895 * / *----*----* / / / *
1896 * * 1/| | | *----*----* 3/|
1897 * | / | 0 | 2 | | 1 | 3 | / |
1898 * |/ *----*----* | | |/ *
1899 * * 0/ / / *----*----* 2/
1900 * | / 0 / 2 / | | | /
1901 * |/ / / | 0 | 2 |/
1902 * *----*----* *----*----*
1903 * @endverbatim
1904 *
1905 * @verbatim
1906 * RefinementCase<3>::cut_yz
1907 *
1908 * *---------* *---------*
1909 * /| 3 | / 3 /|
1910 * * | | *---------* |
1911 * /|3*---------* / 2 /|3*
1912 * * |/| | *---------* |/|
1913 * |2* | 1 | | 2 |2* |
1914 * |/|1*---------* | |/|1*
1915 * * |/ 1 / *---------* |/
1916 * |0*---------* | |0*
1917 * |/ 0 / | 0 |/
1918 * *---------* *---------*
1919 * @endverbatim
1920 *
1921 * This information can also be obtained by the
1922 * <tt>GeometryInfo<3>::child_cell_on_face</tt> function.
1923 *
1924 * <h4>Coordinate systems</h4>
1925 *
1926 * We define the following coordinate system for the explicit coordinates of
1927 * the vertices of the unit cell:
1928 * @verbatim
1929 * 6-------7 6-------7
1930 * /| | / /|
1931 * / | | / / |
1932 * z / | | / / |
1933 * ^ 4 | | 4-------5 |
1934 * | ^y | 2-------3 | | 3
1935 * | / | / / | | /
1936 * | / | / / | | /
1937 * |/ |/ / | |/
1938 * *------>x 0-------1 0-------1
1939 * @endverbatim
1940 *
1941 * By the convention laid down as above, the vertices have the following
1942 * coordinates (lexicographic, with x running fastest):
1943 * <ul>
1944 * <li> Vertex 0: <tt>(0,0,0)</tt>;
1945 * <li> Vertex 1: <tt>(1,0,0)</tt>;
1946 * <li> Vertex 2: <tt>(0,1,0)</tt>;
1947 * <li> Vertex 3: <tt>(1,1,0)</tt>;
1948 * <li> Vertex 4: <tt>(0,0,1)</tt>;
1949 * <li> Vertex 5: <tt>(1,0,1)</tt>;
1950 * <li> Vertex 6: <tt>(0,1,1)</tt>;
1951 * <li> Vertex 7: <tt>(1,1,1)</tt>.
1952 * </ul>
1953 *
1954 *
1955 *
1956 * @note Instantiations for this template are provided for dimensions 1,2,3,4,
1957 * and there is a specialization for dim=0 (see the section on
1958 * @ref Instantiations
1959 * in the manual).
1960 *
1961 * @ingroup grid geomprimitives
1962 */
1963 template <int dim>
1964 struct GeometryInfo
1965 {
1966 /**
1967 * Maximum number of children of a refined cell, i.e. the number of children
1968 * of an isotropically refined cell.
1969 *
1970 * If a cell is refined anisotropically, the actual number of children may
1971 * be less than the value given here.
1972 */
1973 static constexpr unsigned int max_children_per_cell = 1 << dim;
1974
1975 /**
1976 * Number of faces of a cell.
1977 */
1978 static constexpr unsigned int faces_per_cell = 2 * dim;
1979
1980 /**
1981 * Return an object that can be thought of as an array containing all
1982 * indices from zero to `faces_per_cell`. This allows to write code
1983 * using range-based for loops of the following kind:
1984 * @code
1985 * for (auto &cell : triangulation.active_cell_iterators())
1986 * for (auto face_index : GeometryInfo<dim>::face_indices())
1987 * if (cell->face(face_index)->at_boundary())
1988 * ... do something ...
1989 * @endcode
1990 * Here, we are looping over all faces of all cells, with `face_index`
1991 * taking on all valid indices for faces (zero and one in 1d, zero
1992 * through three in 2d, and zero through 5 in 3d).
1993 *
1994 * @see CPP11
1995 */
1996 static std_cxx20::ranges::iota_view<unsigned int, unsigned int>
1997 face_indices();
1998
1999 /**
2000 * Maximum number of children of a refined face, i.e. the number of children
2001 * of an isotropically refined face.
2002 *
2003 * If a cell is refined anisotropically, the actual number of children may
2004 * be less than the value given here.
2005 */
2006 static constexpr unsigned int max_children_per_face =
2007 GeometryInfo<dim - 1>::max_children_per_cell;
2008
2009 /**
2010 * Number of vertices of a cell.
2011 */
2012 static constexpr unsigned int vertices_per_cell = 1 << dim;
2013
2014 /**
2015 * Return an object that can be thought of as an array containing all
2016 * indices from zero to `vertices_per_cell`. This allows to write code
2017 * using range-based for loops of the following kind:
2018 * @code
2019 * for (auto &cell : triangulation.active_cell_iterators())
2020 * for (auto vertex_index : GeometryInfo<dim>::vertex_indices())
2021 * if (cell->vertex(vertex_index) satisfies some condition)
2022 * ... do something ...
2023 * @endcode
2024 * Here, we are looping over all vertices of all cells, with `vertex_index`
2025 * taking on all valid indices.
2026 *
2027 * @see CPP11
2028 */
2029 static std_cxx20::ranges::iota_view<unsigned int, unsigned int>
2030 vertex_indices();
2031
2032 /**
2033 * Number of vertices on each face.
2034 */
2035 static constexpr unsigned int vertices_per_face =
2036 GeometryInfo<dim - 1>::vertices_per_cell;
2037
2038 /**
2039 * Number of lines on each face.
2040 */
2041 static constexpr unsigned int lines_per_face =
2042 GeometryInfo<dim - 1>::lines_per_cell;
2043
2044 /**
2045 * Number of quads on each face.
2046 */
2047 static constexpr unsigned int quads_per_face =
2048 GeometryInfo<dim - 1>::quads_per_cell;
2049
2050 /**
2051 * Number of lines of a cell.
2052 *
2053 * The formula to compute this makes use of the fact that when going from
2054 * one dimension to the next, the object of the lower dimension is copied
2055 * once (thus twice the old number of lines) and then a new line is inserted
2056 * between each vertex of the old object and the corresponding one in the
2057 * copy.
2058 */
2059 static constexpr unsigned int lines_per_cell =
2060 (2 * GeometryInfo<dim - 1>::lines_per_cell +
2061 GeometryInfo<dim - 1>::vertices_per_cell);
2062
2063 /**
2064 * Number of quadrilaterals of a cell.
2065 *
2066 * This number is computed recursively just as the previous one, with the
2067 * exception that new quads result from connecting an original line and its
2068 * copy.
2069 */
2070 static constexpr unsigned int quads_per_cell =
2071 (2 * GeometryInfo<dim - 1>::quads_per_cell +
2072 GeometryInfo<dim - 1>::lines_per_cell);
2073
2074 /**
2075 * Number of hexahedra of a cell.
2076 */
2077 static constexpr unsigned int hexes_per_cell =
2078 (2 * GeometryInfo<dim - 1>::hexes_per_cell +
2079 GeometryInfo<dim - 1>::quads_per_cell);
2080
2081 /**
2082 * Rearrange vertices for UCD output. For a cell being written in UCD
2083 * format, each entry in this field contains the number of a vertex in
2084 * <tt>deal.II</tt> that corresponds to the UCD numbering at this location.
2085 *
2086 * Typical example: write a cell and arrange the vertices, such that UCD
2087 * understands them.
2088 *
2089 * @code
2090 * for (i=0; i< n_vertices; ++i)
2091 * out << cell->vertex(ucd_to_deal[i]);
2092 * @endcode
2093 *
2094 * As the vertex numbering in deal.II versions <= 5.1 happened to coincide
2095 * with the UCD numbering, this field can also be used like a
2096 * old_to_lexicographic mapping.
2097 */
2098 static constexpr std::array<unsigned int, vertices_per_cell> ucd_to_deal =
2099 internal::GeometryInfoHelper::Initializers<dim>::ucd_to_deal();
2100
2101 /**
2102 * Rearrange vertices for OpenDX output. For a cell being written in OpenDX
2103 * format, each entry in this field contains the number of a vertex in
2104 * <tt>deal.II</tt> that corresponds to the DX numbering at this location.
2105 *
2106 * Typical example: write a cell and arrange the vertices, such that OpenDX
2107 * understands them.
2108 *
2109 * @code
2110 * for (i=0; i< n_vertices; ++i)
2111 * out << cell->vertex(dx_to_deal[i]);
2112 * @endcode
2113 */
2114 static constexpr std::array<unsigned int, vertices_per_cell> dx_to_deal =
2115 internal::GeometryInfoHelper::Initializers<dim>::dx_to_deal();
2116
2117 /**
2118 * This field stores for each vertex to which faces it belongs. In any given
2119 * dimension, the number of faces is equal to the dimension. The first index
2120 * in this 2d-array runs over all vertices, the second index over @p dim
2121 * faces to which the vertex belongs.
2122 *
2123 * The order of the faces for each vertex is such that the first listed face
2124 * bounds the reference cell in <i>x</i> direction, the second in <i>y</i>
2125 * direction, and so on.
2126 */
2127 static constexpr ndarray<unsigned int, vertices_per_cell, dim>
2128 vertex_to_face =
2129 internal::GeometryInfoHelper::Initializers<dim>::vertex_to_face();
2130
2131 /**
2132 * Return the number of children of a cell (or face) refined with
2133 * <tt>ref_case</tt>.
2134 */
2135 static unsigned int
2136 n_children(const RefinementCase<dim> &refinement_case);
2137
2138 /**
2139 * Return the number of subfaces of a face refined according to
2140 * internal::SubfaceCase @p face_ref_case.
2141 */
2142 static unsigned int
2143 n_subfaces(const internal::SubfaceCase<dim> &subface_case);
2144
2145 /**
2146 * Given a face on the reference element with a
2147 * <code>internal::SubfaceCase@<dim@></code> @p face_refinement_case this
2148 * function returns the ratio between the area of the @p subface_no th
2149 * subface and the area(=1) of the face.
2150 *
2151 * E.g. for internal::SubfaceCase::cut_xy the ratio is 1/4 for each of the
2152 * subfaces.
2153 */
2154 static double
2155 subface_ratio(const internal::SubfaceCase<dim> &subface_case,
2156 const unsigned int subface_no);
2157
2158 /**
2159 * Given a cell refined with the <code>RefinementCase</code> @p
2160 * cell_refinement_case return the <code>SubfaceCase</code> of the @p
2161 * face_no th face.
2162 */
2163 static RefinementCase<dim - 1>
2164 face_refinement_case(const RefinementCase<dim> &cell_refinement_case,
2165 const unsigned int face_no,
2166 const bool face_orientation = true,
2167 const bool face_flip = false,
2168 const bool face_rotation = false);
2169
2170 /**
2171 * Given the SubfaceCase @p face_refinement_case of the @p face_no th face,
2172 * return the smallest RefinementCase of the cell, which corresponds to that
2173 * refinement of the face.
2174 */
2175 static RefinementCase<dim>
2176 min_cell_refinement_case_for_face_refinement(
2177 const RefinementCase<dim - 1> &face_refinement_case,
2178 const unsigned int face_no,
2179 const bool face_orientation = true,
2180 const bool face_flip = false,
2181 const bool face_rotation = false);
2182
2183 /**
2184 * Given a cell refined with the RefinementCase @p cell_refinement_case
2185 * return the RefinementCase of the @p line_no th face.
2186 */
2187 static RefinementCase<1>
2188 line_refinement_case(const RefinementCase<dim> &cell_refinement_case,
2189 const unsigned int line_no);
2190
2191 /**
2192 * Return the minimal / smallest RefinementCase of the cell, which ensures
2193 * refinement of line @p line_no.
2194 */
2195 static RefinementCase<dim>
2196 min_cell_refinement_case_for_line_refinement(const unsigned int line_no);
2197
2198 /**
2199 * This field stores which child cells are adjacent to a certain face of the
2200 * parent cell.
2201 *
2202 * For example, in 2d the layout of a cell is as follows:
2203 * @verbatim
2204 * . 3
2205 * . 2-->--3
2206 * . | |
2207 * . 0 ^ ^ 1
2208 * . | |
2209 * . 0-->--1
2210 * . 2
2211 * @endverbatim
2212 * Vertices and faces are indicated with their numbers, faces also with
2213 * their directions.
2214 *
2215 * Now, when refined, the layout is like this:
2216 * @verbatim
2217 * *--*--*
2218 * | 2|3 |
2219 * *--*--*
2220 * | 0|1 |
2221 * *--*--*
2222 * @endverbatim
2223 *
2224 * Thus, the child cells on face 0 are (ordered in the direction of the
2225 * face) 0 and 2, on face 3 they are 2 and 3, etc.
2226 *
2227 * For three spatial dimensions, the exact order of the children is laid
2228 * down in the general documentation of this class.
2229 *
2230 * Through the <tt>face_orientation</tt>, <tt>face_flip</tt> and
2231 * <tt>face_rotation</tt> arguments this function handles faces oriented in
2232 * the standard and non-standard orientation. <tt>face_orientation</tt>
2233 * defaults to <tt>true</tt>, <tt>face_flip</tt> and <tt>face_rotation</tt>
2234 * default to <tt>false</tt> (standard orientation) and has no effect in 2d.
2235 * The concept of face orientations is explained in this
2236 * @ref GlossCombinedOrientation "glossary"
2237 * entry.
2238 *
2239 * In the case of anisotropically refined cells and faces, the @p
2240 * RefinementCase of the face, <tt>face_ref_case</tt>, might have an
2241 * influence on which child is behind which given subface, thus this is an
2242 * additional argument, defaulting to isotropic refinement of the face.
2243 */
2244 static unsigned int
2245 child_cell_on_face(const RefinementCase<dim> &ref_case,
2246 const unsigned int face,
2247 const unsigned int subface,
2248 const bool face_orientation = true,
2249 const bool face_flip = false,
2250 const bool face_rotation = false,
2251 const RefinementCase<dim - 1> &face_refinement_case =
2252 RefinementCase<dim - 1>::isotropic_refinement);
2253
2254 /**
2255 * Map line vertex number to cell vertex number, i.e. give the cell vertex
2256 * number of the <tt>vertex</tt>th vertex of line <tt>line</tt>, e.g.
2257 * <tt>GeometryInfo<2>::line_to_cell_vertices(3,0)=2</tt>.
2258 *
2259 * The order of the lines, as well as their direction (which in turn
2260 * determines which is the first and which the second vertex on a line) is
2261 * the canonical one in deal.II, as described in the general documentation
2262 * of this class.
2263 *
2264 * For <tt>dim=2</tt> this call is simply passed down to the
2265 * face_to_cell_vertices() function.
2266 */
2267 static unsigned int
2268 line_to_cell_vertices(const unsigned int line, const unsigned int vertex);
2269
2270 /**
2271 * Map face vertex number to cell vertex number, i.e. give the cell vertex
2272 * number of the <tt>vertex</tt>th vertex of face <tt>face</tt>, e.g.
2273 * <tt>GeometryInfo<2>::face_to_cell_vertices(3,0)=2</tt>, see the image
2274 * under point N4 in the 2d section of this class's documentation.
2275 *
2276 * Through the <tt>face_orientation</tt>, <tt>face_flip</tt> and
2277 * <tt>face_rotation</tt> arguments this function handles faces oriented in
2278 * the standard and non-standard orientation. <tt>face_orientation</tt>
2279 * defaults to <tt>true</tt>, <tt>face_flip</tt> and <tt>face_rotation</tt>
2280 * default to <tt>false</tt> (standard orientation). In 2d only
2281 * <tt>face_flip</tt> is considered. See this
2282 * @ref GlossCombinedOrientation "glossary"
2283 * article for more information.
2284 *
2285 * As the children of a cell are ordered according to the vertices of the
2286 * cell, this call is passed down to the child_cell_on_face() function.
2287 * Hence this function is simply a wrapper of child_cell_on_face() giving it
2288 * a suggestive name.
2289 */
2290 static unsigned int
2291 face_to_cell_vertices(const unsigned int face,
2292 const unsigned int vertex,
2293 const bool face_orientation = true,
2294 const bool face_flip = false,
2295 const bool face_rotation = false);
2296
2297 /**
2298 * Map face line number to cell line number, i.e. give the cell line number
2299 * of the <tt>line</tt>th line of face <tt>face</tt>, e.g.
2300 * <tt>GeometryInfo<3>::face_to_cell_lines(5,0)=4</tt>.
2301 *
2302 * Through the <tt>face_orientation</tt>, <tt>face_flip</tt> and
2303 * <tt>face_rotation</tt> arguments this function handles faces oriented in
2304 * the standard and non-standard orientation. <tt>face_orientation</tt>
2305 * defaults to <tt>true</tt>, <tt>face_flip</tt> and <tt>face_rotation</tt>
2306 * default to <tt>false</tt> (standard orientation) and has no effect in 2d.
2307 */
2308 static unsigned int
2309 face_to_cell_lines(const unsigned int face,
2310 const unsigned int line,
2311 const bool face_orientation = true,
2312 const bool face_flip = false,
2313 const bool face_rotation = false);
2314
2315 /**
2316 * Map the vertex index @p vertex of a face in standard orientation to one
2317 * of a face with arbitrary @p face_orientation, @p face_flip and @p
2318 * face_rotation. The values of these three flags default to <tt>true</tt>,
2319 * <tt>false</tt> and <tt>false</tt>, respectively. this combination
2320 * describes a face in standard orientation.
2321 *
2322 * This function is only implemented in 3d.
2323 */
2324 static unsigned int
2325 standard_to_real_face_vertex(const unsigned int vertex,
2326 const bool face_orientation = true,
2327 const bool face_flip = false,
2328 const bool face_rotation = false);
2329
2330 /**
2331 * Map the vertex index @p vertex of a face with arbitrary @p
2332 * face_orientation, @p face_flip and @p face_rotation to a face in standard
2333 * orientation. The values of these three flags default to <tt>true</tt>,
2334 * <tt>false</tt> and <tt>false</tt>, respectively. this combination
2335 * describes a face in standard orientation.
2336 *
2337 * This function is only implemented in 3d.
2338 */
2339 static unsigned int
2340 real_to_standard_face_vertex(const unsigned int vertex,
2341 const bool face_orientation = true,
2342 const bool face_flip = false,
2343 const bool face_rotation = false);
2344
2345 /**
2346 * Map the line index @p line of a face in standard orientation to one of a
2347 * face with arbitrary @p face_orientation, @p face_flip and @p
2348 * face_rotation. The values of these three flags default to <tt>true</tt>,
2349 * <tt>false</tt> and <tt>false</tt>, respectively. this combination
2350 * describes a face in standard orientation.
2351 *
2352 * This function is only implemented in 3d.
2353 */
2354 static unsigned int
2355 standard_to_real_face_line(const unsigned int line,
2356 const bool face_orientation = true,
2357 const bool face_flip = false,
2358 const bool face_rotation = false);
2359
2360 /**
2361 * Map the vertex index @p vertex of a line in standard orientation to one of a
2362 * face with arbitrary @p line_orientation. The value of this flag default to
2363 * <tt>true</tt>.
2364 */
2365 static unsigned int
2366 standard_to_real_line_vertex(const unsigned int vertex,
2367 const bool line_orientation = true);
2368
2369 /**
2370 * Decompose the vertex index in a quad into a pair of a line index and a
2371 * vertex index within this line.
2372 *
2373 * @note Which line is selected is not of importance (and not exposed on
2374 * purpose).
2375 */
2376 static std::array<unsigned int, 2>
2377 standard_quad_vertex_to_line_vertex_index(const unsigned int vertex);
2378
2379 /**
2380 * Decompose the vertex index in a hex into a pair of a quad index and a
2381 * vertex index within this quad.
2382 *
2383 * @note Which quad is selected is not of importance (and not exposed on
2384 * purpose).
2385 */
2386 static std::array<unsigned int, 2>
2387 standard_hex_vertex_to_quad_vertex_index(const unsigned int vertex);
2388
2389 /**
2390 * Decompose the line index in a hex into a pair of a quad index and a line
2391 * index within this quad.
2392 *
2393 * @note Which quad is selected is not of importance (and not exposed on
2394 * purpose).
2395 */
2396 static std::array<unsigned int, 2>
2397 standard_hex_line_to_quad_line_index(const unsigned int line);
2398
2399 /**
2400 * Map the line index @p line of a face with arbitrary @p face_orientation,
2401 * @p face_flip and @p face_rotation to a face in standard orientation. The
2402 * values of these three flags default to <tt>true</tt>, <tt>false</tt> and
2403 * <tt>false</tt>, respectively. this combination describes a face in
2404 * standard orientation.
2405 *
2406 * This function is only implemented in 3d.
2407 */
2408 static unsigned int
2409 real_to_standard_face_line(const unsigned int line,
2410 const bool face_orientation = true,
2411 const bool face_flip = false,
2412 const bool face_rotation = false);
2413
2414 /**
2415 * Return the position of the @p ith vertex on the unit cell. The order of
2416 * vertices is the canonical one in deal.II, as described in the general
2417 * documentation of this class.
2418 */
2419 static Point<dim>
2420 unit_cell_vertex(const unsigned int vertex);
2421
2422 /**
2423 * Given a point @p p in unit coordinates, return the number of the child
2424 * cell in which it would lie in. If the point lies on the interface of two
2425 * children, return any one of their indices. The result is always less than
2426 * GeometryInfo<dimension>::max_children_per_cell.
2427 *
2428 * The order of child cells is described the general documentation of this
2429 * class.
2430 */
2431 static unsigned int
2432 child_cell_from_point(const Point<dim> &p);
2433
2434 /**
2435 * Given coordinates @p p on the unit cell, return the values of the
2436 * coordinates of this point in the coordinate system of the given child.
2437 * Neither original nor returned coordinates need actually be inside the
2438 * cell, we simply perform a scale-and-shift operation with a shift that
2439 * depends on the number of the child.
2440 */
2441 static Point<dim>
2442 cell_to_child_coordinates(const Point<dim> &p,
2443 const unsigned int child_index,
2444 const RefinementCase<dim> refine_case =
2445 RefinementCase<dim>::isotropic_refinement);
2446
2447 /**
2448 * The reverse function to the one above: take a point in the coordinate
2449 * system of the child, and transform it to the coordinate system of the
2450 * parent cell.
2451 */
2452 static Point<dim>
2453 child_to_cell_coordinates(const Point<dim> &p,
2454 const unsigned int child_index,
2455 const RefinementCase<dim> refine_case =
2456 RefinementCase<dim>::isotropic_refinement);
2457
2458 /**
2459 * Return true if the given point is inside the unit cell of the present
2460 * space dimension.
2461 */
2462 static bool
2463 is_inside_unit_cell(const Point<dim> &p);
2464
2465 /**
2466 * Return true if the given point is inside the unit cell of the present
2467 * space dimension. This function accepts an additional parameter which
2468 * specifies how much the point position may actually be outside the true
2469 * unit cell. This is useful because in practice we may often not be able to
2470 * compute the coordinates of a point in reference coordinates exactly, but
2471 * only up to numerical roundoff.
2472 *
2473 * The tolerance parameter may be less than zero, indicating that the point
2474 * should be safely inside the cell.
2475 */
2476 static bool
2477 is_inside_unit_cell(const Point<dim> &p, const double eps);
2478
2479 /**
2480 * Projects a given point onto the unit cell, i.e. each coordinate outside
2481 * [0..1] is modified to lie within that interval.
2482 */
2483 template <typename Number = double>
2484 static Point<dim, Number>
2485 project_to_unit_cell(const Point<dim, Number> &p);
2486
2487 /**
2488 * Return the infinity norm of the vector between a given point @p p
2489 * outside the unit cell to the closest unit cell boundary. For points
2490 * inside the cell, this is defined as zero.
2491 */
2492 static double
2493 distance_to_unit_cell(const Point<dim> &p);
2494
2495 /**
2496 * Compute the value of the $i$-th $d$-linear (i.e. (bi-,tri-)linear) shape
2497 * function at location $\xi$.
2498 */
2499 static double
2500 d_linear_shape_function(const Point<dim> &xi, const unsigned int i);
2501
2502 /**
2503 * Compute the gradient of the $i$-th $d$-linear (i.e. (bi-,tri-)linear)
2504 * shape function at location $\xi$.
2505 */
2506 static Tensor<1, dim>
2507 d_linear_shape_function_gradient(const Point<dim> &xi, const unsigned int i);
2508
2509 /**
2510 * For a (bi-, tri-)linear mapping from the reference cell, face, or edge to
2511 * the object specified by the given vertices, compute the alternating form
2512 * of the transformed unit vectors vertices. For an object of dimensionality
2513 * @p dim, there are @p dim vectors with @p spacedim components each, and
2514 * the alternating form is a tensor of rank spacedim-dim that corresponds to
2515 * the wedge product of the @p dim unit vectors, and it corresponds to the
2516 * volume and normal vectors of the mapping from reference element to the
2517 * element described by the vertices.
2518 *
2519 * For example, if dim==spacedim==2, then the alternating form is a scalar
2520 * (because spacedim-dim=0) and its value equals $\mathbf v_1\wedge \mathbf
2521 * v_2=\mathbf v_1^\perp \cdot\mathbf v_2$, where $\mathbf v_1^\perp$ is a
2522 * vector that is rotated to the right by 90 degrees from $\mathbf v_1$. If
2523 * dim==spacedim==3, then the result is again a scalar with value $\mathbf
2524 * v_1\wedge \mathbf v_2 \wedge \mathbf v_3 = (\mathbf v_1\times \mathbf
2525 * v_2)\cdot \mathbf v_3$, where $\mathbf v_1, \mathbf v_2, \mathbf v_3$ are
2526 * the images of the unit vectors at a vertex of the unit dim-dimensional
2527 * cell under transformation to the dim-dimensional cell in
2528 * spacedim-dimensional space. In both cases, i.e. for dim==2 or 3, the result
2529 * happens to equal the determinant of the Jacobian of the mapping from
2530 * reference cell to cell in real space. Note that it is the actual
2531 * determinant, not its absolute value as often used in transforming
2532 * integrals from one coordinate system to another. In particular, if the
2533 * object specified by the vertices is a parallelogram (i.e. a linear
2534 * transformation of the reference cell) then the computed values are the
2535 * same at all vertices and equal the (signed) area of the cell; similarly,
2536 * for parallel-epipeds, it is the volume of the cell.
2537 *
2538 * Likewise, if we have dim==spacedim-1 (e.g. we have a quad in 3d space, or
2539 * a line in 2d), then the alternating product denotes the normal vector
2540 * (i.e. a rank-1 tensor, since spacedim-dim=1) to the object at each
2541 * vertex, where the normal vector's magnitude denotes the area element of
2542 * the transformation from the reference object to the object given by the
2543 * vertices. In particular, if again the mapping from reference object to
2544 * the object under consideration here is linear (not bi- or trilinear),
2545 * then the returned vectors are all %parallel, perpendicular to the mapped
2546 * object described by the vertices, and have a magnitude equal to the
2547 * area/volume of the mapped object. If dim=1, spacedim=2, then the returned
2548 * value is $\mathbf v_1^\perp$, where $\mathbf v_1$ is the image of the
2549 * sole unit vector of a line mapped to the line in 2d given by the
2550 * vertices; if dim=2, spacedim=3, then the returned values are $\mathbf v_1
2551 * \wedge \mathbf v_2=\mathbf v_1 \times \mathbf v_2$ where $\mathbf
2552 * v_1,\mathbf v_2$ are the two three-dimensional vectors that are
2553 * tangential to the quad mapped into three-dimensional space.
2554 *
2555 * This function is used in order to determine how distorted a cell is (see
2556 * the entry on
2557 * @ref GlossDistorted "distorted cells"
2558 * in the glossary).
2559 */
2560 template <int spacedim>
2561 static void
2562 alternating_form_at_vertices
2563 #ifndef DEAL_II_CXX14_CONSTEXPR_BUG
2564 (const Point<spacedim> (&vertices)[vertices_per_cell],
2565 Tensor<spacedim - dim, spacedim> (&forms)[vertices_per_cell]);
2566 #else
2567 (const Point<spacedim> *vertices, Tensor<spacedim - dim, spacedim> *forms);
2568 #endif
2569
2570 /**
2571 * For each face of the reference cell, this field stores the coordinate
2572 * direction in which its normal vector points. In <tt>dim</tt> dimension
2573 * these are the <tt>2*dim</tt> first entries of <tt>{0,0,1,1,2,2,3,3}</tt>.
2574 *
2575 * Note that this is only the coordinate number. The actual direction of the
2576 * normal vector is obtained by multiplying the unit vector in this
2577 * direction with #unit_normal_orientation.
2578 */
2579 static constexpr std::array<unsigned int, faces_per_cell>
2580 unit_normal_direction =
2581 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_direction();
2582
2583 /**
2584 * Orientation of the unit normal vector of a face of the reference cell. In
2585 * <tt>dim</tt> dimension these are the <tt>2*dim</tt> first entries of
2586 * <tt>{-1,1,-1,1,-1,1,-1,1}</tt>.
2587 *
2588 * Each value is either <tt>1</tt> or <tt>-1</tt>, corresponding to a normal
2589 * vector pointing in the positive or negative coordinate direction,
2590 * respectively.
2591 *
2592 * Note that this is only the <em>standard orientation</em> of faces. At
2593 * least in 3d, actual faces of cells in a triangulation can also have the
2594 * opposite orientation, depending on a flag that one can query from the
2595 * cell it belongs to. For more information, see the
2596 * @ref GlossCombinedOrientation "glossary"
2597 * entry on face orientation.
2598 */
2599 static constexpr std::array<int, faces_per_cell> unit_normal_orientation =
2600 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_orientation();
2601
2602 /**
2603 * Unit normal vector (Point<dim>) of a face of the reference cell.
2604 *
2605 * Note that this is only the <em>standard orientation</em> of faces. At
2606 * least in 3d, actual faces of cells in a triangulation can also have the
2607 * opposite orientation, depending on a flag that one can query from the
2608 * cell it belongs to. For more information, see the
2609 * @ref GlossCombinedOrientation "glossary"
2610 * entry on face orientation.
2611 */
2612 static constexpr std::array<Tensor<1, dim>, faces_per_cell>
2613 unit_normal_vector =
2614 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_vector();
2615
2616 /**
2617 * Unit tangential vectors (array of `dim-1` elements of Point<dim>) of a
2618 * face of the reference cell, arranged in a right-hand coordinate system
2619 * such that the cross product between the two vectors return the unit
2620 * normal vector.
2621 *
2622 * Note that this is only the <em>standard orientation</em> of faces. At
2623 * least in 3d, actual faces of cells in a triangulation can also have the
2624 * opposite orientation, depending on a flag that one can query from the
2625 * cell it belongs to. For more information, see the
2626 * @ref GlossCombinedOrientation "glossary"
2627 * entry on face orientation.
2628 */
2629 static constexpr ndarray<Tensor<1, dim>, faces_per_cell, dim - 1>
2630 unit_tangential_vectors = internal::GeometryInfoHelper::Initializers<
2631 dim>::unit_tangential_vectors();
2632
2633 /**
2634 * List of numbers which denotes which face is opposite to a given face. Its
2635 * entries are the first <tt>2*dim</tt> entries of <tt>{ 1, 0, 3, 2, 5, 4,
2636 * 7, 6}</tt>.
2637 */
2638 static constexpr std::array<unsigned int, faces_per_cell> opposite_face =
2639 internal::GeometryInfoHelper::Initializers<dim>::opposite_face();
2640
2641
2642 /**
2643 * Exception
2644 */
2645 DeclException1(ExcInvalidCoordinate,
2646 double,
2647 << "The coordinates must satisfy 0 <= x_i <= 1, "
2648 << "but here we have x_i=" << arg1);
2649
2650 /**
2651 * Exception
2652 */
2653 DeclException3(ExcInvalidSubface,
2654 int,
2655 int,
2656 int,
2657 << "RefinementCase<dim> " << arg1 << ": face " << arg2
2658 << " has no subface " << arg3);
2659 };
2660
2661
2662
2663 #ifndef DOXYGEN
2664
2665
2666 /* -------------- declaration of explicit specializations ------------- */
2667
2668
2669 template <>
2670 Tensor<1, 1>
2671 GeometryInfo<1>::d_linear_shape_function_gradient(const Point<1> &xi,
2672 const unsigned int i);
2673 template <>
2674 Tensor<1, 2>
2675 GeometryInfo<2>::d_linear_shape_function_gradient(const Point<2> &xi,
2676 const unsigned int i);
2677 template <>
2678 Tensor<1, 3>
2679 GeometryInfo<3>::d_linear_shape_function_gradient(const Point<3> &xi,
2680 const unsigned int i);
2681
2682
2683
2684 /* -------------- inline functions ------------- */
2685
2686
2687 inline GeometryPrimitive::GeometryPrimitive(const Object object)
2688 : object(object)
2689 {}
2690
2691
2692
2693 inline GeometryPrimitive::GeometryPrimitive(const unsigned int object_dimension)
2694 : object(static_cast<Object>(object_dimension))
2695 {}
2696
2697
2698 inline GeometryPrimitive::operator unsigned int() const
2699 {
2700 return static_cast<unsigned int>(object);
2701 }
2702
2703
2704
2705 namespace internal
2706 {
2707 template <int dim>
2708 inline SubfaceCase<dim>::SubfaceCase(
2709 const typename SubfacePossibilities<dim>::Possibilities subface_possibility)
2710 : value(subface_possibility)
2711 {}
2712
2713
2714 template <int dim>
2715 inline SubfaceCase<dim>::operator std::uint8_t() const
2716 {
2717 return value;
2718 }
2719
2720
2721 } // namespace internal
2722
2723
2724 template <int dim>
2725 inline RefinementCase<dim>
2726 RefinementCase<dim>::cut_axis(const unsigned int)
2727 {
2728 DEAL_II_ASSERT_UNREACHABLE();
2729 return static_cast<std::uint8_t>(-1);
2730 }
2731
2732
2733 template <>
2734 inline RefinementCase<1>
2735 RefinementCase<1>::cut_axis(const unsigned int i)
2736 {
2737 AssertIndexRange(i, 1);
2738
2739 const RefinementCase options[1] = {RefinementPossibilities<1>::cut_x};
2740 return options[i];
2741 }
2742
2743
2744
2745 template <>
2746 inline RefinementCase<2>
2747 RefinementCase<2>::cut_axis(const unsigned int i)
2748 {
2749 AssertIndexRange(i, 2);
2750
2751 const RefinementCase options[2] = {RefinementPossibilities<2>::cut_x,
2752 RefinementPossibilities<2>::cut_y};
2753 return options[i];
2754 }
2755
2756
2757
2758 template <>
2759 inline RefinementCase<3>
2760 RefinementCase<3>::cut_axis(const unsigned int i)
2761 {
2762 AssertIndexRange(i, 3);
2763
2764 const RefinementCase options[3] = {RefinementPossibilities<3>::cut_x,
2765 RefinementPossibilities<3>::cut_y,
2766 RefinementPossibilities<3>::cut_z};
2767 return options[i];
2768 }
2769
2770
2771
2772 template <>
2773 inline std::array<RefinementCase<1>, 2>
2774 RefinementCase<1>::all_refinement_cases()
2775 {
2776 return {{RefinementPossibilities<1>::no_refinement,
2777 RefinementPossibilities<1>::cut_x}};
2778 }
2779
2780
2781
2782 template <>
2783 inline std::array<RefinementCase<2>, 4>
2784 RefinementCase<2>::all_refinement_cases()
2785 {
2786 return {{RefinementPossibilities<2>::no_refinement,
2787 RefinementPossibilities<2>::cut_x,
2788 RefinementPossibilities<2>::cut_y,
2789 RefinementPossibilities<2>::cut_xy}};
2790 }
2791
2792
2793
2794 template <>
2795 inline std::array<RefinementCase<3>, 8>
2796 RefinementCase<3>::all_refinement_cases()
2797 {
2798 return {{RefinementPossibilities<3>::no_refinement,
2799 RefinementPossibilities<3>::cut_x,
2800 RefinementPossibilities<3>::cut_y,
2801 RefinementPossibilities<3>::cut_xy,
2802 RefinementPossibilities<3>::cut_z,
2803 RefinementPossibilities<3>::cut_xz,
2804 RefinementPossibilities<3>::cut_yz,
2805 RefinementPossibilities<3>::cut_xyz}};
2806 }
2807
2808
2809
2810 template <int dim>
2811 inline RefinementCase<dim>::RefinementCase()
2812 : value(RefinementPossibilities<dim>::no_refinement)
2813 {}
2814
2815
2816
2817 template <int dim>
2818 inline RefinementCase<dim>::RefinementCase(
2819 const typename RefinementPossibilities<dim>::Possibilities refinement_case)
2820 : value(refinement_case)
2821 {
2822 // check that only those bits of
2823 // the given argument are set that
2824 // make sense for a given space
2825 // dimension
2826 Assert((refinement_case &
2827 RefinementPossibilities<dim>::isotropic_refinement) ==
2828 refinement_case,
2829 ExcInvalidRefinementCase(refinement_case));
2830 }
2831
2832
2833
2834 template <int dim>
2835 inline RefinementCase<dim>::RefinementCase(const std::uint8_t refinement_case)
2836 : value(refinement_case)
2837 {
2838 // check that only those bits of
2839 // the given argument are set that
2840 // make sense for a given space
2841 // dimension
2842 Assert((refinement_case &
2843 RefinementPossibilities<dim>::isotropic_refinement) ==
2844 refinement_case,
2845 ExcInvalidRefinementCase(refinement_case));
2846 }
2847
2848
2849
2850 template <int dim>
2851 inline DEAL_II_HOST_DEVICE RefinementCase<dim>::operator std::uint8_t() const
2852 {
2853 return value;
2854 }
2855
2856
2857
2858 template <int dim>
2859 inline RefinementCase<dim>
2860 RefinementCase<dim>::operator|(const RefinementCase<dim> &r) const
2861 {
2862 return RefinementCase<dim>(static_cast<std::uint8_t>(value | r.value));
2863 }
2864
2865
2866
2867 template <int dim>
2868 inline RefinementCase<dim>
2869 RefinementCase<dim>::operator&(const RefinementCase<dim> &r) const
2870 {
2871 return RefinementCase<dim>(static_cast<std::uint8_t>(value & r.value));
2872 }
2873
2874
2875
2876 template <int dim>
2877 inline RefinementCase<dim>
2878 RefinementCase<dim>::operator~() const
2879 {
2880 return RefinementCase<dim>(static_cast<std::uint8_t>(
2881 (~value) & RefinementPossibilities<dim>::isotropic_refinement));
2882 }
2883
2884
2885
2886 template <int dim>
2887 inline std::size_t
2888 RefinementCase<dim>::memory_consumption()
2889 {
2890 return sizeof(RefinementCase<dim>);
2891 }
2892
2893
2894
2895 template <int dim>
2896 template <class Archive>
2897 inline void
2898 RefinementCase<dim>::serialize(Archive &ar, const unsigned int)
2899 {
2900 // serialization can't deal with bitfields, so copy from/to a full sized
2901 // std::uint8_t
2902 std::uint8_t uchar_value = value;
2903 ar &uchar_value;
2904 value = uchar_value;
2905 }
2906
2907
2908
2909 template <>
2910 inline Point<1>
2911 GeometryInfo<1>::unit_cell_vertex(const unsigned int vertex)
2912 {
2913 AssertIndexRange(vertex, vertices_per_cell);
2914
2915 return Point<1>(static_cast<double>(vertex));
2916 }
2917
2918
2919
2920 template <>
2921 inline Point<2>
2922 GeometryInfo<2>::unit_cell_vertex(const unsigned int vertex)
2923 {
2924 AssertIndexRange(vertex, vertices_per_cell);
2925
2926 return {static_cast<double>(vertex % 2), static_cast<double>(vertex / 2)};
2927 }
2928
2929
2930
2931 template <>
2932 inline Point<3>
2933 GeometryInfo<3>::unit_cell_vertex(const unsigned int vertex)
2934 {
2935 AssertIndexRange(vertex, vertices_per_cell);
2936
2937 return {static_cast<double>(vertex % 2),
2938 static_cast<double>(vertex / 2 % 2),
2939 static_cast<double>(vertex / 4)};
2940 }
2941
2942
2943
2944 inline std::array<unsigned int, 0>
2945 GeometryInfo<0>::face_indices()
2946 {
2947 return {{}};
2948 }
2949
2950
2951
2952 inline std::array<unsigned int, 1>
2953 GeometryInfo<0>::vertex_indices()
2954 {
2955 return {{0}};
2956 }
2957
2958
2959
2960 template <int dim>
2961 inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
2962 GeometryInfo<dim>::face_indices()
2963 {
2964 return std_cxx20::ranges::iota_view<unsigned int, unsigned int>(
2965 0U, faces_per_cell);
2966 }
2967
2968
2969
2970 template <int dim>
2971 inline std_cxx20::ranges::iota_view<unsigned int, unsigned int>
2972 GeometryInfo<dim>::vertex_indices()
2973 {
2974 return std_cxx20::ranges::iota_view<unsigned int, unsigned int>(
2975 0U, vertices_per_cell);
2976 }
2977
2978
2979
2980 template <int dim>
2981 inline Point<dim>
2982 GeometryInfo<dim>::unit_cell_vertex(const unsigned int)
2983 {
2984 DEAL_II_NOT_IMPLEMENTED();
2985
2986 return {};
2987 }
2988
2989
2990
2991 template <>
2992 inline unsigned int
2993 GeometryInfo<1>::child_cell_from_point(const Point<1> &p)
2994 {
2995 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2996
2997 return (p[0] <= 0.5 ? 0 : 1);
2998 }
2999
3000
3001
3002 template <>
3003 inline unsigned int
3004 GeometryInfo<2>::child_cell_from_point(const Point<2> &p)
3005 {
3006 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
3007 Assert((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
3008
3009 return (p[0] <= 0.5 ? (p[1] <= 0.5 ? 0 : 2) : (p[1] <= 0.5 ? 1 : 3));
3010 }
3011
3012
3013
3014 template <>
3015 inline unsigned int
3016 GeometryInfo<3>::child_cell_from_point(const Point<3> &p)
3017 {
3018 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
3019 Assert((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
3020 Assert((p[2] >= 0) && (p[2] <= 1), ExcInvalidCoordinate(p[2]));
3021
3022 return (p[0] <= 0.5 ?
3023 (p[1] <= 0.5 ? (p[2] <= 0.5 ? 0 : 4) : (p[2] <= 0.5 ? 2 : 6)) :
3024 (p[1] <= 0.5 ? (p[2] <= 0.5 ? 1 : 5) : (p[2] <= 0.5 ? 3 : 7)));
3025 }
3026
3027
3028 template <int dim>
3029 inline unsigned int
3030 GeometryInfo<dim>::child_cell_from_point(const Point<dim> &)
3031 {
3032 DEAL_II_NOT_IMPLEMENTED();
3033
3034 return 0;
3035 }
3036
3037
3038
3039 template <>
3040 inline Point<1>
3041 GeometryInfo<1>::cell_to_child_coordinates(const Point<1> &p,
3042 const unsigned int child_index,
3043 const RefinementCase<1> refine_case)
3044
3045 {
3046 AssertIndexRange(child_index, 2);
3047 Assert(refine_case == RefinementCase<1>::cut_x, ExcInternalError());
3048 (void)refine_case; // removes -Wunused-parameter warning in optimized mode
3049
3050 return Point<1>(p * 2.0 - unit_cell_vertex(child_index));
3051 }
3052
3053
3054
3055 template <>
3056 inline Point<2>
3057 GeometryInfo<2>::cell_to_child_coordinates(const Point<2> &p,
3058 const unsigned int child_index,
3059 const RefinementCase<2> refine_case)
3060
3061 {
3062 AssertIndexRange(child_index, GeometryInfo<2>::n_children(refine_case));
3063
3064 Point<2> point = p;
3065 switch (refine_case)
3066 {
3067 case RefinementCase<2>::cut_x:
3068 point[0] *= 2.0;
3069 if (child_index == 1)
3070 point[0] -= 1.0;
3071 break;
3072 case RefinementCase<2>::cut_y:
3073 point[1] *= 2.0;
3074 if (child_index == 1)
3075 point[1] -= 1.0;
3076 break;
3077 case RefinementCase<2>::cut_xy:
3078 point *= 2.0;
3079 point -= unit_cell_vertex(child_index);
3080 break;
3081 default:
3082 DEAL_II_ASSERT_UNREACHABLE();
3083 }
3084
3085 return point;
3086 }
3087
3088
3089
3090 template <>
3091 inline Point<3>
3092 GeometryInfo<3>::cell_to_child_coordinates(const Point<3> &p,
3093 const unsigned int child_index,
3094 const RefinementCase<3> refine_case)
3095
3096 {
3097 AssertIndexRange(child_index, GeometryInfo<3>::n_children(refine_case));
3098
3099 Point<3> point = p;
3100 // there might be a cleverer way to do
3101 // this, but since this function is called
3102 // in very few places for initialization
3103 // purposes only, I don't care at the
3104 // moment
3105 switch (refine_case)
3106 {
3107 case RefinementCase<3>::cut_x:
3108 point[0] *= 2.0;
3109 if (child_index == 1)
3110 point[0] -= 1.0;
3111 break;
3112 case RefinementCase<3>::cut_y:
3113 point[1] *= 2.0;
3114 if (child_index == 1)
3115 point[1] -= 1.0;
3116 break;
3117 case RefinementCase<3>::cut_z:
3118 point[2] *= 2.0;
3119 if (child_index == 1)
3120 point[2] -= 1.0;
3121 break;
3122 case RefinementCase<3>::cut_xy:
3123 point[0] *= 2.0;
3124 point[1] *= 2.0;
3125 if (child_index % 2 == 1)
3126 point[0] -= 1.0;
3127 if (child_index / 2 == 1)
3128 point[1] -= 1.0;
3129 break;
3130 case RefinementCase<3>::cut_xz:
3131 // careful, this is slightly
3132 // different from xy and yz due to
3133 // different internal numbering of
3134 // children!
3135 point[0] *= 2.0;
3136 point[2] *= 2.0;
3137 if (child_index / 2 == 1)
3138 point[0] -= 1.0;
3139 if (child_index % 2 == 1)
3140 point[2] -= 1.0;
3141 break;
3142 case RefinementCase<3>::cut_yz:
3143 point[1] *= 2.0;
3144 point[2] *= 2.0;
3145 if (child_index % 2 == 1)
3146 point[1] -= 1.0;
3147 if (child_index / 2 == 1)
3148 point[2] -= 1.0;
3149 break;
3150 case RefinementCase<3>::cut_xyz:
3151 point *= 2.0;
3152 point -= unit_cell_vertex(child_index);
3153 break;
3154 default:
3155 DEAL_II_ASSERT_UNREACHABLE();
3156 }
3157
3158 return point;
3159 }
3160
3161
3162
3163 template <int dim>
3164 inline Point<dim>
3165 GeometryInfo<dim>::cell_to_child_coordinates(
3166 const Point<dim> & /*p*/,
3167 const unsigned int /*child_index*/,
3168 const RefinementCase<dim> /*refine_case*/)
3169
3170 {
3171 DEAL_II_NOT_IMPLEMENTED();
3172 return {};
3173 }
3174
3175
3176
3177 template <>
3178 inline Point<1>
3179 GeometryInfo<1>::child_to_cell_coordinates(const Point<1> &p,
3180 const unsigned int child_index,
3181 const RefinementCase<1> refine_case)
3182
3183 {
3184 AssertIndexRange(child_index, 2);
3185 Assert(refine_case == RefinementCase<1>::cut_x, ExcInternalError());
3186 (void)refine_case; // removes -Wunused-parameter warning in optimized mode
3187
3188 return (p + unit_cell_vertex(child_index)) * 0.5;
3189 }
3190
3191
3192
3193 template <>
3194 inline Point<3>
3195 GeometryInfo<3>::child_to_cell_coordinates(const Point<3> &p,
3196 const unsigned int child_index,
3197 const RefinementCase<3> refine_case)
3198
3199 {
3200 AssertIndexRange(child_index, GeometryInfo<3>::n_children(refine_case));
3201
3202 Point<3> point = p;
3203 // there might be a cleverer way to do
3204 // this, but since this function is called
3205 // in very few places for initialization
3206 // purposes only, I don't care at the
3207 // moment
3208 switch (refine_case)
3209 {
3210 case RefinementCase<3>::cut_x:
3211 if (child_index == 1)
3212 point[0] += 1.0;
3213 point[0] *= 0.5;
3214 break;
3215 case RefinementCase<3>::cut_y:
3216 if (child_index == 1)
3217 point[1] += 1.0;
3218 point[1] *= 0.5;
3219 break;
3220 case RefinementCase<3>::cut_z:
3221 if (child_index == 1)
3222 point[2] += 1.0;
3223 point[2] *= 0.5;
3224 break;
3225 case RefinementCase<3>::cut_xy:
3226 if (child_index % 2 == 1)
3227 point[0] += 1.0;
3228 if (child_index / 2 == 1)
3229 point[1] += 1.0;
3230 point[0] *= 0.5;
3231 point[1] *= 0.5;
3232 break;
3233 case RefinementCase<3>::cut_xz:
3234 // careful, this is slightly
3235 // different from xy and yz due to
3236 // different internal numbering of
3237 // children!
3238 if (child_index / 2 == 1)
3239 point[0] += 1.0;
3240 if (child_index % 2 == 1)
3241 point[2] += 1.0;
3242 point[0] *= 0.5;
3243 point[2] *= 0.5;
3244 break;
3245 case RefinementCase<3>::cut_yz:
3246 if (child_index % 2 == 1)
3247 point[1] += 1.0;
3248 if (child_index / 2 == 1)
3249 point[2] += 1.0;
3250 point[1] *= 0.5;
3251 point[2] *= 0.5;
3252 break;
3253 case RefinementCase<3>::cut_xyz:
3254 point += unit_cell_vertex(child_index);
3255 point *= 0.5;
3256 break;
3257 default:
3258 DEAL_II_ASSERT_UNREACHABLE();
3259 }
3260
3261 return point;
3262 }
3263
3264
3265
3266 template <>
3267 inline Point<2>
3268 GeometryInfo<2>::child_to_cell_coordinates(const Point<2> &p,
3269 const unsigned int child_index,
3270 const RefinementCase<2> refine_case)
3271 {
3272 AssertIndexRange(child_index, GeometryInfo<2>::n_children(refine_case));
3273
3274 Point<2> point = p;
3275 switch (refine_case)
3276 {
3277 case RefinementCase<2>::cut_x:
3278 if (child_index == 1)
3279 point[0] += 1.0;
3280 point[0] *= 0.5;
3281 break;
3282 case RefinementCase<2>::cut_y:
3283 if (child_index == 1)
3284 point[1] += 1.0;
3285 point[1] *= 0.5;
3286 break;
3287 case RefinementCase<2>::cut_xy:
3288 point += unit_cell_vertex(child_index);
3289 point *= 0.5;
3290 break;
3291 default:
3292 DEAL_II_ASSERT_UNREACHABLE();
3293 }
3294
3295 return point;
3296 }
3297
3298
3299
3300 template <int dim>
3301 inline Point<dim>
3302 GeometryInfo<dim>::child_to_cell_coordinates(
3303 const Point<dim> & /*p*/,
3304 const unsigned int /*child_index*/,
3305 const RefinementCase<dim> /*refine_case*/)
3306 {
3307 DEAL_II_NOT_IMPLEMENTED();
3308 return {};
3309 }
3310
3311
3312
3313 template <int dim>
3314 inline bool
3315 GeometryInfo<dim>::is_inside_unit_cell(const Point<dim> &)
3316 {
3317 DEAL_II_NOT_IMPLEMENTED();
3318 return false;
3319 }
3320
3321 template <>
3322 inline bool
3323 GeometryInfo<1>::is_inside_unit_cell(const Point<1> &p)
3324 {
3325 return (p[0] >= 0.) && (p[0] <= 1.);
3326 }
3327
3328
3329
3330 template <>
3331 inline bool
3332 GeometryInfo<2>::is_inside_unit_cell(const Point<2> &p)
3333 {
3334 return (p[0] >= 0.) && (p[0] <= 1.) && (p[1] >= 0.) && (p[1] <= 1.);
3335 }
3336
3337
3338
3339 template <>
3340 inline bool
3341 GeometryInfo<3>::is_inside_unit_cell(const Point<3> &p)
3342 {
3343 return (p[0] >= 0.) && (p[0] <= 1.) && (p[1] >= 0.) && (p[1] <= 1.) &&
3344 (p[2] >= 0.) && (p[2] <= 1.);
3345 }
3346
3347
3348
3349 template <int dim>
3350 inline bool
3351 GeometryInfo<dim>::is_inside_unit_cell(const Point<dim> &, const double)
3352 {
3353 DEAL_II_NOT_IMPLEMENTED();
3354 return false;
3355 }
3356
3357 template <>
3358 inline bool
3359 GeometryInfo<1>::is_inside_unit_cell(const Point<1> &p, const double eps)
3360 {
3361 return (p[0] >= -eps) && (p[0] <= 1. + eps);
3362 }
3363
3364
3365
3366 template <>
3367 inline bool
3368 GeometryInfo<2>::is_inside_unit_cell(const Point<2> &p, const double eps)
3369 {
3370 const double l = -eps, u = 1 + eps;
3371 return (p[0] >= l) && (p[0] <= u) && (p[1] >= l) && (p[1] <= u);
3372 }
3373
3374
3375
3376 template <>
3377 inline bool
3378 GeometryInfo<3>::is_inside_unit_cell(const Point<3> &p, const double eps)
3379 {
3380 const double l = -eps, u = 1.0 + eps;
3381 return (p[0] >= l) && (p[0] <= u) && (p[1] >= l) && (p[1] <= u) &&
3382 (p[2] >= l) && (p[2] <= u);
3383 }
3384
3385
3386
3387 template <>
3388 inline unsigned int
3389 GeometryInfo<1>::line_to_cell_vertices(const unsigned int line,
3390 const unsigned int vertex)
3391 {
3392 (void)line;
3393 AssertIndexRange(line, lines_per_cell);
3394 AssertIndexRange(vertex, 2);
3395
3396 return vertex;
3397 }
3398
3399
3400 template <>
3401 inline unsigned int
3402 GeometryInfo<2>::line_to_cell_vertices(const unsigned int line,
3403 const unsigned int vertex)
3404 {
3405 constexpr unsigned int cell_vertices[4][2] = {{0, 2}, {1, 3}, {0, 1}, {2, 3}};
3406 return cell_vertices[line][vertex];
3407 }
3408
3409
3410
3411 template <>
3412 inline unsigned int
3413 GeometryInfo<3>::line_to_cell_vertices(const unsigned int line,
3414 const unsigned int vertex)
3415 {
3416 AssertIndexRange(line, lines_per_cell);
3417 AssertIndexRange(vertex, 2);
3418
3419 constexpr unsigned vertices[lines_per_cell][2] = {{0, 2}, // bottom face
3420 {1, 3},
3421 {0, 1},
3422 {2, 3},
3423 {4, 6}, // top face
3424 {5, 7},
3425 {4, 5},
3426 {6, 7},
3427 {0,
3428 4}, // connects of bottom
3429 {1, 5}, // top face
3430 {2, 6},
3431 {3, 7}};
3432 return vertices[line][vertex];
3433 }
3434
3435
3436 template <>
3437 inline unsigned int
3438 GeometryInfo<4>::line_to_cell_vertices(const unsigned int, const unsigned int)
3439 {
3440 DEAL_II_NOT_IMPLEMENTED();
3441 return numbers::invalid_unsigned_int;
3442 }
3443
3444 template <>
3445 inline unsigned int
3446 GeometryInfo<3>::standard_to_real_face_vertex(const unsigned int vertex,
3447 const bool face_orientation,
3448 const bool face_flip,
3449 const bool face_rotation)
3450 {
3451 AssertIndexRange(vertex, GeometryInfo<3>::vertices_per_face);
3452
3453 // set up a table to make sure that
3454 // we handle non-standard faces correctly
3455 //
3456 // so set up a table that for each vertex (of
3457 // a quad in standard position) describes
3458 // which vertex to take
3459 //
3460 // first index: four vertices 0...3
3461 //
3462 // second index: face_orientation; 0:
3463 // opposite normal, 1: standard
3464 //
3465 // third index: face_flip; 0: standard, 1:
3466 // face rotated by 180 degrees
3467 //
3468 // forth index: face_rotation: 0: standard,
3469 // 1: face rotated by 90 degrees
3470
3471 constexpr unsigned int vertex_translation[4][2][2][2] = {
3472 {{{0, 2}, // vertex 0, face_orientation=false, face_flip=false,
3473 // face_rotation=false and true
3474 {3, 1}}, // vertex 0, face_orientation=false, face_flip=true,
3475 // face_rotation=false and true
3476 {{0, 2}, // vertex 0, face_orientation=true, face_flip=false,
3477 // face_rotation=false and true
3478 {3, 1}}}, // vertex 0, face_orientation=true, face_flip=true,
3479 // face_rotation=false and true
3480
3481 {{{2, 3}, // vertex 1 ...
3482 {1, 0}},
3483 {{1, 0}, {2, 3}}},
3484
3485 {{{1, 0}, // vertex 2 ...
3486 {2, 3}},
3487 {{2, 3}, {1, 0}}},
3488
3489 {{{3, 1}, // vertex 3 ...
3490 {0, 2}},
3491 {{3, 1}, {0, 2}}}};
3492
3493 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
3494 }
3495
3496
3497
3498 template <int dim>
3499 inline unsigned int
3500 GeometryInfo<dim>::standard_to_real_face_vertex(const unsigned int vertex,
3501 const bool,
3502 const bool,
3503 const bool)
3504 {
3505 Assert(dim > 1, ExcImpossibleInDim(dim));
3506 AssertIndexRange(vertex, GeometryInfo<dim>::vertices_per_face);
3507 return vertex;
3508 }
3509
3510 template <int dim>
3511 inline unsigned int
3512 GeometryInfo<dim>::n_children(const RefinementCase<dim> &ref_case)
3513 {
3514 constexpr unsigned int n_children[RefinementCase<3>::cut_xyz + 1] = {
3515 0, 2, 2, 4, 2, 4, 4, 8};
3516
3517 return n_children[ref_case];
3518 }
3519
3520
3521
3522 template <int dim>
3523 inline unsigned int
3524 GeometryInfo<dim>::n_subfaces(const internal::SubfaceCase<dim> &)
3525 {
3526 DEAL_II_NOT_IMPLEMENTED();
3527 return 0;
3528 }
3529
3530 template <>
3531 inline unsigned int
3532 GeometryInfo<1>::n_subfaces(const internal::SubfaceCase<1> &)
3533 {
3534 Assert(false, ExcImpossibleInDim(1));
3535 return 0;
3536 }
3537
3538 template <>
3539 inline unsigned int
3540 GeometryInfo<2>::n_subfaces(const internal::SubfaceCase<2> &subface_case)
3541 {
3542 return (subface_case == internal::SubfaceCase<2>::case_x) ? 2 : 0;
3543 }
3544
3545
3546
3547 template <>
3548 inline unsigned int
3549 GeometryInfo<3>::n_subfaces(const internal::SubfaceCase<3> &subface_case)
3550 {
3551 const unsigned int nsubs[internal::SubfaceCase<3>::case_isotropic + 1] = {
3552 0, 2, 3, 3, 4, 2, 3, 3, 4, 4};
3553 return nsubs[subface_case];
3554 }
3555
3556
3557
3558 template <int dim>
3559 inline double
3560 GeometryInfo<dim>::subface_ratio(const internal::SubfaceCase<dim> &,
3561 const unsigned int)
3562 {
3563 DEAL_II_NOT_IMPLEMENTED();
3564 return 0.;
3565 }
3566
3567 template <>
3568 inline double
3569 GeometryInfo<1>::subface_ratio(const internal::SubfaceCase<1> &,
3570 const unsigned int)
3571 {
3572 return 1;
3573 }
3574
3575
3576 template <>
3577 inline double
3578 GeometryInfo<2>::subface_ratio(const internal::SubfaceCase<2> &subface_case,
3579 const unsigned int)
3580 {
3581 double ratio = 1;
3582 switch (subface_case)
3583 {
3584 case internal::SubfaceCase<2>::case_none:
3585 // Here, an
3586 // Assert(false,ExcInternalError())
3587 // would be the right
3588 // choice, but
3589 // unfortunately the
3590 // current function is
3591 // also called for faces
3592 // without children (see
3593 // tests/fe/mapping.cc).
3594 // Assert(false, ExcMessage("Face has no subfaces."));
3595 // Furthermore, assign
3596 // following value as
3597 // otherwise the
3598 // bits/volume_x tests
3599 // break
3600 ratio = 1. / GeometryInfo<2>::max_children_per_face;
3601 break;
3602 case internal::SubfaceCase<2>::case_x:
3603 ratio = 0.5;
3604 break;
3605 default:
3606 // there should be no
3607 // cases left
3608 DEAL_II_ASSERT_UNREACHABLE();
3609 break;
3610 }
3611
3612 return ratio;
3613 }
3614
3615
3616 template <>
3617 inline double
3618 GeometryInfo<3>::subface_ratio(const internal::SubfaceCase<3> &subface_case,
3619 const unsigned int subface_no)
3620 {
3621 double ratio = 1;
3622 switch (subface_case)
3623 {
3624 case internal::SubfaceCase<3>::case_none:
3625 // Here, an
3626 // Assert(false,ExcInternalError())
3627 // would be the right
3628 // choice, but
3629 // unfortunately the
3630 // current function is
3631 // also called for faces
3632 // without children (see
3633 // tests/bits/mesh_3d_16.cc). Add
3634 // following switch to
3635 // avoid diffs in
3636 // tests/bits/mesh_3d_16
3637 ratio = 1. / GeometryInfo<3>::max_children_per_face;
3638 break;
3639 case internal::SubfaceCase<3>::case_x:
3640 case internal::SubfaceCase<3>::case_y:
3641 ratio = 0.5;
3642 break;
3643 case internal::SubfaceCase<3>::case_xy:
3644 case internal::SubfaceCase<3>::case_x1y2y:
3645 case internal::SubfaceCase<3>::case_y1x2x:
3646 ratio = 0.25;
3647 break;
3648 case internal::SubfaceCase<3>::case_x1y:
3649 case internal::SubfaceCase<3>::case_y1x:
3650 if (subface_no < 2)
3651 ratio = 0.25;
3652 else
3653 ratio = 0.5;
3654 break;
3655 case internal::SubfaceCase<3>::case_x2y:
3656 case internal::SubfaceCase<3>::case_y2x:
3657 if (subface_no == 0)
3658 ratio = 0.5;
3659 else
3660 ratio = 0.25;
3661 break;
3662 default:
3663 // there should be no
3664 // cases left
3665 DEAL_II_ASSERT_UNREACHABLE();
3666 break;
3667 }
3668
3669 return ratio;
3670 }
3671
3672
3673
3674 template <int dim>
3675 RefinementCase<dim - 1> inline GeometryInfo<dim>::face_refinement_case(
3676 const RefinementCase<dim> &,
3677 const unsigned int,
3678 const bool,
3679 const bool,
3680 const bool)
3681 {
3682 DEAL_II_NOT_IMPLEMENTED();
3683 return RefinementCase<dim - 1>::no_refinement;
3684 }
3685
3686 template <>
3687 RefinementCase<0> inline GeometryInfo<1>::face_refinement_case(
3688 const RefinementCase<1> &,
3689 const unsigned int,
3690 const bool,
3691 const bool,
3692 const bool)
3693 {
3694 Assert(false, ExcImpossibleInDim(1));
3695
3696 return RefinementCase<0>::no_refinement;
3697 }
3698
3699
3700 template <>
3701 inline RefinementCase<1>
3702 GeometryInfo<2>::face_refinement_case(
3703 const RefinementCase<2> &cell_refinement_case,
3704 const unsigned int face_no,
3705 const bool,
3706 const bool,
3707 const bool)
3708 {
3709 const unsigned int dim = 2;
3710 AssertIndexRange(cell_refinement_case,
3711 RefinementCase<dim>::isotropic_refinement + 1);
3712 AssertIndexRange(face_no, GeometryInfo<dim>::faces_per_cell);
3713
3714 // simple special case
3715 if (cell_refinement_case == RefinementCase<dim>::cut_xy)
3716 return RefinementCase<1>::cut_x;
3717
3718 const RefinementCase<dim - 1>
3719 ref_cases[RefinementCase<dim>::isotropic_refinement +
3720 1][GeometryInfo<dim>::faces_per_cell / 2] = {
3721 {RefinementCase<dim - 1>::no_refinement, // no_refinement
3722 RefinementCase<dim - 1>::no_refinement},
3723
3724 {RefinementCase<dim - 1>::no_refinement, RefinementCase<dim - 1>::cut_x},
3725
3726 {RefinementCase<dim - 1>::cut_x, RefinementCase<dim - 1>::no_refinement},
3727
3728 {RefinementCase<dim - 1>::cut_x, // cut_xy
3729 RefinementCase<dim - 1>::cut_x}};
3730
3731 return ref_cases[cell_refinement_case][face_no / 2];
3732 }
3733
3734
3735 template <>
3736 inline RefinementCase<2>
3737 GeometryInfo<3>::face_refinement_case(
3738 const RefinementCase<3> &cell_refinement_case,
3739 const unsigned int face_no,
3740 const bool face_orientation,
3741 const bool /*face_flip*/,
3742 const bool face_rotation)
3743 {
3744 const unsigned int dim = 3;
3745 AssertIndexRange(cell_refinement_case,
3746 RefinementCase<dim>::isotropic_refinement + 1);
3747 AssertIndexRange(face_no, GeometryInfo<dim>::faces_per_cell);
3748
3749 // simple special case
3750 if (cell_refinement_case == RefinementCase<dim>::cut_xyz)
3751 return RefinementCase<dim - 1>::cut_xy;
3752
3753 const RefinementCase<dim - 1>
3754 ref_cases[RefinementCase<dim>::isotropic_refinement + 1]
3755 [GeometryInfo<dim>::faces_per_cell / 2] = {
3756 {RefinementCase<dim - 1>::no_refinement, // no_refinement
3757 RefinementCase<dim - 1>::no_refinement,
3758 RefinementCase<dim - 1>::no_refinement},
3759
3760 {RefinementCase<dim - 1>::no_refinement, // cut_x
3761 RefinementCase<dim - 1>::cut_y,
3762 RefinementCase<dim - 1>::cut_x},
3763
3764 {RefinementCase<dim - 1>::cut_x, // cut_y
3765 RefinementCase<dim - 1>::no_refinement,
3766 RefinementCase<dim - 1>::cut_y},
3767
3768 {RefinementCase<dim - 1>::cut_x, // cut_xy
3769 RefinementCase<dim - 1>::cut_y,
3770 RefinementCase<dim - 1>::cut_xy},
3771
3772 {RefinementCase<dim - 1>::cut_y, // cut_z
3773 RefinementCase<dim - 1>::cut_x,
3774 RefinementCase<dim - 1>::no_refinement},
3775
3776 {RefinementCase<dim - 1>::cut_y, // cut_xz
3777 RefinementCase<dim - 1>::cut_xy,
3778 RefinementCase<dim - 1>::cut_x},
3779
3780 {RefinementCase<dim - 1>::cut_xy, // cut_yz
3781 RefinementCase<dim - 1>::cut_x,
3782 RefinementCase<dim - 1>::cut_y},
3783
3784 {RefinementCase<dim - 1>::cut_xy, // cut_xyz
3785 RefinementCase<dim - 1>::cut_xy,
3786 RefinementCase<dim - 1>::cut_xy},
3787 };
3788
3789 const RefinementCase<dim - 1> ref_case =
3790 ref_cases[cell_refinement_case][face_no / 2];
3791
3792 const RefinementCase<dim - 1> flip[4] = {
3793 RefinementCase<dim - 1>::no_refinement,
3794 RefinementCase<dim - 1>::cut_y,
3795 RefinementCase<dim - 1>::cut_x,
3796 RefinementCase<dim - 1>::cut_xy};
3797
3798 // correct the ref_case for face_orientation
3799 // and face_rotation. for face_orientation,
3800 // 'true' is the default value whereas for
3801 // face_rotation, 'false' is standard. If
3802 // <tt>face_rotation==face_orientation</tt>,
3803 // then one of them is non-standard and we
3804 // have to swap cut_x and cut_y, otherwise no
3805 // change is necessary. face_flip has no
3806 // influence. however, in order to keep the
3807 // interface consistent with other functions,
3808 // we still include it as an argument to this
3809 // function
3810 return (face_orientation == face_rotation) ? flip[ref_case] : ref_case;
3811 }
3812
3813
3814
3815 template <int dim>
3816 inline RefinementCase<1>
3817 GeometryInfo<dim>::line_refinement_case(const RefinementCase<dim> &,
3818 const unsigned int)
3819 {
3820 DEAL_II_NOT_IMPLEMENTED();
3821 return RefinementCase<1>::no_refinement;
3822 }
3823
3824 template <>
3825 inline RefinementCase<1>
3826 GeometryInfo<1>::line_refinement_case(
3827 const RefinementCase<1> &cell_refinement_case,
3828 const unsigned int line_no)
3829 {
3830 (void)line_no;
3831 const unsigned int dim = 1;
3832 (void)dim;
3833 AssertIndexRange(cell_refinement_case,
3834 RefinementCase<dim>::isotropic_refinement + 1);
3835 AssertIndexRange(line_no, GeometryInfo<dim>::lines_per_cell);
3836
3837 return cell_refinement_case;
3838 }
3839
3840
3841 template <>
3842 inline RefinementCase<1>
3843 GeometryInfo<2>::line_refinement_case(
3844 const RefinementCase<2> &cell_refinement_case,
3845 const unsigned int line_no)
3846 {
3847 // Assertions are in face_refinement_case()
3848 return face_refinement_case(cell_refinement_case, line_no);
3849 }
3850
3851
3852 template <>
3853 inline RefinementCase<1>
3854 GeometryInfo<3>::line_refinement_case(
3855 const RefinementCase<3> &cell_refinement_case,
3856 const unsigned int line_no)
3857 {
3858 const unsigned int dim = 3;
3859 AssertIndexRange(cell_refinement_case,
3860 RefinementCase<dim>::isotropic_refinement + 1);
3861 AssertIndexRange(line_no, GeometryInfo<dim>::lines_per_cell);
3862
3863 // simple special case
3864 if (cell_refinement_case == RefinementCase<dim>::cut_xyz)
3865 return RefinementCase<1>::cut_x;
3866
3867 // array indicating, which simple refine
3868 // case cuts a line in direction x, y or
3869 // z. For example, cut_y and everything
3870 // containing cut_y (cut_xy, cut_yz,
3871 // cut_xyz) cuts lines, which are in y
3872 // direction.
3873 const RefinementCase<dim> cut_one[dim] = {RefinementCase<dim>::cut_x,
3874 RefinementCase<dim>::cut_y,
3875 RefinementCase<dim>::cut_z};
3876
3877 // order the direction of lines
3878 // 0->x, 1->y, 2->z
3879 const unsigned int direction[lines_per_cell] = {
3880 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2, 2};
3881
3882 return ((cell_refinement_case & cut_one[direction[line_no]]) ?
3883 RefinementCase<1>::cut_x :
3884 RefinementCase<1>::no_refinement);
3885 }
3886
3887
3888
3889 template <int dim>
3890 inline RefinementCase<dim>
3891 GeometryInfo<dim>::min_cell_refinement_case_for_face_refinement(
3892 const RefinementCase<dim - 1> &,
3893 const unsigned int,
3894 const bool,
3895 const bool,
3896 const bool)
3897 {
3898 DEAL_II_NOT_IMPLEMENTED();
3899
3900 return RefinementCase<dim>::no_refinement;
3901 }
3902
3903 template <>
3904 inline RefinementCase<1>
3905 GeometryInfo<1>::min_cell_refinement_case_for_face_refinement(
3906 const RefinementCase<0> &,
3907 const unsigned int,
3908 const bool,
3909 const bool,
3910 const bool)
3911 {
3912 const unsigned int dim = 1;
3913 Assert(false, ExcImpossibleInDim(dim));
3914
3915 return RefinementCase<dim>::no_refinement;
3916 }
3917
3918
3919 template <>
3920 inline RefinementCase<2>
3921 GeometryInfo<2>::min_cell_refinement_case_for_face_refinement(
3922 const RefinementCase<1> &face_refinement_case,
3923 const unsigned int face_no,
3924 const bool,
3925 const bool,
3926 const bool)
3927 {
3928 const unsigned int dim = 2;
3929 AssertIndexRange(face_refinement_case,
3930 RefinementCase<dim - 1>::isotropic_refinement + 1);
3931 AssertIndexRange(face_no, GeometryInfo<dim>::faces_per_cell);
3932
3933 if (face_refinement_case == RefinementCase<dim>::cut_x)
3934 return (face_no / 2) != 0u ? RefinementCase<dim>::cut_x :
3935 RefinementCase<dim>::cut_y;
3936 else
3937 return RefinementCase<dim>::no_refinement;
3938 }
3939
3940
3941 template <>
3942 inline RefinementCase<3>
3943 GeometryInfo<3>::min_cell_refinement_case_for_face_refinement(
3944 const RefinementCase<2> &face_refinement_case,
3945 const unsigned int face_no,
3946 const bool face_orientation,
3947 const bool /*face_flip*/,
3948 const bool face_rotation)
3949 {
3950 const unsigned int dim = 3;
3951 AssertIndexRange(face_refinement_case,
3952 RefinementCase<dim - 1>::isotropic_refinement + 1);
3953 AssertIndexRange(face_no, GeometryInfo<dim>::faces_per_cell);
3954
3955 const RefinementCase<2> flip[4] = {RefinementCase<2>::no_refinement,
3956 RefinementCase<2>::cut_y,
3957 RefinementCase<2>::cut_x,
3958 RefinementCase<2>::cut_xy};
3959
3960 // correct the face_refinement_case for
3961 // face_orientation and face_rotation. for
3962 // face_orientation, 'true' is the default
3963 // value whereas for face_rotation, 'false'
3964 // is standard. If
3965 // <tt>face_rotation==face_orientation</tt>,
3966 // then one of them is non-standard and we
3967 // have to swap cut_x and cut_y, otherwise no
3968 // change is necessary. face_flip has no
3969 // influence. however, in order to keep the
3970 // interface consistent with other functions,
3971 // we still include it as an argument to this
3972 // function
3973 const RefinementCase<dim - 1> std_face_ref =
3974 (face_orientation == face_rotation) ? flip[face_refinement_case] :
3975 face_refinement_case;
3976
3977 const RefinementCase<dim> face_to_cell[3][4] = {
3978 {RefinementCase<dim>::no_refinement, // faces 0 and 1
3979 RefinementCase<dim>::cut_y, // cut_x in face 0 means cut_y for the cell
3980 RefinementCase<dim>::cut_z,
3981 RefinementCase<dim>::cut_yz},
3982
3983 {RefinementCase<dim>::no_refinement, // faces 2 and 3 (note that x and y are
3984 // "exchanged on faces 2 and 3")
3985 RefinementCase<dim>::cut_z,
3986 RefinementCase<dim>::cut_x,
3987 RefinementCase<dim>::cut_xz},
3988
3989 {RefinementCase<dim>::no_refinement, // faces 4 and 5
3990 RefinementCase<dim>::cut_x,
3991 RefinementCase<dim>::cut_y,
3992 RefinementCase<dim>::cut_xy}};
3993
3994 return face_to_cell[face_no / 2][std_face_ref];
3995 }
3996
3997
3998
3999 template <int dim>
4000 inline RefinementCase<dim>
4001 GeometryInfo<dim>::min_cell_refinement_case_for_line_refinement(
4002 const unsigned int)
4003 {
4004 DEAL_II_NOT_IMPLEMENTED();
4005
4006 return RefinementCase<dim>::no_refinement;
4007 }
4008
4009 template <>
4010 inline RefinementCase<1>
4011 GeometryInfo<1>::min_cell_refinement_case_for_line_refinement(
4012 const unsigned int line_no)
4013 {
4014 (void)line_no;
4015 AssertIndexRange(line_no, 1);
4016
4017 return RefinementCase<1>::cut_x;
4018 }
4019
4020
4021 template <>
4022 inline RefinementCase<2>
4023 GeometryInfo<2>::min_cell_refinement_case_for_line_refinement(
4024 const unsigned int line_no)
4025 {
4026 const unsigned int dim = 2;
4027 (void)dim;
4028 AssertIndexRange(line_no, GeometryInfo<dim>::lines_per_cell);
4029
4030 return (line_no / 2) != 0u ? RefinementCase<2>::cut_x :
4031 RefinementCase<2>::cut_y;
4032 }
4033
4034
4035 template <>
4036 inline RefinementCase<3>
4037 GeometryInfo<3>::min_cell_refinement_case_for_line_refinement(
4038 const unsigned int line_no)
4039 {
4040 const unsigned int dim = 3;
4041 AssertIndexRange(line_no, GeometryInfo<dim>::lines_per_cell);
4042
4043 const RefinementCase<dim> ref_cases[6] = {
4044 RefinementCase<dim>::cut_y, // lines 0 and 1
4045 RefinementCase<dim>::cut_x, // lines 2 and 3
4046 RefinementCase<dim>::cut_y, // lines 4 and 5
4047 RefinementCase<dim>::cut_x, // lines 6 and 7
4048 RefinementCase<dim>::cut_z, // lines 8 and 9
4049 RefinementCase<dim>::cut_z}; // lines 10 and 11
4050
4051 return ref_cases[line_no / 2];
4052 }
4053
4054
4055
4056 template <>
4057 inline unsigned int
4058 GeometryInfo<3>::real_to_standard_face_vertex(const unsigned int vertex,
4059 const bool face_orientation,
4060 const bool face_flip,
4061 const bool face_rotation)
4062 {
4063 AssertIndexRange(vertex, GeometryInfo<3>::vertices_per_face);
4064
4065 // set up a table to make sure that
4066 // we handle non-standard faces correctly
4067 //
4068 // so set up a table that for each vertex (of
4069 // a quad in standard position) describes
4070 // which vertex to take
4071 //
4072 // first index: four vertices 0...3
4073 //
4074 // second index: face_orientation; 0:
4075 // opposite normal, 1: standard
4076 //
4077 // third index: face_flip; 0: standard, 1:
4078 // face rotated by 180 degrees
4079 //
4080 // forth index: face_rotation: 0: standard,
4081 // 1: face rotated by 90 degrees
4082
4083 const unsigned int vertex_translation[4][2][2][2] = {
4084 {{{0, 2}, // vertex 0, face_orientation=false, face_flip=false,
4085 // face_rotation=false and true
4086 {3, 1}}, // vertex 0, face_orientation=false, face_flip=true,
4087 // face_rotation=false and true
4088 {{0, 1}, // vertex 0, face_orientation=true, face_flip=false,
4089 // face_rotation=false and true
4090 {3, 2}}}, // vertex 0, face_orientation=true, face_flip=true,
4091 // face_rotation=false and true
4092
4093 {{{2, 3}, // vertex 1 ...
4094 {1, 0}},
4095 {{1, 3}, {2, 0}}},
4096
4097 {{{1, 0}, // vertex 2 ...
4098 {2, 3}},
4099 {{2, 0}, {1, 3}}},
4100
4101 {{{3, 1}, // vertex 3 ...
4102 {0, 2}},
4103 {{3, 2}, {0, 1}}}};
4104
4105 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
4106 }
4107
4108
4109
4110 template <int dim>
4111 inline unsigned int
4112 GeometryInfo<dim>::real_to_standard_face_vertex(const unsigned int vertex,
4113 const bool,
4114 const bool,
4115 const bool)
4116 {
4117 Assert(dim > 1, ExcImpossibleInDim(dim));
4118 AssertIndexRange(vertex, GeometryInfo<dim>::vertices_per_face);
4119 return vertex;
4120 }
4121
4122
4123
4124 template <>
4125 inline unsigned int
4126 GeometryInfo<3>::standard_to_real_face_line(const unsigned int line,
4127 const bool face_orientation,
4128 const bool face_flip,
4129 const bool face_rotation)
4130 {
4131 AssertIndexRange(line, GeometryInfo<3>::lines_per_face);
4132
4133
4134 // make sure we handle
4135 // non-standard faces correctly
4136 //
4137 // so set up a table that for each line (of a
4138 // quad) describes which line to take
4139 //
4140 // first index: four lines 0...3
4141 //
4142 // second index: face_orientation; 0:
4143 // opposite normal, 1: standard
4144 //
4145 // third index: face_flip; 0: standard, 1:
4146 // face rotated by 180 degrees
4147 //
4148 // forth index: face_rotation: 0: standard,
4149 // 1: face rotated by 90 degrees
4150
4151 const unsigned int line_translation[4][2][2][2] = {
4152 {{{2, 0}, // line 0, face_orientation=false, face_flip=false,
4153 // face_rotation=false and true
4154 {3, 1}}, // line 0, face_orientation=false, face_flip=true,
4155 // face_rotation=false and true
4156 {{0, 3}, // line 0, face_orientation=true, face_flip=false,
4157 // face_rotation=false and true
4158 {1, 2}}}, // line 0, face_orientation=true, face_flip=true,
4159 // face_rotation=false and true
4160
4161 {{{3, 1}, // line 1 ...
4162 {2, 0}},
4163 {{1, 2}, {0, 3}}},
4164
4165 {{{0, 3}, // line 2 ...
4166 {1, 2}},
4167 {{2, 0}, {3, 1}}},
4168
4169 {{{1, 2}, // line 3 ...
4170 {0, 3}},
4171 {{3, 1}, {2, 0}}}};
4172
4173 return line_translation[line][face_orientation][face_flip][face_rotation];
4174 }
4175
4176
4177
4178 template <int dim>
4179 inline unsigned int
4180 GeometryInfo<dim>::standard_to_real_face_line(const unsigned int line,
4181 const bool,
4182 const bool,
4183 const bool)
4184 {
4185 DEAL_II_NOT_IMPLEMENTED();
4186 return line;
4187 }
4188
4189
4190
4191 template <>
4192 inline unsigned int
4193 GeometryInfo<2>::standard_to_real_line_vertex(const unsigned int vertex,
4194 const bool line_orientation)
4195 {
4196 return line_orientation ? vertex : (1 - vertex);
4197 }
4198
4199
4200
4201 template <int dim>
4202 inline unsigned int
4203 GeometryInfo<dim>::standard_to_real_line_vertex(const unsigned int vertex,
4204 const bool)
4205 {
4206 DEAL_II_NOT_IMPLEMENTED();
4207 return vertex;
4208 }
4209
4210
4211
4212 template <>
4213 inline std::array<unsigned int, 2>
4214 GeometryInfo<2>::standard_quad_vertex_to_line_vertex_index(
4215 const unsigned int vertex)
4216 {
4217 return {{vertex % 2, vertex / 2}};
4218 }
4219
4220
4221
4222 template <int dim>
4223 inline std::array<unsigned int, 2>
4224 GeometryInfo<dim>::standard_quad_vertex_to_line_vertex_index(
4225 const unsigned int vertex)
4226 {
4227 DEAL_II_NOT_IMPLEMENTED();
4228 (void)vertex;
4229 return {{0, 0}};
4230 }
4231
4232
4233
4234 template <>
4235 inline std::array<unsigned int, 2>
4236 GeometryInfo<3>::standard_hex_line_to_quad_line_index(const unsigned int i)
4237 {
4238 // set up a table that for each
4239 // line describes a) from which
4240 // quad to take it, b) which line
4241 // therein it is if the face is
4242 // oriented correctly
4243 static const unsigned int lookup_table[GeometryInfo<3>::lines_per_cell][2] = {
4244 {4, 0}, // take first four lines from bottom face
4245 {4, 1},
4246 {4, 2},
4247 {4, 3},
4248
4249 {5, 0}, // second four lines from top face
4250 {5, 1},
4251 {5, 2},
4252 {5, 3},
4253
4254 {0, 0}, // the rest randomly
4255 {1, 0},
4256 {0, 1},
4257 {1, 1}};
4258
4259 return {{lookup_table[i][0], lookup_table[i][1]}};
4260 }
4261
4262
4263
4264 template <int dim>
4265 inline std::array<unsigned int, 2>
4266 GeometryInfo<dim>::standard_hex_line_to_quad_line_index(const unsigned int line)
4267 {
4268 DEAL_II_NOT_IMPLEMENTED();
4269 (void)line;
4270 return {{0, 0}};
4271 }
4272
4273
4274
4275 template <>
4276 inline std::array<unsigned int, 2>
4277 GeometryInfo<3>::standard_hex_vertex_to_quad_vertex_index(
4278 const unsigned int vertex)
4279 {
4280 // get the corner indices by asking either the bottom or the top face for its
4281 // vertices. handle non-standard faces by calling the vertex reordering
4282 // function from GeometryInfo
4283
4284 // bottom face (4) for first four vertices, top face (5) for the rest
4285 return {{4 + vertex / 4, vertex % 4}};
4286 }
4287
4288
4289
4290 template <int dim>
4291 inline std::array<unsigned int, 2>
4292 GeometryInfo<dim>::standard_hex_vertex_to_quad_vertex_index(
4293 const unsigned int vertex)
4294 {
4295 DEAL_II_NOT_IMPLEMENTED();
4296 (void)vertex;
4297 return {{0, 0}};
4298 }
4299
4300
4301
4302 template <>
4303 inline unsigned int
4304 GeometryInfo<3>::real_to_standard_face_line(const unsigned int line,
4305 const bool face_orientation,
4306 const bool face_flip,
4307 const bool face_rotation)
4308 {
4309 AssertIndexRange(line, GeometryInfo<3>::lines_per_face);
4310
4311
4312 // make sure we handle
4313 // non-standard faces correctly
4314 //
4315 // so set up a table that for each line (of a
4316 // quad) describes which line to take
4317 //
4318 // first index: four lines 0...3
4319 //
4320 // second index: face_orientation; 0:
4321 // opposite normal, 1: standard
4322 //
4323 // third index: face_flip; 0: standard, 1:
4324 // face rotated by 180 degrees
4325 //
4326 // forth index: face_rotation: 0: standard,
4327 // 1: face rotated by 90 degrees
4328
4329 const unsigned int line_translation[4][2][2][2] = {
4330 {{{2, 0}, // line 0, face_orientation=false, face_flip=false,
4331 // face_rotation=false and true
4332 {3, 1}}, // line 0, face_orientation=false, face_flip=true,
4333 // face_rotation=false and true
4334 {{0, 2}, // line 0, face_orientation=true, face_flip=false,
4335 // face_rotation=false and true
4336 {1, 3}}}, // line 0, face_orientation=true, face_flip=true,
4337 // face_rotation=false and true
4338
4339 {{{3, 1}, // line 1 ...
4340 {2, 0}},
4341 {{1, 3}, {0, 2}}},
4342
4343 {{{0, 3}, // line 2 ...
4344 {1, 2}},
4345 {{2, 1}, {3, 0}}},
4346
4347 {{{1, 2}, // line 3 ...
4348 {0, 3}},
4349 {{3, 0}, {2, 1}}}};
4350
4351 return line_translation[line][face_orientation][face_flip][face_rotation];
4352 }
4353
4354
4355
4356 template <int dim>
4357 inline unsigned int
4358 GeometryInfo<dim>::real_to_standard_face_line(const unsigned int line,
4359 const bool,
4360 const bool,
4361 const bool)
4362 {
4363 DEAL_II_NOT_IMPLEMENTED();
4364 return line;
4365 }
4366
4367
4368
4369 template <>
4370 inline unsigned int
4371 GeometryInfo<1>::child_cell_on_face(const RefinementCase<1> &,
4372 const unsigned int face,
4373 const unsigned int subface,
4374 const bool,
4375 const bool,
4376 const bool,
4377 const RefinementCase<0> &)
4378 {
4379 (void)subface;
4380 AssertIndexRange(face, faces_per_cell);
4381 AssertIndexRange(subface, max_children_per_face);
4382
4383 return face;
4384 }
4385
4386
4387
4388 template <>
4389 inline unsigned int
4390 GeometryInfo<2>::child_cell_on_face(const RefinementCase<2> &ref_case,
4391 const unsigned int face,
4392 const unsigned int subface,
4393 const bool face_orientation,
4394 const bool /*face_flip*/,
4395 const bool /*face_rotation*/,
4396 const RefinementCase<1> &)
4397 {
4398 AssertIndexRange(face, faces_per_cell);
4399 AssertIndexRange(subface, max_children_per_face);
4400
4401 // always return the child adjacent to the specified
4402 // subface. if the face of a cell is not refined, don't
4403 // throw an assertion but deliver the child adjacent to
4404 // the face nevertheless, i.e. deliver the child of
4405 // this cell adjacent to the subface of a possibly
4406 // refined neighbor. this simplifies setting neighbor
4407 // information in execute_refinement.
4408 constexpr unsigned int
4409 subcells[/* possible face orientation */ 2]
4410 [/* number of different ways to refine a cell */ 4]
4411 [/* faces_per_cell */ 4][/* max_children_per_face */ 2] = {
4412 {
4413 // Flipped orientation (face_orientation = false)
4414 {{0, 0}, {1, 1}, {1, 0}, {1, 0}}, // cut_x
4415 {{1, 0}, {1, 0}, {0, 0}, {1, 1}}, // cut_y
4416 {{2, 0}, {3, 1}, {1, 0}, {3, 2}} // cut_xy, i.e., isotropic
4417 },
4418 {
4419 // Normal orientation (face_orientation = true)
4420 {{0, 0}, {1, 1}, {0, 1}, {0, 1}}, // cut_x
4421 {{0, 1}, {0, 1}, {0, 0}, {1, 1}}, // cut_y
4422 {{0, 2}, {1, 3}, {0, 1}, {2, 3}} // cut_xy, i.e., isotropic
4423 }};
4424
4425 return subcells[face_orientation][ref_case - 1][face][subface];
4426 }
4427
4428
4429
4430 template <>
4431 inline unsigned int
4432 GeometryInfo<3>::child_cell_on_face(const RefinementCase<3> &ref_case,
4433 const unsigned int face,
4434 const unsigned int subface,
4435 const bool face_orientation,
4436 const bool face_flip,
4437 const bool face_rotation,
4438 const RefinementCase<2> &face_ref_case)
4439 {
4440 const unsigned int dim = 3;
4441
4442 Assert(ref_case > RefinementCase<dim - 1>::no_refinement,
4443 ExcMessage("Cell has no children."));
4444 AssertIndexRange(face, faces_per_cell);
4445 if (!(subface == 0 &&
4446 face_ref_case == RefinementCase<dim - 1>::no_refinement))
4447 {
4448 AssertIndexRange(subface,
4449 GeometryInfo<dim - 1>::n_children(face_ref_case));
4450 }
4451
4452 // invalid number used for invalid cases,
4453 // e.g. when the children are more refined at
4454 // a given face than the face itself
4455 const unsigned int e = numbers::invalid_unsigned_int;
4456
4457 // the whole process of finding a child cell
4458 // at a given subface considering the
4459 // possibly anisotropic refinement cases of
4460 // the cell and the face as well as
4461 // orientation, flip and rotation of the face
4462 // is quite complicated. thus, we break it
4463 // down into several steps.
4464
4465 // first step: convert the given face refine
4466 // case to a face refine case concerning the
4467 // face in standard orientation (, flip and
4468 // rotation). This only affects cut_x and
4469 // cut_y
4470 const RefinementCase<dim - 1> flip[4] = {
4471 RefinementCase<dim - 1>::no_refinement,
4472 RefinementCase<dim - 1>::cut_y,
4473 RefinementCase<dim - 1>::cut_x,
4474 RefinementCase<dim - 1>::cut_xy};
4475 // for face_orientation, 'true' is the
4476 // default value whereas for face_rotation,
4477 // 'false' is standard. If
4478 // <tt>face_rotation==face_orientation</tt>,
4479 // then one of them is non-standard and we
4480 // have to swap cut_x and cut_y, otherwise no
4481 // change is necessary.
4482 const RefinementCase<dim - 1> std_face_ref =
4483 (face_orientation == face_rotation) ? flip[face_ref_case] : face_ref_case;
4484
4485 // second step: convert the given subface
4486 // index to the one for a standard face
4487 // respecting face_orientation, face_flip and
4488 // face_rotation
4489
4490 // first index: face_ref_case
4491 // second index: face_orientation
4492 // third index: face_flip
4493 // forth index: face_rotation
4494 // fifth index: subface index
4495 const unsigned int subface_exchange[4][2][2][2][4] = {
4496 // no_refinement (subface 0 stays 0,
4497 // all others are invalid)
4498 {{{{0, e, e, e}, {0, e, e, e}}, {{0, e, e, e}, {0, e, e, e}}},
4499 {{{0, e, e, e}, {0, e, e, e}}, {{0, e, e, e}, {0, e, e, e}}}},
4500 // cut_x (here, if the face is only
4501 // rotated OR only falsely oriented,
4502 // then subface 0 of the non-standard
4503 // face does NOT correspond to one of
4504 // the subfaces of a standard
4505 // face. Thus we indicate the subface
4506 // which is located at the lower left
4507 // corner (the origin of the face's
4508 // local coordinate system) with
4509 // '0'. The rest of this issue is
4510 // taken care of using the above
4511 // conversion to a 'standard face
4512 // refine case')
4513 {{{{0, 1, e, e}, {0, 1, e, e}}, {{1, 0, e, e}, {1, 0, e, e}}},
4514 {{{0, 1, e, e}, {0, 1, e, e}}, {{1, 0, e, e}, {1, 0, e, e}}}},
4515 // cut_y (the same applies as for
4516 // cut_x)
4517 {{{{0, 1, e, e}, {1, 0, e, e}}, {{1, 0, e, e}, {0, 1, e, e}}},
4518 {{{0, 1, e, e}, {1, 0, e, e}}, {{1, 0, e, e}, {0, 1, e, e}}}},
4519 // cut_xyz: this information is
4520 // identical to the information
4521 // returned by
4522 // GeometryInfo<3>::real_to_standard_face_vertex()
4523 {{{{0, 2, 1, 3}, // face_orientation=false, face_flip=false,
4524 // face_rotation=false, subfaces 0,1,2,3
4525 {2, 3, 0, 1}}, // face_orientation=false, face_flip=false,
4526 // face_rotation=true, subfaces 0,1,2,3
4527 {{3, 1, 2, 0}, // face_orientation=false, face_flip=true,
4528 // face_rotation=false, subfaces 0,1,2,3
4529 {1, 0, 3, 2}}}, // face_orientation=false, face_flip=true,
4530 // face_rotation=true, subfaces 0,1,2,3
4531 {{{0, 1, 2, 3}, // face_orientation=true, face_flip=false,
4532 // face_rotation=false, subfaces 0,1,2,3
4533 {1, 3, 0, 2}}, // face_orientation=true, face_flip=false,
4534 // face_rotation=true, subfaces 0,1,2,3
4535 {{3, 2, 1, 0}, // face_orientation=true, face_flip=true,
4536 // face_rotation=false, subfaces 0,1,2,3
4537 {2, 0, 3, 1}}}}}; // face_orientation=true, face_flip=true,
4538 // face_rotation=true, subfaces 0,1,2,3
4539
4540 const unsigned int std_subface =
4541 subface_exchange[face_ref_case][face_orientation][face_flip][face_rotation]
4542 [subface];
4543 Assert(std_subface != e, ExcInternalError());
4544
4545 // third step: these are the children, which
4546 // can be found at the given subfaces of an
4547 // isotropically refined (standard) face
4548 //
4549 // first index: (refinement_case-1)
4550 // second index: face_index
4551 // third index: subface_index (isotropic refinement)
4552 const unsigned int iso_children[RefinementCase<dim>::cut_xyz][faces_per_cell]
4553 [max_children_per_face] = {
4554 // cut_x
4555 {{0, 0, 0, 0}, // face 0, subfaces 0,1,2,3
4556 {1, 1, 1, 1}, // face 1, subfaces 0,1,2,3
4557 {0, 0, 1, 1}, // face 2, subfaces 0,1,2,3
4558 {0, 0, 1, 1}, // face 3, subfaces 0,1,2,3
4559 {0, 1, 0, 1}, // face 4, subfaces 0,1,2,3
4560 {0, 1, 0, 1}}, // face 5, subfaces 0,1,2,3
4561 // cut_y
4562 {{0, 1, 0, 1},
4563 {0, 1, 0, 1},
4564 {0, 0, 0, 0},
4565 {1, 1, 1, 1},
4566 {0, 0, 1, 1},
4567 {0, 0, 1, 1}},
4568 // cut_xy
4569 {{0, 2, 0, 2},
4570 {1, 3, 1, 3},
4571 {0, 0, 1, 1},
4572 {2, 2, 3, 3},
4573 {0, 1, 2, 3},
4574 {0, 1, 2, 3}},
4575 // cut_z
4576 {{0, 0, 1, 1},
4577 {0, 0, 1, 1},
4578 {0, 1, 0, 1},
4579 {0, 1, 0, 1},
4580 {0, 0, 0, 0},
4581 {1, 1, 1, 1}},
4582 // cut_xz
4583 {{0, 0, 1, 1},
4584 {2, 2, 3, 3},
4585 {0, 1, 2, 3},
4586 {0, 1, 2, 3},
4587 {0, 2, 0, 2},
4588 {1, 3, 1, 3}},
4589 // cut_yz
4590 {{0, 1, 2, 3},
4591 {0, 1, 2, 3},
4592 {0, 2, 0, 2},
4593 {1, 3, 1, 3},
4594 {0, 0, 1, 1},
4595 {2, 2, 3, 3}},
4596 // cut_xyz
4597 {{0, 2, 4, 6},
4598 {1, 3, 5, 7},
4599 {0, 4, 1, 5},
4600 {2, 6, 3, 7},
4601 {0, 1, 2, 3},
4602 {4, 5, 6, 7}}};
4603
4604 // forth step: check, whether the given face
4605 // refine case is valid for the given cell
4606 // refine case. this is the case, if the
4607 // given face refine case is at least as
4608 // refined as the face is for the given cell
4609 // refine case
4610
4611 // note, that we are considering standard
4612 // face refinement cases here and thus must
4613 // not pass the given orientation, flip and
4614 // rotation flags
4615 if ((std_face_ref & face_refinement_case(ref_case, face)) ==
4616 face_refinement_case(ref_case, face))
4617 {
4618 // all is fine. for anisotropic face
4619 // refine cases, select one of the
4620 // isotropic subfaces which neighbors the
4621 // same child
4622
4623 // first index: (standard) face refine case
4624 // second index: subface index
4625 const unsigned int equivalent_iso_subface[4][4] = {
4626 {0, e, e, e}, // no_refinement
4627 {0, 3, e, e}, // cut_x
4628 {0, 3, e, e}, // cut_y
4629 {0, 1, 2, 3}}; // cut_xy
4630
4631 const unsigned int equ_std_subface =
4632 equivalent_iso_subface[std_face_ref][std_subface];
4633 Assert(equ_std_subface != e, ExcInternalError());
4634
4635 return iso_children[ref_case - 1][face][equ_std_subface];
4636 }
4637 else
4638 {
4639 // the face_ref_case was too coarse,
4640 // throw an error
4641 Assert(false,
4642 ExcMessage("The face RefineCase is too coarse "
4643 "for the given cell RefineCase."));
4644 }
4645 // we only get here in case of an error
4646 return e;
4647 }
4648
4649
4650
4651 template <>
4652 inline unsigned int
4653 GeometryInfo<4>::child_cell_on_face(const RefinementCase<4> &,
4654 const unsigned int,
4655 const unsigned int,
4656 const bool,
4657 const bool,
4658 const bool,
4659 const RefinementCase<3> &)
4660 {
4661 DEAL_II_NOT_IMPLEMENTED();
4662 return numbers::invalid_unsigned_int;
4663 }
4664
4665
4666
4667 template <>
4668 inline unsigned int
4669 GeometryInfo<2>::face_to_cell_lines(const unsigned int face,
4670 const unsigned int line,
4671 const bool,
4672 const bool,
4673 const bool)
4674 {
4675 (void)line;
4676 AssertIndexRange(face, faces_per_cell);
4677 AssertIndexRange(line, lines_per_face);
4678
4679 // The face is a line itself.
4680 return face;
4681 }
4682
4683
4684
4685 template <>
4686 inline unsigned int
4687 GeometryInfo<3>::face_to_cell_lines(const unsigned int face,
4688 const unsigned int line,
4689 const bool face_orientation,
4690 const bool face_flip,
4691 const bool face_rotation)
4692 {
4693 AssertIndexRange(face, faces_per_cell);
4694 AssertIndexRange(line, lines_per_face);
4695
4696 const unsigned lines[faces_per_cell][lines_per_face] = {
4697 {8, 10, 0, 4}, // left face
4698 {9, 11, 1, 5}, // right face
4699 {2, 6, 8, 9}, // front face
4700 {3, 7, 10, 11}, // back face
4701 {0, 1, 2, 3}, // bottom face
4702 {4, 5, 6, 7}}; // top face
4703 return lines[face][real_to_standard_face_line(
4704 line, face_orientation, face_flip, face_rotation)];
4705 }
4706
4707
4708
4709 inline unsigned int
4710 GeometryInfo<0>::face_to_cell_lines(const unsigned int,
4711 const unsigned int,
4712 const bool,
4713 const bool,
4714 const bool)
4715 {
4716 DEAL_II_NOT_IMPLEMENTED();
4717 return numbers::invalid_unsigned_int;
4718 }
4719
4720
4721
4722 template <int dim>
4723 inline unsigned int
4724 GeometryInfo<dim>::face_to_cell_lines(const unsigned int,
4725 const unsigned int,
4726 const bool,
4727 const bool,
4728 const bool)
4729 {
4730 DEAL_II_NOT_IMPLEMENTED();
4731 return numbers::invalid_unsigned_int;
4732 }
4733
4734
4735
4736 template <int dim>
4737 inline unsigned int
4738 GeometryInfo<dim>::face_to_cell_vertices(const unsigned int face,
4739 const unsigned int vertex,
4740 const bool face_orientation,
4741 const bool face_flip,
4742 const bool face_rotation)
4743 {
4744 return child_cell_on_face(RefinementCase<dim>::isotropic_refinement,
4745 face,
4746 vertex,
4747 face_orientation,
4748 face_flip,
4749 face_rotation);
4750 }
4751
4752
4753
4754 inline unsigned int
4755 GeometryInfo<0>::face_to_cell_vertices(const unsigned int,
4756 const unsigned int,
4757 const bool,
4758 const bool,
4759 const bool)
4760 {
4761 DEAL_II_NOT_IMPLEMENTED();
4762 return numbers::invalid_unsigned_int;
4763 }
4764
4765
4766
4767 template <int dim>
4768 template <typename Number>
4769 inline Point<dim, Number>
4770 GeometryInfo<dim>::project_to_unit_cell(const Point<dim, Number> &q)
4771 {
4772 Point<dim, Number> p;
4773 for (unsigned int i = 0; i < dim; ++i)
4774 p[i] = std::min(std::max(q[i], Number(0.)), Number(1.));
4775
4776 return p;
4777 }
4778
4779
4780
4781 template <int dim>
4782 inline double
4783 GeometryInfo<dim>::distance_to_unit_cell(const Point<dim> &p)
4784 {
4785 double result = 0.0;
4786
4787 for (unsigned int i = 0; i < dim; ++i)
4788 {
4789 result = std::max(result, -p[i]);
4790 result = std::max(result, p[i] - 1.);
4791 }
4792
4793 return result;
4794 }
4795
4796
4797
4798 template <int dim>
4799 inline double
4800 GeometryInfo<dim>::d_linear_shape_function(const Point<dim> &xi,
4801 const unsigned int i)
4802 {
4803 AssertIndexRange(i, GeometryInfo<dim>::vertices_per_cell);
4804
4805 switch (dim)
4806 {
4807 case 1:
4808 {
4809 const double x = xi[0];
4810 switch (i)
4811 {
4812 case 0:
4813 return 1 - x;
4814 case 1:
4815 return x;
4816 }
4817 break;
4818 }
4819
4820 case 2:
4821 {
4822 const double x = xi[0];
4823 const double y = xi[1];
4824 switch (i)
4825 {
4826 case 0:
4827 return (1 - x) * (1 - y);
4828 case 1:
4829 return x * (1 - y);
4830 case 2:
4831 return (1 - x) * y;
4832 case 3:
4833 return x * y;
4834 }
4835 break;
4836 }
4837
4838 case 3:
4839 {
4840 const double x = xi[0];
4841 const double y = xi[1];
4842 const double z = xi[2];
4843 switch (i)
4844 {
4845 case 0:
4846 return (1 - x) * (1 - y) * (1 - z);
4847 case 1:
4848 return x * (1 - y) * (1 - z);
4849 case 2:
4850 return (1 - x) * y * (1 - z);
4851 case 3:
4852 return x * y * (1 - z);
4853 case 4:
4854 return (1 - x) * (1 - y) * z;
4855 case 5:
4856 return x * (1 - y) * z;
4857 case 6:
4858 return (1 - x) * y * z;
4859 case 7:
4860 return x * y * z;
4861 }
4862 break;
4863 }
4864
4865 default:
4866 DEAL_II_NOT_IMPLEMENTED();
4867 }
4868 return -1e9;
4869 }
4870
4871
4872
4873 template <>
4874 Tensor<1, 1> inline GeometryInfo<1>::d_linear_shape_function_gradient(
4875 const Point<1> &,
4876 const unsigned int i)
4877 {
4878 AssertIndexRange(i, GeometryInfo<1>::vertices_per_cell);
4879
4880 switch (i)
4881 {
4882 case 0:
4883 return Point<1>(-1.);
4884 case 1:
4885 return Point<1>(1.);
4886 }
4887
4888 return Point<1>(-1e9);
4889 }
4890
4891
4892
4893 template <>
4894 Tensor<1, 2> inline GeometryInfo<2>::d_linear_shape_function_gradient(
4895 const Point<2> &xi,
4896 const unsigned int i)
4897 {
4898 AssertIndexRange(i, GeometryInfo<2>::vertices_per_cell);
4899
4900 const double x = xi[0];
4901 const double y = xi[1];
4902 switch (i)
4903 {
4904 case 0:
4905 return Point<2>(-(1 - y), -(1 - x));
4906 case 1:
4907 return Point<2>(1 - y, -x);
4908 case 2:
4909 return Point<2>(-y, 1 - x);
4910 case 3:
4911 return Point<2>(y, x);
4912 }
4913 return Point<2>(-1e9, -1e9);
4914 }
4915
4916
4917
4918 template <>
4919 Tensor<1, 3> inline GeometryInfo<3>::d_linear_shape_function_gradient(
4920 const Point<3> &xi,
4921 const unsigned int i)
4922 {
4923 AssertIndexRange(i, GeometryInfo<3>::vertices_per_cell);
4924
4925 const double x = xi[0];
4926 const double y = xi[1];
4927 const double z = xi[2];
4928 switch (i)
4929 {
4930 case 0:
4931 return Point<3>(-(1 - y) * (1 - z),
4932 -(1 - x) * (1 - z),
4933 -(1 - x) * (1 - y));
4934 case 1:
4935 return Point<3>((1 - y) * (1 - z), -x * (1 - z), -x * (1 - y));
4936 case 2:
4937 return Point<3>(-y * (1 - z), (1 - x) * (1 - z), -(1 - x) * y);
4938 case 3:
4939 return Point<3>(y * (1 - z), x * (1 - z), -x * y);
4940 case 4:
4941 return Point<3>(-(1 - y) * z, -(1 - x) * z, (1 - x) * (1 - y));
4942 case 5:
4943 return Point<3>((1 - y) * z, -x * z, x * (1 - y));
4944 case 6:
4945 return Point<3>(-y * z, (1 - x) * z, (1 - x) * y);
4946 case 7:
4947 return Point<3>(y * z, x * z, x * y);
4948 }
4949
4950 return Point<3>(-1e9, -1e9, -1e9);
4951 }
4952
4953
4954
4955 template <int dim>
4956 inline Tensor<1, dim>
4957 GeometryInfo<dim>::d_linear_shape_function_gradient(const Point<dim> &,
4958 const unsigned int)
4959 {
4960 DEAL_II_NOT_IMPLEMENTED();
4961 return Tensor<1, dim>();
4962 }
4963
4964
4965 unsigned int inline GeometryInfo<0>::n_children(const RefinementCase<0> &)
4966 {
4967 return 0;
4968 }
4969
4970
4971 namespace internal
4972 {
4973 namespace GeometryInfoHelper
4974 {
4975 // wedge product of a single
4976 // vector in 2d: we just have to
4977 // rotate it by 90 degrees to the
4978 // right
4979 inline Tensor<1, 2>
4980 wedge_product(const Tensor<1, 2> (&derivative)[1])
4981 {
4982 Tensor<1, 2> result;
4983 result[0] = derivative[0][1];
4984 result[1] = -derivative[0][0];
4985
4986 return result;
4987 }
4988
4989
4990 // wedge product of 2 vectors in
4991 // 3d is the cross product
4992 inline Tensor<1, 3>
4993 wedge_product(const Tensor<1, 3> (&derivative)[2])
4994 {
4995 return cross_product_3d(derivative[0], derivative[1]);
4996 }
4997
4998
4999 // wedge product of dim vectors
5000 // in dim-d: that's the
5001 // determinant of the matrix
5002 template <int dim>
5003 inline Tensor<0, dim>
5004 wedge_product(const Tensor<1, dim> (&derivative)[dim])
5005 {
5006 Tensor<2, dim> jacobian;
5007 for (unsigned int i = 0; i < dim; ++i)
5008 jacobian[i] = derivative[i];
5009
5010 return determinant(jacobian);
5011 }
5012 } // namespace GeometryInfoHelper
5013 } // namespace internal
5014
5015
5016 template <int dim>
5017 template <int spacedim>
5018 inline void
5019 GeometryInfo<dim>::alternating_form_at_vertices
5020 # ifndef DEAL_II_CXX14_CONSTEXPR_BUG
5021 (const Point<spacedim> (&vertices)[vertices_per_cell],
5022 Tensor<spacedim - dim, spacedim> (&forms)[vertices_per_cell])
5023 # else
5024 (const Point<spacedim> *vertices, Tensor<spacedim - dim, spacedim> *forms)
5025 # endif
5026 {
5027 // for each of the vertices,
5028 // compute the alternating form
5029 // of the mapped unit
5030 // vectors. consider for
5031 // example the case of a quad
5032 // in spacedim==3: to do so, we
5033 // need to see how the
5034 // infinitesimal vectors
5035 // (d\xi_1,0) and (0,d\xi_2)
5036 // are transformed into
5037 // spacedim-dimensional space
5038 // and then form their cross
5039 // product (i.e. the wedge product
5040 // of two vectors). to this end, note
5041 // that
5042 // \vec x = sum_i \vec v_i phi_i(\vec xi)
5043 // so the transformed vectors are
5044 // [x(\xi+(d\xi_1,0))-x(\xi)]/d\xi_1
5045 // and
5046 // [x(\xi+(0,d\xi_2))-x(\xi)]/d\xi_2
5047 // which boils down to the columns
5048 // of the 3x2 matrix \grad_\xi x(\xi)
5049 //
5050 // a similar reasoning would
5051 // hold for all dim,spacedim
5052 // pairs -- we only have to
5053 // compute the wedge product of
5054 // the columns of the
5055 // derivatives
5056 for (unsigned int i = 0; i < vertices_per_cell; ++i)
5057 {
5058 Tensor<1, spacedim> derivatives[dim];
5059
5060 for (unsigned int j = 0; j < vertices_per_cell; ++j)
5061 {
5062 const Tensor<1, dim> grad_phi_j =
5063 d_linear_shape_function_gradient(unit_cell_vertex(i), j);
5064 for (unsigned int l = 0; l < dim; ++l)
5065 derivatives[l] += vertices[j] * grad_phi_j[l];
5066 }
5067
5068 forms[i] = internal::GeometryInfoHelper::wedge_product(derivatives);
5069 }
5070 }
5071
5072 #endif // DOXYGEN
5073 DEAL_II_NAMESPACE_CLOSE
5074
5075 #endif