Nektar++
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Nektar::NekPoint< data_type > Class Template Reference

#include <NekPoint.hpp>

Public Types

typedef data_type DataType
 
typedef ThreeD dim
 

Public Member Functions

 NekPoint ()
 
 NekPoint (const std::string &pointValues)
 
 NekPoint (typename boost::call_traits< DataType >::param_type x, typename boost::call_traits< DataType >::param_type y, typename boost::call_traits< DataType >::param_type z)
 
 NekPoint (typename boost::call_traits< DataType >::const_reference a)
 
 NekPoint (const NekPoint< DataType > &rhs)
 
 ~NekPoint ()
 
NekPoint< DataType > & operator= (const NekPoint< DataType > &rhs)
 
boost::call_traits< DataType >::reference operator() (unsigned int i)
 Returns i^{th} element. More...
 
boost::call_traits< DataType >::const_reference operator() (unsigned int i) const
 
boost::call_traits< DataType >::reference operator[] (unsigned int i)
 
boost::call_traits< DataType >::const_reference operator[] (unsigned int i) const
 
boost::call_traits< DataType >::const_reference x () const
 
boost::call_traits< DataType >::const_reference y () const
 
boost::call_traits< DataType >::const_reference z () const
 
boost::call_traits< DataType >::const_reference a () const
 
boost::call_traits< DataType >::const_reference b () const
 
boost::call_traits< DataType >::const_reference c () const
 
boost::call_traits< DataType >::const_reference r () const
 
boost::call_traits< DataType >::const_reference s () const
 
boost::call_traits< DataType >::const_reference t () const
 
void SetX (typename boost::call_traits< DataType >::const_reference val)
 
void SetY (typename boost::call_traits< DataType >::const_reference val)
 
void SetZ (typename boost::call_traits< DataType >::const_reference val)
 
boost::call_traits< DataType >::reference x ()
 
boost::call_traits< DataType >::reference y ()
 
boost::call_traits< DataType >::reference z ()
 
const DataTypeGetPtr () const
 
bool operator== (const NekPoint< DataType > &rhs) const
 
bool operator!= (const NekPoint< DataType > &rhs) const
 
void negate ()
 Arithmetic Routines. More...
 
NekPoint< DataTypeoperator- () const
 
NekPoint< DataType > & operator+= (const NekPoint< DataType > &rhs)
 
NekPoint< DataType > & operator+= (typename boost::call_traits< DataType >::param_type rhs)
 
NekPoint< DataType > & operator-= (const NekPoint< DataType > &rhs)
 
NekPoint< DataType > & operator-= (typename boost::call_traits< DataType >::param_type rhs)
 
NekPoint< DataType > & operator*= (typename boost::call_traits< DataType >::param_type rhs)
 
NekPoint< DataType > & operator/= (typename boost::call_traits< DataType >::param_type rhs)
 
std::string AsString () const
 

Static Public Member Functions

static unsigned int dimension ()
 Returns the number of dimensions for the point. More...
 

Private Attributes

DataType m_data [dim::Value]
 

Detailed Description

template<typename data_type>
class Nektar::NekPoint< data_type >

Definition at line 52 of file NekPoint.hpp.

Member Typedef Documentation

◆ DataType

template<typename data_type >
typedef data_type Nektar::NekPoint< data_type >::DataType

Definition at line 55 of file NekPoint.hpp.

◆ dim

template<typename data_type >
typedef ThreeD Nektar::NekPoint< data_type >::dim

Definition at line 56 of file NekPoint.hpp.

Constructor & Destructor Documentation

◆ NekPoint() [1/5]

template<typename data_type >
Nektar::NekPoint< data_type >::NekPoint ( )
inline

Definition at line 59 of file NekPoint.hpp.

60  {
61  // This may be suboptimal if DataType isn't numeric.
62  // If we use them then maybe we could look at an enable_if
63  // template to choose a better constructor.
64  for (unsigned int i = 0; i < dim::Value; ++i)
65  {
66  // If you get a compile error pointing you here then
67  // the DataType being stored in the point doesn't have an
68  // accessible operator= or default copy constructor.
69  m_data[i] = DataType();
70  }
71  }
data_type DataType
Definition: NekPoint.hpp:55
DataType m_data[dim::Value]
Definition: NekPoint.hpp:366
static const unsigned int Value

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ NekPoint() [2/5]

template<typename data_type >
Nektar::NekPoint< data_type >::NekPoint ( const std::string &  pointValues)
inline

Definition at line 73 of file NekPoint.hpp.

74  {
75  bool result = fromString(pointValues, *this);
76  ASSERTL0(result, "Unable to create a point from a string.");
77  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
bool fromString(const std::string &str, NekPoint< DataType > &result)
Definition: NekPoint.hpp:475

References ASSERTL0, and Nektar::fromString().

◆ NekPoint() [3/5]

template<typename data_type >
Nektar::NekPoint< data_type >::NekPoint ( typename boost::call_traits< DataType >::param_type  x,
typename boost::call_traits< DataType >::param_type  y,
typename boost::call_traits< DataType >::param_type  z 
)
inline

Definition at line 79 of file NekPoint.hpp.

82  {
83  m_data[0] = x;
84  m_data[1] = y;
85  m_data[2] = z;
86  }
boost::call_traits< DataType >::const_reference z() const
Definition: NekPoint.hpp:172
boost::call_traits< DataType >::const_reference x() const
Definition: NekPoint.hpp:160
boost::call_traits< DataType >::const_reference y() const
Definition: NekPoint.hpp:166

References Nektar::NekPoint< data_type >::m_data, Nektar::NekPoint< data_type >::x(), Nektar::NekPoint< data_type >::y(), and Nektar::NekPoint< data_type >::z().

◆ NekPoint() [4/5]

template<typename data_type >
Nektar::NekPoint< data_type >::NekPoint ( typename boost::call_traits< DataType >::const_reference  a)
inlineexplicit

Definition at line 88 of file NekPoint.hpp.

89  {
90  for (unsigned int i = 0; i < dim::Value; ++i)
91  {
92  m_data[i] = a;
93  }
94  }
boost::call_traits< DataType >::const_reference a() const
Definition: NekPoint.hpp:178

References Nektar::NekPoint< data_type >::a(), Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ NekPoint() [5/5]

template<typename data_type >
Nektar::NekPoint< data_type >::NekPoint ( const NekPoint< DataType > &  rhs)
inline

Definition at line 96 of file NekPoint.hpp.

97  {
98  for (unsigned int i = 0; i < dim::Value; ++i)
99  {
100  m_data[i] = rhs.m_data[i];
101  }
102  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ ~NekPoint()

template<typename data_type >
Nektar::NekPoint< data_type >::~NekPoint ( )
inline

Definition at line 104 of file NekPoint.hpp.

105  {
106  }

Member Function Documentation

◆ a()

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::a ( ) const
inline

Definition at line 178 of file NekPoint.hpp.

179  {
180  static_assert(dim::Value >= 1, "invalid dimension");
181  return m_data[0];
182  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

Referenced by Nektar::NekPoint< data_type >::NekPoint().

◆ AsString()

template<typename data_type >
std::string Nektar::NekPoint< data_type >::AsString ( ) const
inline

Definition at line 350 of file NekPoint.hpp.

351  {
352  std::string result = "(";
353  for (unsigned int i = 0; i < dim::Value; ++i)
354  {
355  result += boost::lexical_cast<std::string>(m_data[i]);
356  if (i < dim::Value - 1)
357  {
358  result += ", ";
359  }
360  }
361  result += ")";
362  return result;
363  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ b()

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::b ( ) const
inline

Definition at line 184 of file NekPoint.hpp.

185  {
186  static_assert(dim::Value >= 2, "invalid dimension");
187  return (*this)[1];
188  }

References Nektar::ThreeD::Value.

◆ c()

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::c ( ) const
inline

Definition at line 190 of file NekPoint.hpp.

191  {
192  static_assert(dim::Value >= 3, "invalid dimension");
193  return (*this)[2];
194  }

References Nektar::ThreeD::Value.

◆ dimension()

template<typename data_type >
static unsigned int Nektar::NekPoint< data_type >::dimension ( )
inlinestatic

Returns the number of dimensions for the point.

Definition at line 118 of file NekPoint.hpp.

119  {
120  return dim::Value;
121  }

References Nektar::ThreeD::Value.

◆ GetPtr()

template<typename data_type >
const DataType* Nektar::NekPoint< data_type >::GetPtr ( ) const
inline

Definition at line 250 of file NekPoint.hpp.

251  {
252  return &m_data[0];
253  }

References Nektar::NekPoint< data_type >::m_data.

◆ negate()

template<typename data_type >
void Nektar::NekPoint< data_type >::negate ( )
inline

Arithmetic Routines.

Definition at line 277 of file NekPoint.hpp.

278  {
279  for (int i = 0; i < dim::Value; ++i)
280  {
281  (*this)[i] = -(*this)[i];
282  }
283  }

References Nektar::ThreeD::Value.

Referenced by Nektar::negate(), and Nektar::NekPoint< data_type >::operator-().

◆ operator!=()

template<typename data_type >
bool Nektar::NekPoint< data_type >::operator!= ( const NekPoint< DataType > &  rhs) const
inline

Definition at line 269 of file NekPoint.hpp.

270  {
271  return !(*this == rhs);
272  }

◆ operator()() [1/2]

template<typename data_type >
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::operator() ( unsigned int  i)
inline

Returns i^{th} element.

Parameters
iThe element to return.
Precondition
i < dim
Returns
A reference to the i^{th} element.

Retrieves the i^{th} element. Since it returns a reference you may assign a new value (i.e., p(2) = 3.2;)

This operator performs range checking.

Definition at line 132 of file NekPoint.hpp.

133  {
134  ASSERTL0(i < dim::Value,
135  "Invalid access to NekPoint data via parenthesis "
136  "operator: index out of range");
137  return m_data[i];
138  }

References ASSERTL0, Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator()() [2/2]

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::operator() ( unsigned int  i) const
inline

Definition at line 140 of file NekPoint.hpp.

142  {
143  ASSERTL0(i < dim::Value,
144  "Invalid access to NekPoint data via parenthesis "
145  "operator: index out of range");
146  return m_data[i];
147  }

References ASSERTL0, Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator*=()

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator*= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 330 of file NekPoint.hpp.

332  {
333  for (unsigned int i = 0; i < dim::Value; ++i)
334  {
335  m_data[i] *= rhs;
336  }
337  return *this;
338  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator+=() [1/2]

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator+= ( const NekPoint< DataType > &  rhs)
inline

Definition at line 292 of file NekPoint.hpp.

293  {
294  for (unsigned int i = 0; i < dim::Value; ++i)
295  {
296  m_data[i] += rhs.m_data[i];
297  }
298  return *this;
299  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator+=() [2/2]

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator+= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 301 of file NekPoint.hpp.

303  {
304  for (unsigned int i = 0; i < dim::Value; ++i)
305  {
306  m_data[i] += rhs;
307  }
308  return *this;
309  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator-()

template<typename data_type >
NekPoint<DataType> Nektar::NekPoint< data_type >::operator- ( ) const
inline

Definition at line 285 of file NekPoint.hpp.

286  {
287  NekPoint<DataType> result(*this);
288  result.negate();
289  return result;
290  }

References Nektar::NekPoint< data_type >::negate().

◆ operator-=() [1/2]

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator-= ( const NekPoint< DataType > &  rhs)
inline

Definition at line 311 of file NekPoint.hpp.

312  {
313  for (unsigned int i = 0; i < dim::Value; ++i)
314  {
315  m_data[i] -= rhs.m_data[i];
316  }
317  return *this;
318  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator-=() [2/2]

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator-= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 320 of file NekPoint.hpp.

322  {
323  for (unsigned int i = 0; i < dim::Value; ++i)
324  {
325  m_data[i] -= rhs;
326  }
327  return *this;
328  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator/=()

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator/= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 340 of file NekPoint.hpp.

342  {
343  for (unsigned int i = 0; i < dim::Value; ++i)
344  {
345  m_data[i] /= rhs;
346  }
347  return *this;
348  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator=()

template<typename data_type >
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator= ( const NekPoint< DataType > &  rhs)
inline

Definition at line 108 of file NekPoint.hpp.

109  {
110  for (unsigned int i = 0; i < dim::Value; ++i)
111  {
112  m_data[i] = rhs.m_data[i];
113  }
114  return *this;
115  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator==()

template<typename data_type >
bool Nektar::NekPoint< data_type >::operator== ( const NekPoint< DataType > &  rhs) const
inline

Definition at line 255 of file NekPoint.hpp.

256  {
257  for (unsigned int i = 0; i < dim::Value; ++i)
258  {
259  // If you get a compile error here then you have to
260  // add a != operator to the DataType class.
261  if (m_data[i] != rhs.m_data[i])
262  {
263  return false;
264  }
265  }
266  return true;
267  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ operator[]() [1/2]

template<typename data_type >
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::operator[] ( unsigned int  i)
inline

Definition at line 149 of file NekPoint.hpp.

150  {
151  return m_data[i];
152  }

References Nektar::NekPoint< data_type >::m_data.

◆ operator[]() [2/2]

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::operator[] ( unsigned int  i) const
inline

Definition at line 154 of file NekPoint.hpp.

156  {
157  return m_data[i];
158  }

References Nektar::NekPoint< data_type >::m_data.

◆ r()

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::r ( ) const
inline

Definition at line 196 of file NekPoint.hpp.

197  {
198  static_assert(dim::Value >= 1, "invalid dimension");
199  return m_data[0];
200  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ s()

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::s ( ) const
inline

Definition at line 202 of file NekPoint.hpp.

203  {
204  static_assert(dim::Value >= 2, "invalid dimension");
205  return (*this)[1];
206  }

References Nektar::ThreeD::Value.

◆ SetX()

template<typename data_type >
void Nektar::NekPoint< data_type >::SetX ( typename boost::call_traits< DataType >::const_reference  val)
inline

Definition at line 214 of file NekPoint.hpp.

215  {
216  static_assert(dim::Value >= 1, "invalid dimension");
217  m_data[0] = val;
218  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ SetY()

template<typename data_type >
void Nektar::NekPoint< data_type >::SetY ( typename boost::call_traits< DataType >::const_reference  val)
inline

Definition at line 220 of file NekPoint.hpp.

221  {
222  static_assert(dim::Value >= 2, "invalid dimension");
223  m_data[1] = val;
224  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ SetZ()

template<typename data_type >
void Nektar::NekPoint< data_type >::SetZ ( typename boost::call_traits< DataType >::const_reference  val)
inline

Definition at line 226 of file NekPoint.hpp.

227  {
228  static_assert(dim::Value >= 2, "invalid dimension");
229  m_data[2] = val;
230  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

◆ t()

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::t ( ) const
inline

Definition at line 208 of file NekPoint.hpp.

209  {
210  static_assert(dim::Value >= 3, "invalid dimension");
211  return (*this)[2];
212  }

References Nektar::ThreeD::Value.

◆ x() [1/2]

template<typename data_type >
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::x ( )
inline

Definition at line 232 of file NekPoint.hpp.

233  {
234  static_assert(dim::Value >= 1, "invalid dimension");
235  return (*this)(0);
236  }

References Nektar::ThreeD::Value.

◆ x() [2/2]

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::x ( ) const
inline

Definition at line 160 of file NekPoint.hpp.

161  {
162  static_assert(dim::Value >= 1, "invalid dimension");
163  return m_data[0];
164  }

References Nektar::NekPoint< data_type >::m_data, and Nektar::ThreeD::Value.

Referenced by Nektar::NekPoint< data_type >::NekPoint(), and Nektar::LocalRegions::Expansion3D::v_TraceNormLen().

◆ y() [1/2]

template<typename data_type >
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::y ( )
inline

Definition at line 238 of file NekPoint.hpp.

239  {
240  static_assert(dim::Value >= 2, "invalid dimension");
241  return (*this)(1);
242  }

References Nektar::ThreeD::Value.

◆ y() [2/2]

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::y ( ) const
inline

Definition at line 166 of file NekPoint.hpp.

167  {
168  static_assert(dim::Value >= 2, "invalid dimension");
169  return (*this)[1];
170  }

References Nektar::ThreeD::Value.

Referenced by Nektar::NekPoint< data_type >::NekPoint(), and Nektar::LocalRegions::Expansion3D::v_TraceNormLen().

◆ z() [1/2]

template<typename data_type >
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::z ( )
inline

Definition at line 244 of file NekPoint.hpp.

245  {
246  static_assert(dim::Value >= 3, "invalid dimension");
247  return (*this)(2);
248  }

References Nektar::ThreeD::Value.

◆ z() [2/2]

template<typename data_type >
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::z ( ) const
inline

Definition at line 172 of file NekPoint.hpp.

173  {
174  static_assert(dim::Value >= 3, "invalid dimension");
175  return (*this)[2];
176  }

References Nektar::ThreeD::Value.

Referenced by Nektar::NekPoint< data_type >::NekPoint(), and Nektar::LocalRegions::Expansion3D::v_TraceNormLen().

Member Data Documentation

◆ m_data

template<typename data_type >
DataType Nektar::NekPoint< data_type >::m_data[dim::Value]
private