Debian Codegraph @

include/deal.II/grid/tria_faces.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2006 - 2023 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_tria_faces_h
16 #define dealii_tria_faces_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/grid/reference_cell.h>
21 #include <deal.II/grid/tria_objects.h>
22
23
24 DEAL_II_NAMESPACE_OPEN
25
26 namespace internal
27 {
28 namespace TriangulationImplementation
29 {
30 /**
31 * This class contains information belonging to the faces of a
32 * triangulation. These classes are similar to the TriaLevel classes. As
33 * cells are organized in a hierarchical structure of levels, each
34 * triangulation consists of several such TriaLevels. However the faces of
35 * a triangulation, lower dimensional objects like lines in 2d or lines
36 * and quads in 3d, do not have to be based on such a hierarchical
37 * structure. In fact we have to organise them in only one object if we
38 * want to enable anisotropic refinement. Therefore the TriaFaces classes
39 * store the information belonging to the faces of a triangulation
40 * separately from the TriaLevel classes.
41 */
42 class TriaFaces
43 {
44 public:
45 /**
46 * Constructor.
47 */
48 TriaFaces(const unsigned int dim);
49
50 /**
51 * Default constructor for Boost::serialization.
52 */
53 TriaFaces() = default;
54
55 /**
56 * Dimension of the underlying triangulation.
57 */
58 unsigned int dim;
59
60 /**
61 * The TriaObject containing the data of quads.
62 *
63 * @note Used only for dim=3.
64 */
65 TriaObjects quads;
66
67 /**
68 * Orientation of each line of each quad. Like elsewhere, `true` refers to
69 * the standard orientation and `false` refers to the reverse orientation.
70 *
71 * @note Used only for dim=3.
72 */
73 std::vector<bool> quads_line_orientations;
74
75 /**
76 * Whether or not each quad is a Quadrilateral. Since, if dim = 3, faces
77 * are either Triangles or Quadrilaterals, it suffices to store a
78 * boolean.
79 *
80 * @note Used only for dim=3.
81 */
82 std::vector<bool> quad_is_quadrilateral;
83
84 /**
85 * Helper accessor function for quad_is_quadrilateral
86 */
87 ReferenceCell
88 get_quad_type(const std::size_t index) const;
89
90 /**
91 * Helper accessor function for quad_is_quadrilateral
92 */
93 void
94 set_quad_type(const std::size_t index, const ReferenceCell face_type);
95
96 /**
97 * The TriaObject containing the data of lines.
98 *
99 * @note Used only for dim>1.
100 */
101 TriaObjects lines;
102
103 /**
104 * Determine an estimate for the memory consumption (in bytes) of this
105 * object.
106 */
107 std::size_t
108 memory_consumption() const;
109
110 /**
111 * Read or write the data of this object to or from a stream for the
112 * purpose of serialization using the [BOOST serialization
113 * library](https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/index.html).
114 */
115 template <class Archive>
116 void
117 serialize(Archive &ar, const unsigned int version);
118 };
119
120
121
122 inline ReferenceCell
123 TriaFaces::get_quad_type(const std::size_t index) const
124 {
125 AssertIndexRange(index, quad_is_quadrilateral.size());
126 return quad_is_quadrilateral[index] ? ReferenceCells::Quadrilateral :
127 ReferenceCells::Triangle;
128 }
129
130
131
132 inline void
133 TriaFaces::set_quad_type(const std::size_t index,
134 const ReferenceCell face_type)
135 {
136 AssertIndexRange(index, quad_is_quadrilateral.size());
137 Assert(face_type == ReferenceCells::Quadrilateral ||
138 face_type == ReferenceCells::Triangle,
139 ExcInternalError());
140 if (face_type == ReferenceCells::Quadrilateral)
141 quad_is_quadrilateral[index] = true;
142 else
143 quad_is_quadrilateral[index] = false;
144 }
145
146
147
148 template <class Archive>
149 void
150 TriaFaces::serialize(Archive &ar, const unsigned int)
151 {
152 ar &dim;
153 ar &quads &lines &quads_line_orientations &quad_is_quadrilateral;
154 }
155 } // namespace TriangulationImplementation
156 } // namespace internal
157
158 DEAL_II_NAMESPACE_CLOSE
159
160 #endif