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. More...
 
 FourierPoints (const FourierPoints &points)
 Copy constructor should not be called. More...
 
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 >
 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.

55  {
56  }
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, and Nektar::LibUtilities::Points< NekDouble >::m_InterpManager.

65  :PointsBaseType(key)
66  {
67  m_InterpManager.RegisterCreator(PointsKey(0, eGaussGaussLegendre),
68  boost::bind(&FourierPoints::CreateMatrix, this, _1));
69  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauMLegendre),
70  boost::bind(&FourierPoints::CreateMatrix, this, _1));
71  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauPLegendre),
72  boost::bind(&FourierPoints::CreateMatrix, this, _1));
73  m_InterpManager.RegisterCreator(PointsKey(0, eGaussLobattoLegendre),
74  boost::bind(&FourierPoints::CreateMatrix, this, _1));
75  m_InterpManager.RegisterCreator(PointsKey(0, eGaussGaussChebyshev),
76  boost::bind(&FourierPoints::CreateMatrix, this, _1));
77  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauMChebyshev),
78  boost::bind(&FourierPoints::CreateMatrix, this, _1));
79  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauPChebyshev),
80  boost::bind(&FourierPoints::CreateMatrix, this, _1));
81  m_InterpManager.RegisterCreator(PointsKey(0, eGaussLobattoChebyshev),
82  boost::bind(&FourierPoints::CreateMatrix, this, _1));
83  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauMAlpha0Beta1),
84  boost::bind(&FourierPoints::CreateMatrix, this, _1));
85  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauMAlpha0Beta2),
86  boost::bind(&FourierPoints::CreateMatrix, this, _1));
87  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauMAlpha1Beta0),
88  boost::bind(&FourierPoints::CreateMatrix, this, _1));
89  m_InterpManager.RegisterCreator(PointsKey(0, eGaussRadauMAlpha2Beta0),
90  boost::bind(&FourierPoints::CreateMatrix, this, _1));
91  m_InterpManager.RegisterCreator(PointsKey(0, ePolyEvenlySpaced),
92  boost::bind(&FourierPoints::CreateMatrix, this, _1));
93  m_InterpManager.RegisterCreator(PointsKey(0, eFourierEvenlySpaced),
94  boost::bind(&FourierPoints::CreateMatrix, this, _1));
95  }
1D Gauss-Radau-Chebyshev quadrature points, pinned at x=-1
Definition: PointsType.h:52
1D Gauss-Radau-Legendre quadrature points, pinned at x=1
Definition: PointsType.h:49
boost::shared_ptr< NekMatrix< NekDouble > > CreateMatrix(const PointsKey &pkey)
1D Gauss-Gauss-Legendre quadrature points
Definition: PointsType.h:47
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:57
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
1D Evenly-spaced points using Fourier Fit
Definition: PointsType.h:64
1D Gauss-Radau-Chebyshev quadrature points, pinned at x=1
Definition: PointsType.h:53
1D Gauss-Gauss-Chebyshev quadrature points
Definition: PointsType.h:51
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:58
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:56
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_InterpManager
Definition: Points.h:352
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:55
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:50
1D Gauss-Radau-Legendre quadrature points, pinned at x=-1
Definition: PointsType.h:48
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:54
Points< NekDouble > PointsBaseType
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 ( )
privatevirtual

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

Definition at line 90 of file FourierPoints.cpp.

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

91  {
92  //// Allocate the derivative matrix.
94 
95  unsigned int npts = m_pointsKey.GetNumPoints();
96 
97  for(unsigned int i=1;i<npts;++i)
98  {
99  m_derivmatrix[0]->SetValue(i,i, 0.0);
100  }
101 
102  for(unsigned int i=1;i<npts;++i)
103  {
104  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));
105  }
106 
107  for(unsigned int i=1;i<npts;++i)
108  {
109  for(unsigned int j=0;j<npts;++j)
110  {
111  m_derivmatrix[0]->SetValue(i,j, (*m_derivmatrix[0])(0,(j-i+npts)%npts));
112  }
113  }
114  }
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:351
static std::string npts
Definition: InputFld.cpp:43
double NekDouble
virtual void CalculateDerivMatrix()
Definition: Points.h:371
unsigned int GetNumPoints() const
Definition: Points.h:106
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().

166  {
167  const NekDouble h = 2.0/m_pointsKey.GetNumPoints();
168  for(unsigned int i=0;i<npts;++i)
169  {
170  for(unsigned int j=0;j<m_pointsKey.GetNumPoints();++j)
171  {
172  interp[i*m_pointsKey.GetNumPoints()+j] = PeriodicSincFunction(M_PI*(xpoints[i]-m_points[0][j]),h);
173  }
174  }
175  }
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
static std::string npts
Definition: InputFld.cpp:43
double NekDouble
unsigned int GetNumPoints() const
Definition: Points.h:106
NekDouble PeriodicSincFunction(const NekDouble x, const NekDouble h)
void Nektar::LibUtilities::FourierPoints::CalculatePoints ( )
privatevirtual

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

Definition at line 49 of file FourierPoints.cpp.

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

50  {
51  // Allocate the storage for points
53 
54  unsigned int npts = m_pointsKey.GetNumPoints();
55  ASSERTL0(!(npts%2), "Fourier points need to be of even order");
56 
57  if(npts==1)
58  {
59  m_points[0][0] = 0.0;
60  }
61  else
62  {
63  NekDouble dx = 2.0/(NekDouble)(npts);
64  for(unsigned int i=0;i<npts;++i)
65  {
66  m_points[0][i] = -1.0 + i*dx;
67  }
68  }
69  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
static std::string npts
Definition: InputFld.cpp:43
double NekDouble
unsigned int GetNumPoints() const
Definition: Points.h:106
void Nektar::LibUtilities::FourierPoints::CalculateWeights ( )
privatevirtual

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

Definition at line 71 of file FourierPoints.cpp.

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

72  {
73  // Allocate the storage for points
75 
76  unsigned int npts = m_pointsKey.GetNumPoints();
77  if(npts==1)
78  {
79  m_weights[0] = 1.0; //midpoint rule
80  }
81  else
82  {
83  for(unsigned int i=0; i<npts; ++i)
84  {
85  m_weights[i] = 1.0/(NekDouble)npts;
86  }
87  }
88  }
static std::string npts
Definition: InputFld.cpp:43
Array< OneD, DataType > m_weights
Definition: Points.h:350
double NekDouble
unsigned int GetNumPoints() const
Definition: Points.h:106
boost::shared_ptr< Points< NekDouble > > Nektar::LibUtilities::FourierPoints::Create ( const PointsKey key)
static

Definition at line 116 of file FourierPoints.cpp.

117  {
118  boost::shared_ptr<Points<NekDouble> > returnval(MemoryManager<FourierPoints>::AllocateSharedPtr(key));
119 
120  returnval->Initialize();
121 
122  return returnval;
123  }
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().

127  {
128  int numpoints = pkey.GetNumPoints();
129  Array<OneD, const NekDouble> xpoints;
130 
131  PointsManager()[pkey]->GetPoints(xpoints);
132 
133  /// Delegate to function below.
134  return GetI(numpoints, xpoints);
135  }
PointsManagerT & PointsManager(void)
const MatrixSharedPtrType GetI(const PointsKey &pkey)
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().

138  {
139  ASSERTL0(pkey.GetPointsDim()==1, "Fourier Points can only interp to other 1d point distributions");
140 
141  return m_InterpManager[pkey];
142  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_InterpManager
Definition: Points.h:352
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().

145  {
146  int numpoints = 1;
147 
148  /// Delegate to function below.
149  return GetI(numpoints, x);
150  }
const MatrixSharedPtrType GetI(const PointsKey &pkey)
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().

153  {
154  Array<OneD, NekDouble> interp(GetNumPoints()*numpoints);
155 
156  CalculateInterpMatrix(numpoints, x, interp);
157 
158  NekDouble* t = interp.data();
159  unsigned int np = GetNumPoints();
160  boost::shared_ptr< NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr(numpoints,np,t));
161 
162  return returnval;
163  }
void CalculateInterpMatrix(unsigned int npts, const Array< OneD, const NekDouble > &xpoints, Array< OneD, NekDouble > &interp)
unsigned int GetNumPoints() const
Definition: Points.h:246
double NekDouble
NekDouble Nektar::LibUtilities::FourierPoints::PeriodicSincFunction ( const NekDouble  x,
const NekDouble  h 
)
private

Definition at line 177 of file FourierPoints.cpp.

Referenced by CalculateInterpMatrix().

178  {
179  // This formula is based upon a mapped version of
180  // the periodic sinc presented in Trefethen's "Spectral Methods
181  // in Matlab"
182 
183  NekDouble y = 1.0;
184 
185  if(fabs(x)>1.0e-12)
186  {
187  y = sin(M_PI*x/(M_PI*h))/((2.0/h)*tan(0.5*x));
188  }
189 
190  return y;
191  }
double NekDouble