Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
Nektar::LibUtilities::FourierPoints Class Reference

#include <FourierPoints.h>

Inheritance diagram for Nektar::LibUtilities::FourierPoints:
Inheritance graph
[legend]
Collaboration diagram for Nektar::LibUtilities::FourierPoints:
Collaboration graph
[legend]

Public Member Functions

virtual ~FourierPoints ()
boost::shared_ptr< NekMatrix
< NekDouble > > 
CreateMatrix (const PointsKey &pkey)
const MatrixSharedPtrType GetI (const PointsKey &pkey)
const MatrixSharedPtrType GetI (const Array< OneD, const NekDouble > &x)
const MatrixSharedPtrType GetI (unsigned int numpoints, const Array< OneD, const NekDouble > &x)
 FourierPoints (const PointsKey &key)
- Public Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual ~Points ()
virtual void Initialize (void)
unsigned int GetPointsDim () const
unsigned int GetNumPoints () const
unsigned int GetTotNumPoints () const
PointsType GetPointsType () const
const Array< OneD, const
DataType > & 
GetZ () const
const Array< OneD, const
DataType > & 
GetW () const
void GetZW (Array< OneD, const DataType > &z, Array< OneD, const DataType > &w) const
void GetPoints (Array< OneD, const DataType > &x) const
void GetPoints (Array< OneD, const DataType > &x, Array< OneD, const DataType > &y) const
void GetPoints (Array< OneD, const DataType > &x, Array< OneD, const DataType > &y, Array< OneD, const DataType > &z) const
const MatrixSharedPtrTypeGetD (Direction dir=xDir) const
virtual const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y)
virtual const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y, const Array< OneD, const DataType > &z)
virtual const MatrixSharedPtrType GetGalerkinProjection (const PointsKey &pkey)

Static Public Member Functions

static boost::shared_ptr
< PointsBaseType
Create (const PointsKey &key)

Private Member Functions

 FourierPoints ()
 Default constructor should not be called except by Create method.
 FourierPoints (const FourierPoints &points)
 Copy constructor should not be called.
void CalculatePoints ()
void CalculateWeights ()
void CalculateDerivMatrix ()
void CalculateInterpMatrix (unsigned int npts, const Array< OneD, const NekDouble > &xpoints, Array< OneD, NekDouble > &interp)
NekDouble PeriodicSincFunction (const NekDouble x, const NekDouble h)

Additional Inherited Members

- Public Types inherited from Nektar::LibUtilities::Points< NekDouble >
typedef NekDouble DataType
typedef boost::shared_ptr
< NekMatrix< DataType > > 
MatrixSharedPtrType
- Protected Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual void CalculatePoints ()
virtual void CalculateWeights ()
virtual void CalculateDerivMatrix ()
 Points (const PointsKey &key)
- Protected Attributes inherited from Nektar::LibUtilities::Points< NekDouble >
PointsKey m_pointsKey
Array< OneD, DataTypem_points [3]
Array< OneD, DataTypem_weights
MatrixSharedPtrType m_derivmatrix [3]
NekManager< PointsKey,
NekMatrix< DataType >
, PointsKey::opLess
m_InterpManager
NekManager< PointsKey,
NekMatrix< DataType >
, PointsKey::opLess
m_GalerkinProjectionManager

Detailed Description

Definition at line 51 of file FourierPoints.h.

Constructor & Destructor Documentation

virtual Nektar::LibUtilities::FourierPoints::~FourierPoints ( )
inlinevirtual

Definition at line 54 of file FourierPoints.h.

{
}
Nektar::LibUtilities::FourierPoints::FourierPoints ( const PointsKey key)
inline

Definition at line 65 of file FourierPoints.h.

References CreateMatrix(), Nektar::LibUtilities::eFourierEvenlySpaced, Nektar::LibUtilities::eGaussGaussChebyshev, Nektar::LibUtilities::eGaussGaussLegendre, Nektar::LibUtilities::eGaussLobattoChebyshev, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eGaussRadauMAlpha0Beta1, Nektar::LibUtilities::eGaussRadauMAlpha0Beta2, Nektar::LibUtilities::eGaussRadauMAlpha1Beta0, Nektar::LibUtilities::eGaussRadauMAlpha2Beta0, Nektar::LibUtilities::eGaussRadauMChebyshev, Nektar::LibUtilities::eGaussRadauMLegendre, Nektar::LibUtilities::eGaussRadauPChebyshev, Nektar::LibUtilities::eGaussRadauPLegendre, Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::LibUtilities::Points< NekDouble >::m_InterpManager, and Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::RegisterCreator().

{
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
boost::bind(&FourierPoints::CreateMatrix, this, _1));
}
Nektar::LibUtilities::FourierPoints::FourierPoints ( )
private

Default constructor should not be called except by Create method.

Nektar::LibUtilities::FourierPoints::FourierPoints ( const FourierPoints points)
private

Copy constructor should not be called.

Member Function Documentation

void Nektar::LibUtilities::FourierPoints::CalculateDerivMatrix ( )
private

Definition at line 90 of file FourierPoints.cpp.

References Nektar::LibUtilities::PointsKey::GetNumPoints(), Nektar::LibUtilities::Points< NekDouble >::m_derivmatrix, Nektar::LibUtilities::Points< NekDouble >::m_pointsKey, and npts.

{
//// Allocate the derivative matrix.
unsigned int npts = m_pointsKey.GetNumPoints();
for(unsigned int i=1;i<npts;++i)
{
m_derivmatrix[0]->SetValue(i,i, 0.0);
}
for(unsigned int i=1;i<npts;++i)
{
m_derivmatrix[0]->SetValue(0,i, -0.5*M_PI*pow(-1.0,NekDouble(i))*cos(M_PI*i/npts)/sin(M_PI*i/npts));
}
for(unsigned int i=1;i<npts;++i)
{
for(unsigned int j=0;j<npts;++j)
{
m_derivmatrix[0]->SetValue(i,j, (*m_derivmatrix[0])(0,(j-i+npts)%npts));
}
}
}
void Nektar::LibUtilities::FourierPoints::CalculateInterpMatrix ( unsigned int  npts,
const Array< OneD, const NekDouble > &  xpoints,
Array< OneD, NekDouble > &  interp 
)
private

Definition at line 165 of file FourierPoints.cpp.

References Nektar::LibUtilities::PointsKey::GetNumPoints(), Nektar::LibUtilities::Points< NekDouble >::m_points, Nektar::LibUtilities::Points< NekDouble >::m_pointsKey, npts, and PeriodicSincFunction().

Referenced by GetI().

{
for(unsigned int i=0;i<npts;++i)
{
for(unsigned int j=0;j<m_pointsKey.GetNumPoints();++j)
{
interp[i*m_pointsKey.GetNumPoints()+j] = PeriodicSincFunction(M_PI*(xpoints[i]-m_points[0][j]),h);
}
}
}
void Nektar::LibUtilities::FourierPoints::CalculatePoints ( )
private

Definition at line 49 of file FourierPoints.cpp.

References ASSERTL0, Nektar::LibUtilities::PointsKey::GetNumPoints(), Nektar::LibUtilities::Points< NekDouble >::m_points, Nektar::LibUtilities::Points< NekDouble >::m_pointsKey, and npts.

{
// Allocate the storage for points
unsigned int npts = m_pointsKey.GetNumPoints();
ASSERTL0(!(npts%2), "Fourier points need to be of even order");
if(npts==1)
{
m_points[0][0] = 0.0;
}
else
{
NekDouble dx = 2.0/(NekDouble)(npts);
for(unsigned int i=0;i<npts;++i)
{
m_points[0][i] = -1.0 + i*dx;
}
}
}
void Nektar::LibUtilities::FourierPoints::CalculateWeights ( )
private

Definition at line 71 of file FourierPoints.cpp.

References Nektar::LibUtilities::PointsKey::GetNumPoints(), Nektar::LibUtilities::Points< NekDouble >::m_pointsKey, Nektar::LibUtilities::Points< NekDouble >::m_weights, and npts.

{
// Allocate the storage for points
unsigned int npts = m_pointsKey.GetNumPoints();
if(npts==1)
{
m_weights[0] = 1.0; //midpoint rule
}
else
{
for(unsigned int i=0; i<npts; ++i)
{
m_weights[i] = 1.0/(NekDouble)npts;
}
}
}
boost::shared_ptr< Points< NekDouble > > Nektar::LibUtilities::FourierPoints::Create ( const PointsKey key)
static

Definition at line 116 of file FourierPoints.cpp.

{
boost::shared_ptr<Points<NekDouble> > returnval(MemoryManager<FourierPoints>::AllocateSharedPtr(key));
returnval->Initialize();
return returnval;
}
boost::shared_ptr< NekMatrix< NekDouble > > Nektar::LibUtilities::FourierPoints::CreateMatrix ( const PointsKey pkey)

Delegate to function below.

Definition at line 126 of file FourierPoints.cpp.

References GetI(), Nektar::LibUtilities::PointsKey::GetNumPoints(), and Nektar::LibUtilities::PointsManager().

Referenced by FourierPoints().

{
int numpoints = pkey.GetNumPoints();
Array<OneD, const NekDouble> xpoints;
PointsManager()[pkey]->GetPoints(xpoints);
/// Delegate to function below.
return GetI(numpoints, xpoints);
}
const boost::shared_ptr< NekMatrix< NekDouble > > Nektar::LibUtilities::FourierPoints::GetI ( const PointsKey pkey)
virtual

Reimplemented from Nektar::LibUtilities::Points< NekDouble >.

Definition at line 137 of file FourierPoints.cpp.

References ASSERTL0, Nektar::LibUtilities::PointsKey::GetPointsDim(), and Nektar::LibUtilities::Points< NekDouble >::m_InterpManager.

Referenced by CreateMatrix(), and GetI().

{
ASSERTL0(pkey.GetPointsDim()==1, "Fourier Points can only interp to other 1d point distributions");
return m_InterpManager[pkey];
}
const boost::shared_ptr< NekMatrix< NekDouble > > Nektar::LibUtilities::FourierPoints::GetI ( const Array< OneD, const NekDouble > &  x)
virtual

Delegate to function below.

Reimplemented from Nektar::LibUtilities::Points< NekDouble >.

Definition at line 144 of file FourierPoints.cpp.

References GetI().

{
int numpoints = 1;
/// Delegate to function below.
return GetI(numpoints, x);
}
const boost::shared_ptr< NekMatrix< NekDouble > > Nektar::LibUtilities::FourierPoints::GetI ( unsigned int  numpoints,
const Array< OneD, const NekDouble > &  x 
)
virtual

Reimplemented from Nektar::LibUtilities::Points< NekDouble >.

Definition at line 152 of file FourierPoints.cpp.

References CalculateInterpMatrix(), and Nektar::LibUtilities::Points< NekDouble >::GetNumPoints().

{
Array<OneD, NekDouble> interp(GetNumPoints()*numpoints);
CalculateInterpMatrix(numpoints, x, interp);
NekDouble* t = interp.data();
unsigned int np = GetNumPoints();
boost::shared_ptr< NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr(numpoints,np,t));
return returnval;
}
NekDouble Nektar::LibUtilities::FourierPoints::PeriodicSincFunction ( const NekDouble  x,
const NekDouble  h 
)
private

Definition at line 177 of file FourierPoints.cpp.

Referenced by CalculateInterpMatrix().

{
// This formula is based upon a mapped version of
// the periodic sinc presented in Trefethen's "Spectral Methods
// in Matlab"
NekDouble y = 1.0;
if(fabs(x)>1.0e-12)
{
y = sin(M_PI*x/(M_PI*h))/((2.0/h)*tan(0.5*x));
}
return y;
}