Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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>

Collaboration diagram for Nektar::NekPoint< data_type >:
Collaboration graph
[legend]

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

Private Attributes

DataType m_data [dim::Value]

Detailed Description

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

Definition at line 61 of file NekPoint.hpp.

Member Typedef Documentation

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

Definition at line 64 of file NekPoint.hpp.

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

Definition at line 65 of file NekPoint.hpp.

Constructor & Destructor Documentation

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

Definition at line 68 of file NekPoint.hpp.

{
// This may be suboptimal if DataType isn't numeric.
// If we use them then maybe we could look at an enable_if
// template to choose a better constructor.
for(unsigned int i = 0; i < dim::Value; ++i)
{
// If you get a compile error pointing you here then
// the DataType being stored in the point doesn't have an
// accessible operator= or default copy constructor.
m_data[i] = DataType();
}
}
template<typename data_type>
Nektar::NekPoint< data_type >::NekPoint ( const std::string &  pointValues)
inline

Definition at line 82 of file NekPoint.hpp.

{
bool result = fromString(pointValues, *this);
ASSERTL0(result, "Unable to create a point from a string.");
}
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 88 of file NekPoint.hpp.

{
m_data[0] = x;
m_data[1] = y;
m_data[2] = z;
}
template<typename data_type>
Nektar::NekPoint< data_type >::NekPoint ( typename boost::call_traits< DataType >::const_reference  a)
inlineexplicit

Definition at line 97 of file NekPoint.hpp.

{
boost::function_requires< Nektar::AssignableConcept<DataType> >();
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] = a;
}
}
template<typename data_type>
Nektar::NekPoint< data_type >::NekPoint ( const NekPoint< DataType > &  rhs)
inline

Definition at line 108 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] = rhs.m_data[i];
}
}
template<typename data_type>
Nektar::NekPoint< data_type >::~NekPoint ( )
inline

Definition at line 116 of file NekPoint.hpp.

{
}

Member Function Documentation

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

Definition at line 182 of file NekPoint.hpp.

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

{
BOOST_STATIC_ASSERT(dim::Value >= 1);
return m_data[0];
}
template<typename data_type>
std::string Nektar::NekPoint< data_type >::AsString ( ) const
inline

Definition at line 352 of file NekPoint.hpp.

Referenced by Nektar::operator<<().

{
std::string result = "(";
for(unsigned int i = 0; i < dim::Value; ++i)
{
result += boost::lexical_cast<std::string>(m_data[i]);
if( i < dim::Value-1 )
{
result += ", ";
}
}
result += ")";
return result;
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::b ( ) const
inline

Definition at line 188 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 2);
return (*this)[1];
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::c ( ) const
inline

Definition at line 194 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 3);
return (*this)[2];
}
template<typename data_type>
static unsigned int Nektar::NekPoint< data_type >::dimension ( )
inlinestatic

Returns the number of dimensions for the point.

Definition at line 131 of file NekPoint.hpp.

{ return dim::Value; }
template<typename data_type>
const DataType* Nektar::NekPoint< data_type >::GetPtr ( ) const
inline

Definition at line 254 of file NekPoint.hpp.

{
return &m_data[0];
}
template<typename data_type>
void Nektar::NekPoint< data_type >::negate ( )
inline

Arithmetic Routines.

Definition at line 281 of file NekPoint.hpp.

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

{
for(int i=0; i < dim::Value; ++i)
{
(*this)[i] = -(*this)[i];
}
}
template<typename data_type>
bool Nektar::NekPoint< data_type >::operator!= ( const NekPoint< DataType > &  rhs) const
inline

Definition at line 273 of file NekPoint.hpp.

{
return !(*this == rhs);
}
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 142 of file NekPoint.hpp.

{
ASSERTL0( (i>=0) && (i<dim::Value), "Invalid access to NekPoint data via parenthesis operator: index out of range");
return m_data[i];
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::operator() ( unsigned int  i) const
inline

Definition at line 148 of file NekPoint.hpp.

{
ASSERTL0( (i>=0) && (i<dim::Value), "Invalid access to NekPoint data via parenthesis operator: index out of range");
return m_data[i];
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator*= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 334 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] *= rhs;
}
return *this;
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator+= ( const NekPoint< DataType > &  rhs)
inline

Definition at line 297 of file NekPoint.hpp.

{
for(unsigned int i=0; i < dim::Value; ++i)
{
m_data[i] += rhs.m_data[i];
}
return *this;
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator+= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 306 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] += rhs;
}
return *this;
}
template<typename data_type>
NekPoint<DataType> Nektar::NekPoint< data_type >::operator- ( ) const
inline

Definition at line 289 of file NekPoint.hpp.

{
NekPoint<DataType> result(*this);
result.negate();
return result;
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator-= ( const NekPoint< DataType > &  rhs)
inline

Definition at line 315 of file NekPoint.hpp.

{
for(unsigned int i=0; i < dim::Value; ++i)
{
m_data[i] -= rhs.m_data[i];
}
return *this;
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator-= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 325 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] -= rhs;
}
return *this;
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator/= ( typename boost::call_traits< DataType >::param_type  rhs)
inline

Definition at line 343 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] /= rhs;
}
return *this;
}
template<typename data_type>
NekPoint<DataType>& Nektar::NekPoint< data_type >::operator= ( const NekPoint< DataType > &  rhs)
inline

Definition at line 121 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
m_data[i] = rhs.m_data[i];
}
return *this;
}
template<typename data_type>
bool Nektar::NekPoint< data_type >::operator== ( const NekPoint< DataType > &  rhs) const
inline

Definition at line 259 of file NekPoint.hpp.

{
for(unsigned int i = 0; i < dim::Value; ++i)
{
// If you get a compile error here then you have to
// add a != operator to the DataType class.
if( m_data[i] != rhs.m_data[i] )
{
return false;
}
}
return true;
}
template<typename data_type>
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::operator[] ( unsigned int  i)
inline

Definition at line 154 of file NekPoint.hpp.

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

Definition at line 159 of file NekPoint.hpp.

{
return m_data[i];
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::r ( ) const
inline

Definition at line 200 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 1);
return m_data[0];
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::s ( ) const
inline

Definition at line 206 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 2);
return (*this)[1];
}
template<typename data_type>
void Nektar::NekPoint< data_type >::SetX ( typename boost::call_traits< DataType >::const_reference  val)
inline

Definition at line 218 of file NekPoint.hpp.

Referenced by Nektar::MultiRegions::ExpList::GetExpIndex().

{
BOOST_STATIC_ASSERT(dim::Value >= 1);
m_data[0] = val;
}
template<typename data_type>
void Nektar::NekPoint< data_type >::SetY ( typename boost::call_traits< DataType >::const_reference  val)
inline

Definition at line 224 of file NekPoint.hpp.

Referenced by Nektar::MultiRegions::ExpList::GetExpIndex().

{
BOOST_STATIC_ASSERT(dim::Value >= 2);
m_data[1] = val;
}
template<typename data_type>
void Nektar::NekPoint< data_type >::SetZ ( typename boost::call_traits< DataType >::const_reference  val)
inline

Definition at line 230 of file NekPoint.hpp.

Referenced by Nektar::MultiRegions::ExpList::GetExpIndex().

{
BOOST_STATIC_ASSERT(dim::Value >= 2);
m_data[2] = val;
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::t ( ) const
inline

Definition at line 212 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 3);
return (*this)[2];
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::x ( ) const
inline
template<typename data_type>
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::x ( )
inline

Definition at line 236 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 1);
return (*this)(0);
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::y ( ) const
inline

Definition at line 170 of file NekPoint.hpp.

Referenced by Nektar::SpatialDomains::PointGeom::dist(), Nektar::SpatialDomains::PointGeom::dot(), and Nektar::NekPoint< NekDouble >::NekPoint().

{
BOOST_STATIC_ASSERT(dim::Value >= 2);
return (*this)[1];
}
template<typename data_type>
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::y ( )
inline

Definition at line 242 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 2);
return (*this)(1);
}
template<typename data_type>
boost::call_traits<DataType>::const_reference Nektar::NekPoint< data_type >::z ( ) const
inline

Definition at line 176 of file NekPoint.hpp.

Referenced by Nektar::SpatialDomains::PointGeom::dist(), Nektar::SpatialDomains::PointGeom::dot(), and Nektar::NekPoint< NekDouble >::NekPoint().

{
BOOST_STATIC_ASSERT(dim::Value >= 3);
return (*this)[2];
}
template<typename data_type>
boost::call_traits<DataType>::reference Nektar::NekPoint< data_type >::z ( )
inline

Definition at line 248 of file NekPoint.hpp.

{
BOOST_STATIC_ASSERT(dim::Value >= 3);
return (*this)(2);
}

Member Data Documentation

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