Debian Codegraph @

include/deal.II/boost_adaptors/point.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2018 - 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_boost_adaptor_point_h
16 #define dealii_boost_adaptor_point_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/point.h>
21
22 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
23 #include <boost/geometry/core/coordinate_dimension.hpp>
24 #include <boost/geometry/core/coordinate_system.hpp>
25 #include <boost/geometry/core/coordinate_type.hpp>
26 #include <boost/geometry/core/cs.hpp>
27 #include <boost/geometry/core/tag.hpp>
28 #include <boost/geometry/strategies/strategies.hpp>
29 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
30
31
32 DEAL_II_NAMESPACE_OPEN
33 DEAL_II_NAMESPACE_CLOSE // Do not convert for module purposes
34
35 namespace boost
36 {
37 namespace geometry
38 {
39 namespace traits
40 {
41 /**
42 * Tag adaptor for dealii::Point.
43 */
44 template <int dim, class Number>
45 struct tag<dealii::Point<dim, Number>>
46 {
47 using type = point_tag;
48 };
49
50 /**
51 * Coordinate type adaptor for dealii::Point.
52 */
53 template <int dim, class Number>
54 struct coordinate_type<dealii::Point<dim, Number>>
55 {
56 using type = Number;
57 };
58
59 /**
60 * Coordinate system adaptor for dealii::Point. By default, we assume
61 * that a dealii Point is cartesian point.
62 */
63 template <int dim, class Number>
64 struct coordinate_system<dealii::Point<dim, Number>>
65 {
66 using type = cs::cartesian;
67 };
68
69 /**
70 * Dimension adaptor.
71 */
72 template <int dim, class Number>
73 struct dimension<dealii::Point<dim, Number>> : boost::mpl::int_<dim>
74 {};
75
76 /**
77 * Getter function for D-th coordinate of a dealii Point.
78 */
79 template <std::size_t D, int dim, class Number>
80 struct access<dealii::Point<dim, Number>, D>
81 {
82 static inline double
83 get(const dealii::Point<dim, Number> &p)
84 {
85 return p[D];
86 }
87
88 /**
89 * Setter function for D-th coordinate of a dealii Point.
90 */
91 static inline void
92 set(dealii::Point<dim, Number> &p, Number value)
93 {
94 p[D] = value;
95 }
96 };
97 } // namespace traits
98 } // namespace geometry
99 } // namespace boost
100
101 DEAL_II_NAMESPACE_OPEN // Do not convert for module purposes
102 DEAL_II_NAMESPACE_CLOSE
103
104
105 #endif