libMesh
point.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 
39 class Point : public TypeVector<Real>
40 {
41 public:
42 
47  Point (const Real x=0.,
48  const Real y=0.,
49  const Real z=0.) :
50  TypeVector<Real> (x,y,z)
51  {}
52 
56  Point (const Point & p) = default;
57 
61  Point (const TypeVector<Real> & p) :
62  TypeVector<Real> (p)
63  {}
64 
68  Point& operator=(const Point & p) = default;
69 
73  template <typename T,
74  typename = typename
76  Point (const T x) :
77  TypeVector<Real> (x,0,0)
78  {}
79 
83  ~Point() = default;
84 
85 protected:
86 
90  friend class Node;
91 };
92 
93 } // namespace libMesh
94 
95 namespace std
96 {
97 template <>
98 struct hash<libMesh::Point>
99 {
100  std::size_t operator()(const libMesh::Point & p) const
101  {
102  std::size_t seed = 0;
103  for (int d=0; d != LIBMESH_DIM; ++d)
104  libMesh::boostcopy::hash_combine(seed, std::hash<libMesh::Real>()(p(d)));
105  return seed;
106  }
107 };
108 
109 }
110 
111 #endif // LIBMESH_POINT_H
std::size_t operator()(const libMesh::Point &p) const
Definition: point.h:100
A Node is like a Point, but with more information.
Definition: node.h:52
Point & operator=(const Point &p)=default
Copy-assignment operator.
void hash_combine(std::size_t &seed, const T &value)
Definition: hashing.h:34
~Point()=default
Destructor.
Point(const TypeVector< Real > &p)
Copy-constructor from non-point Typevector.
Definition: point.h:61
Point(const T x)
Disambiguate constructing from non-Real scalars.
Definition: point.h:76
The libMesh namespace provides an interface to certain functionality in the library.
Point(const Real x=0., const Real y=0., const Real z=0.)
Constructor.
Definition: point.h:47
This class defines a vector in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:34
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39