Nektar++
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
Nektar::LibUtilities::FourierPoints Class Reference

#include <FourierPoints.h>

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

Public Member Functions

virtual ~FourierPoints ()
 
std::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 std::shared_ptr< PointsBaseTypeCreate (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)
 

Static Private Attributes

static bool initPointsManager []
 

Additional Inherited Members

- Public Types inherited from Nektar::LibUtilities::Points< NekDouble >
typedef NekDouble DataType
 
typedef std::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::opLessm_InterpManager
 
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLessm_GalerkinProjectionManager
 

Detailed Description

Definition at line 48 of file FourierPoints.h.

Constructor & Destructor Documentation

◆ ~FourierPoints()

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

Definition at line 51 of file FourierPoints.h.

References Create(), CreateMatrix(), GetI(), and LIB_UTILITIES_EXPORT.

52  {
53  }

◆ FourierPoints() [1/3]

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

Definition at line 62 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.

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

◆ FourierPoints() [2/3]

Nektar::LibUtilities::FourierPoints::FourierPoints ( )
private

Default constructor should not be called except by Create method.

◆ FourierPoints() [3/3]

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

Copy constructor should not be called.

Member Function Documentation

◆ CalculateDerivMatrix()

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

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

Definition at line 92 of file FourierPoints.cpp.

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

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

◆ CalculateInterpMatrix()

void Nektar::LibUtilities::FourierPoints::CalculateInterpMatrix ( unsigned int  npts,
const Array< OneD, const NekDouble > &  xpoints,
Array< OneD, NekDouble > &  interp 
)
private

Definition at line 167 of file FourierPoints.cpp.

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

Referenced by GetI().

168  {
169  const NekDouble h = 2.0/m_pointsKey.GetNumPoints();
170  for(unsigned int i=0;i<npts;++i)
171  {
172  for(unsigned int j=0;j<m_pointsKey.GetNumPoints();++j)
173  {
174  interp[i*m_pointsKey.GetNumPoints()+j] = PeriodicSincFunction(M_PI*(xpoints[i]-m_points[0][j]),h);
175  }
176  }
177  }
double NekDouble
Array< OneD, DataType > m_points[3]
Definition: Points.h:381
NekDouble PeriodicSincFunction(const NekDouble x, const NekDouble h)
unsigned int GetNumPoints() const
Definition: Points.h:107

◆ CalculatePoints()

void Nektar::LibUtilities::FourierPoints::CalculatePoints ( )
privatevirtual

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

Definition at line 51 of file FourierPoints.cpp.

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

52  {
53  // Allocate the storage for points
55 
56  unsigned int npts = m_pointsKey.GetNumPoints();
57  ASSERTL0(!(npts%2), "Fourier points need to be of even order");
58 
59  if(npts==1)
60  {
61  m_points[0][0] = 0.0;
62  }
63  else
64  {
65  NekDouble dx = 2.0/(NekDouble)(npts);
66  for(unsigned int i=0;i<npts;++i)
67  {
68  m_points[0][i] = -1.0 + i*dx;
69  }
70  }
71  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
double NekDouble
Array< OneD, DataType > m_points[3]
Definition: Points.h:381
unsigned int GetNumPoints() const
Definition: Points.h:107

◆ CalculateWeights()

void Nektar::LibUtilities::FourierPoints::CalculateWeights ( )
privatevirtual

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

Definition at line 73 of file FourierPoints.cpp.

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

74  {
75  // Allocate the storage for points
77 
78  unsigned int npts = m_pointsKey.GetNumPoints();
79  if(npts==1)
80  {
81  m_weights[0] = 1.0; //midpoint rule
82  }
83  else
84  {
85  for(unsigned int i=0; i<npts; ++i)
86  {
87  m_weights[i] = 1.0/(NekDouble)npts;
88  }
89  }
90  }
Array< OneD, DataType > m_weights
Definition: Points.h:382
double NekDouble
unsigned int GetNumPoints() const
Definition: Points.h:107

◆ Create()

std::shared_ptr< Points< NekDouble > > Nektar::LibUtilities::FourierPoints::Create ( const PointsKey key)
static

Definition at line 118 of file FourierPoints.cpp.

Referenced by ~FourierPoints().

119  {
120  std::shared_ptr<Points<NekDouble> > returnval(MemoryManager<FourierPoints>::AllocateSharedPtr(key));
121 
122  returnval->Initialize();
123 
124  return returnval;
125  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ CreateMatrix()

std::shared_ptr< NekMatrix< NekDouble > > Nektar::LibUtilities::FourierPoints::CreateMatrix ( const PointsKey pkey)

Delegate to function below.

Definition at line 128 of file FourierPoints.cpp.

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

Referenced by FourierPoints(), and ~FourierPoints().

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

◆ GetI() [1/3]

const std::shared_ptr< NekMatrix< NekDouble > > Nektar::LibUtilities::FourierPoints::GetI ( const PointsKey pkey)
virtual

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

Definition at line 139 of file FourierPoints.cpp.

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

Referenced by CreateMatrix(), GetI(), and ~FourierPoints().

140  {
141  ASSERTL0(pkey.GetPointsDim()==1, "Fourier Points can only interp to other 1d point distributions");
142 
143  return m_InterpManager[pkey];
144  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_InterpManager
Definition: Points.h:384

◆ GetI() [2/3]

const std::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 146 of file FourierPoints.cpp.

References GetI().

147  {
148  int numpoints = 1;
149 
150  /// Delegate to function below.
151  return GetI(numpoints, x);
152  }
const MatrixSharedPtrType GetI(const PointsKey &pkey)

◆ GetI() [3/3]

const std::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 154 of file FourierPoints.cpp.

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

155  {
156  Array<OneD, NekDouble> interp(GetNumPoints()*numpoints);
157 
158  CalculateInterpMatrix(numpoints, x, interp);
159 
160  NekDouble* t = interp.data();
161  unsigned int np = GetNumPoints();
162  std::shared_ptr< NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr(numpoints,np,t));
163 
164  return returnval;
165  }
void CalculateInterpMatrix(unsigned int npts, const Array< OneD, const NekDouble > &xpoints, Array< OneD, NekDouble > &interp)
double NekDouble
unsigned int GetNumPoints() const
Definition: Points.h:272

◆ PeriodicSincFunction()

NekDouble Nektar::LibUtilities::FourierPoints::PeriodicSincFunction ( const NekDouble  x,
const NekDouble  h 
)
private

Definition at line 179 of file FourierPoints.cpp.

Referenced by CalculateInterpMatrix().

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

Member Data Documentation

◆ initPointsManager

bool Nektar::LibUtilities::FourierPoints::initPointsManager
staticprivate
Initial value:

Definition at line 96 of file FourierPoints.h.