1 // ---------------------------------------------------------------------
3 // Copyright (C) 2022 - 2023 by the deal.II authors
5 // This file is part of the deal.II library.
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
14 // ---------------------------------------------------------------------
16 #ifndef dealii_tria_objects_orientations_h
17 #define dealii_tria_objects_orientations_h
19 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/memory_consumption.h>
23 #include <deal.II/base/utilities.h>
25 #include <deal.II/grid/reference_cell.h>
29 DEAL_II_NAMESPACE_OPEN
33 namespace TriangulationImplementation
36 * Class storing orientation information for various objects in a
41 class TriaObjectsOrientations
47 TriaObjectsOrientations();
50 * Constructor. Sets up objects in the default orientation (orientation
53 TriaObjectsOrientations(const unsigned int n_objects);
56 * Return number of geometric objects stored by this class.
62 * Reset the object to a default state.
65 reinit(const unsigned int n_objects);
68 * Change the number of stored objects. New objects are constructed in
69 * the default orientation (true, false, false).
72 resize(const unsigned int n_objects);
75 * Return the size of objects of this kind.
78 memory_consumption() const;
81 * Get the combined orientation of the object, as described in the class
85 get_combined_orientation(const unsigned int object) const;
88 * Get the orientation bit of the object.
91 get_orientation(const unsigned int object) const;
94 * Get the rotation bit of the object.
97 get_rotation(const unsigned int object) const;
100 * Get the flip bit of the object.
103 get_flip(const unsigned int object) const;
106 * Set the combined orientation of the object, as described in the class
110 set_combined_orientation(const unsigned int object,
111 const unsigned char value);
114 * Set the orientation bit of the object.
117 set_orientation(const unsigned int object, const bool value);
120 * Set the rotate bit of the object.
123 set_rotation(const unsigned int object, const bool value);
126 * Set the flip bit of the object.
129 set_flip(const unsigned int object, const bool value);
132 * Read or write the data of this object to or from a stream for the
133 * purpose of serialization using the [BOOST serialization
134 * library](https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/index.html).
136 template <class Archive>
138 serialize(Archive &ar, const unsigned int version);
144 unsigned int n_stored_objects;
149 std::vector<unsigned char> flags;
152 //----------------------------------------------------------------------//
154 inline TriaObjectsOrientations::TriaObjectsOrientations()
161 inline TriaObjectsOrientations::TriaObjectsOrientations(
162 const unsigned int n_objects)
170 TriaObjectsOrientations::reinit(const unsigned int n_objects)
172 n_stored_objects = n_objects;
173 // Assign to the default orientation
174 flags.assign(n_objects,
175 ReferenceCell::default_combined_face_orientation());
181 TriaObjectsOrientations::resize(const unsigned int n_objects)
183 flags.resize(n_objects,
184 ReferenceCell::default_combined_face_orientation());
185 n_stored_objects = n_objects;
191 TriaObjectsOrientations::memory_consumption() const
193 return MemoryConsumption::memory_consumption(n_stored_objects) +
194 MemoryConsumption::memory_consumption(flags);
200 TriaObjectsOrientations::n_objects() const
202 return n_stored_objects;
208 TriaObjectsOrientations::get_combined_orientation(
209 const unsigned int object) const
211 AssertIndexRange(object, n_stored_objects);
212 return flags[object];
218 TriaObjectsOrientations::get_orientation(const unsigned int object) const
220 AssertIndexRange(object, n_stored_objects);
221 return Utilities::get_bit(flags[object], 0);
227 TriaObjectsOrientations::get_rotation(const unsigned int object) const
229 AssertIndexRange(object, n_stored_objects);
230 return Utilities::get_bit(flags[object], 1);
236 TriaObjectsOrientations::get_flip(const unsigned int object) const
238 AssertIndexRange(object, n_stored_objects);
239 return Utilities::get_bit(flags[object], 2);
245 TriaObjectsOrientations::set_combined_orientation(const unsigned int object,
246 const unsigned char value)
248 AssertIndexRange(object, n_stored_objects);
249 flags[object] = value;
255 TriaObjectsOrientations::set_orientation(const unsigned int object,
258 AssertIndexRange(object, n_stored_objects);
259 Utilities::set_bit(flags[object], 0, value);
265 TriaObjectsOrientations::set_rotation(const unsigned int object,
268 AssertIndexRange(object, n_stored_objects);
269 Utilities::set_bit(flags[object], 1, value);
275 TriaObjectsOrientations::set_flip(const unsigned int object,
278 AssertIndexRange(object, n_stored_objects);
279 Utilities::set_bit(flags[object], 2, value);
284 template <class Archive>
286 TriaObjectsOrientations::serialize(Archive &ar, const unsigned int)
288 ar &n_stored_objects &flags;
290 } // namespace TriangulationImplementation
291 } // namespace internal
293 DEAL_II_NAMESPACE_CLOSE
In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move.
Douglas Adams