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 53 of file NekPoint.hpp.

Member Typedef Documentation

◆ DataType

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

Definition at line 56 of file NekPoint.hpp.

◆ dim

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

Definition at line 57 of file NekPoint.hpp.

Constructor & Destructor Documentation

◆ NekPoint() [1/5]

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

Definition at line 60 of file NekPoint.hpp.

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

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

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 80 of file NekPoint.hpp.

83  {
84  m_data[0] = x;
85  m_data[1] = y;
86  m_data[2] = z;
87  }
boost::call_traits< DataType >::const_reference z() const
Definition: NekPoint.hpp:170
boost::call_traits< DataType >::const_reference x() const
Definition: NekPoint.hpp:158
boost::call_traits< DataType >::const_reference y() const
Definition: NekPoint.hpp:164

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 89 of file NekPoint.hpp.

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

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 98 of file NekPoint.hpp.

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

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 106 of file NekPoint.hpp.

107  {
108  }

Member Function Documentation

◆ a()

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

Definition at line 176 of file NekPoint.hpp.

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

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 346 of file NekPoint.hpp.

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

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 182 of file NekPoint.hpp.

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

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 188 of file NekPoint.hpp.

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

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 121 of file NekPoint.hpp.

121 { return dim::Value; }

References Nektar::ThreeD::Value.

◆ GetPtr()

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

Definition at line 248 of file NekPoint.hpp.

249  {
250  return &m_data[0];
251  }

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

◆ negate()

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

Arithmetic Routines.

Definition at line 275 of file NekPoint.hpp.

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

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 267 of file NekPoint.hpp.

268  {
269  return !(*this == rhs);
270  }

◆ 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.

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

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 328 of file NekPoint.hpp.

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

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 291 of file NekPoint.hpp.

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

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 300 of file NekPoint.hpp.

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

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 283 of file NekPoint.hpp.

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

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 309 of file NekPoint.hpp.

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

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 319 of file NekPoint.hpp.

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

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 337 of file NekPoint.hpp.

338  {
339  for(unsigned int i = 0; i < dim::Value; ++i)
340  {
341  m_data[i] /= rhs;
342  }
343  return *this;
344  }

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 111 of file NekPoint.hpp.

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

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 253 of file NekPoint.hpp.

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

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 148 of file NekPoint.hpp.

149  {
150  return m_data[i];
151  }

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 153 of file NekPoint.hpp.

154  {
155  return m_data[i];
156  }

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 194 of file NekPoint.hpp.

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

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 200 of file NekPoint.hpp.

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

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 212 of file NekPoint.hpp.

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

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 218 of file NekPoint.hpp.

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

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 224 of file NekPoint.hpp.

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

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 206 of file NekPoint.hpp.

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

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 230 of file NekPoint.hpp.

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

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 158 of file NekPoint.hpp.

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

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

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

◆ y() [1/2]

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

Definition at line 236 of file NekPoint.hpp.

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

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 164 of file NekPoint.hpp.

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

References Nektar::ThreeD::Value.

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

◆ z() [1/2]

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

Definition at line 242 of file NekPoint.hpp.

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

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 170 of file NekPoint.hpp.

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

References Nektar::ThreeD::Value.

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

Member Data Documentation

◆ m_data

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