Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 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/type_vector.h" 26 : 27 : namespace libMesh 28 : { 29 : 30 : /** 31 : * A \p Point defines a location in LIBMESH_DIM dimensional Real space. Points 32 : * are always real-valued, even if the library is configured with 33 : * \p --enable-complex. 34 : * 35 : * \author Benjamin S. Kirk 36 : * \date 2003 37 : * \brief A geometric point in (x,y,z) space. 38 : */ 39 : class Point : public TypeVector<Real> 40 : { 41 : public: 42 : 43 : /** 44 : * Constructor. By default sets all entries to 0. Gives the point 45 : * 0 in \p LIBMESH_DIM dimensions. 46 : */ 47 282988136 : Point (const Real x=0., 48 : const Real y=0., 49 282988136 : const Real z=0.) : 50 282988136 : TypeVector<Real> (x,y,z) 51 283002332 : {} 52 : 53 : /** 54 : * Trivial copy-constructor. 55 : */ 56 : Point (const Point & p) = default; 57 : 58 : /** 59 : * Copy-constructor from non-point Typevector. 60 : */ 61 1073337081 : Point (const TypeVector<Real> & p) : 62 545412088 : TypeVector<Real> (p) 63 78481897 : {} 64 : 65 : /** 66 : * Copy-assignment operator. 67 : */ 68 : Point& operator=(const Point & p) = default; 69 : 70 : /** 71 : * Disambiguate constructing from non-Real scalars 72 : */ 73 : template <typename T, 74 : typename = typename 75 : boostcopy::enable_if_c<ScalarTraits<T>::value,void>::type> 76 246729 : Point (const T x) : 77 246729 : TypeVector<Real> (x,0,0) 78 246729 : {} 79 : 80 : /** 81 : * Destructor. 82 : */ 83 : ~Point() = default; 84 : 85 : protected: 86 : 87 : /** 88 : * Make the derived class a friend. 89 : */ 90 : friend class Node; 91 : }; 92 : 93 : } // namespace libMesh 94 : 95 : namespace std 96 : { 97 : template <> 98 : struct hash<libMesh::Point> 99 : { 100 275517 : std::size_t operator()(const libMesh::Point & p) const 101 : { 102 42507 : std::size_t seed = 0; 103 1102068 : for (int d=0; d != LIBMESH_DIM; ++d) 104 1289621 : libMesh::boostcopy::hash_combine(seed, std::hash<libMesh::Real>()(p(d))); 105 275517 : return seed; 106 : } 107 : }; 108 : 109 : } 110 : 111 : #endif // LIBMESH_POINT_H