Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : 19 : 20 : #ifndef LIBMESH_POINT_H 21 : #define LIBMESH_POINT_H 22 : 23 : // Local includes 24 : #include "libmesh/hashing.h" 25 : #include "libmesh/libmesh_device.h" 26 : #include "libmesh/type_vector.h" 27 : 28 : namespace libMesh 29 : { 30 : 31 : /** 32 : * A \p Point defines a location in LIBMESH_DIM dimensional Real space. Points 33 : * are always real-valued, even if the library is configured with 34 : * \p --enable-complex. 35 : * 36 : * \author Benjamin S. Kirk 37 : * \date 2003 38 : * \brief A geometric point in (x,y,z) space. 39 : */ 40 : class Point : public TypeVector<Real> 41 : { 42 : public: 43 : 44 : /** 45 : * Constructor. By default sets all entries to 0. Gives the point 46 : * 0 in \p LIBMESH_DIM dimensions. 47 : */ 48 : LIBMESH_DEVICE_INLINE 49 333137491 : Point (const Real x=0., 50 : const Real y=0., 51 333137491 : const Real z=0.) : 52 333137491 : TypeVector<Real> (x,y,z) 53 333151687 : {} 54 : 55 : /** 56 : * Trivial copy-constructor. 57 : */ 58 : LIBMESH_DEVICE_INLINE 59 : Point (const Point & p) = default; 60 : 61 : /** 62 : * Copy-constructor from non-point Typevector. 63 : */ 64 : LIBMESH_DEVICE_INLINE 65 1258511187 : Point (const TypeVector<Real> & p) : 66 726325242 : TypeVector<Real> (p) 67 84114475 : {} 68 : 69 : /** 70 : * Copy-assignment operator. 71 : */ 72 : LIBMESH_DEVICE_INLINE 73 : Point& operator=(const Point & p) = default; 74 : 75 : /** 76 : * Disambiguate constructing from non-Real scalars 77 : */ 78 : template <typename T, 79 : typename = typename 80 : std::enable_if<ScalarTraits<T>::value,void>::type> 81 : LIBMESH_DEVICE_INLINE 82 214518 : Point (const T x) : 83 214518 : TypeVector<Real> (x,0,0) 84 214518 : {} 85 : 86 : /** 87 : * Destructor. 88 : */ 89 : ~Point() = default; 90 : 91 : protected: 92 : 93 : /** 94 : * Make the derived class a friend. 95 : */ 96 : friend class Node; 97 : }; 98 : 99 : } // namespace libMesh 100 : 101 : namespace std 102 : { 103 : template <> 104 : struct hash<libMesh::Point> 105 : { 106 275533 : std::size_t operator()(const libMesh::Point & p) const 107 : { 108 42523 : std::size_t seed = 0; 109 1102132 : for (int d=0; d != LIBMESH_DIM; ++d) 110 1289669 : libMesh::boostcopy::hash_combine(seed, std::hash<libMesh::Real>()(p(d))); 111 275533 : return seed; 112 : } 113 : }; 114 : 115 : } 116 : 117 : #endif // LIBMESH_POINT_H