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

#include <NodalTriEvenlySpaced.h>

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

Public Member Functions

virtual ~NodalTriEvenlySpaced ()
 
 NodalTriEvenlySpaced (const PointsKey &key)
 
const MatrixSharedPtrType GetI (const PointsKey &pkey)
 
const MatrixSharedPtrType GetI (const Array< OneD, const NekDouble > &x, const Array< OneD, const NekDouble > &y)
 
- 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)
 
virtual const MatrixSharedPtrType GetI (unsigned int, const Array< OneD, const DataType > &x)
 
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

 NodalTriEvenlySpaced ()
 Deafult constructor should not be called except by Create matrix. More...
 
void CalculatePoints ()
 
void CalculateWeights ()
 
void CalculateDerivMatrix ()
 
void NodalPointReorder2d ()
 
void CalculateInterpMatrix (const Array< OneD, const NekDouble > &xi, const Array< OneD, const NekDouble > &yi, Array< OneD, NekDouble > &interp)
 

Private Attributes

std::shared_ptr< NodalUtilTrianglem_util
 

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 51 of file NodalTriEvenlySpaced.h.

Constructor & Destructor Documentation

◆ ~NodalTriEvenlySpaced()

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

Definition at line 54 of file NodalTriEvenlySpaced.h.

55  {
56 
57  }

◆ NodalTriEvenlySpaced() [1/2]

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

Definition at line 59 of file NodalTriEvenlySpaced.h.

References Create(), and LIB_UTILITIES_EXPORT.

59  : PointsBaseType(key)
60  {
61 
62  }
Points< NekDouble > PointsBaseType

◆ NodalTriEvenlySpaced() [2/2]

Nektar::LibUtilities::NodalTriEvenlySpaced::NodalTriEvenlySpaced ( )
inlineprivate

Deafult constructor should not be called except by Create matrix.

Definition at line 98 of file NodalTriEvenlySpaced.h.

References CalculateDerivMatrix(), CalculateInterpMatrix(), CalculatePoints(), CalculateWeights(), and NodalPointReorder2d().

99  {
100  }
static const PointsKey NullPointsKey(0, eNoPointsType)
Points< NekDouble > PointsBaseType

Member Function Documentation

◆ CalculateDerivMatrix()

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

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

Definition at line 135 of file NodalTriEvenlySpaced.cpp.

References Nektar::LibUtilities::Points< NekDouble >::CalculateDerivMatrix(), Nektar::LibUtilities::Points< NekDouble >::m_derivmatrix, and m_util.

Referenced by NodalTriEvenlySpaced().

136  {
137 
138  // Allocate the derivative matrix.
140 
141  m_derivmatrix[0] = m_util->GetDerivMatrix(0);
142  m_derivmatrix[1] = m_util->GetDerivMatrix(1);
143  }
std::shared_ptr< NodalUtilTriangle > m_util
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:383

◆ CalculateInterpMatrix()

void Nektar::LibUtilities::NodalTriEvenlySpaced::CalculateInterpMatrix ( const Array< OneD, const NekDouble > &  xi,
const Array< OneD, const NekDouble > &  yi,
Array< OneD, NekDouble > &  interp 
)
private

Definition at line 119 of file NodalTriEvenlySpaced.cpp.

References m_util, and Vmath::Vcopy().

Referenced by GetI(), and NodalTriEvenlySpaced().

122  {
123  Array<OneD, Array<OneD, NekDouble> > xi(2);
124  xi[0] = xia;
125  xi[1] = yia;
126 
127  std::shared_ptr<NekMatrix<NekDouble> > mat =
128  m_util->GetInterpolationMatrix(xi);
129  Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(),
130  1, &interp[0], 1);
131  }
std::shared_ptr< NodalUtilTriangle > m_util
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ CalculatePoints()

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

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

Definition at line 78 of file NodalTriEvenlySpaced.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::Points< NekDouble >::CalculatePoints(), Nektar::LibUtilities::Points< NekDouble >::GetNumPoints(), Nektar::LibUtilities::Points< NekDouble >::m_points, m_util, and NodalPointReorder2d().

Referenced by NodalTriEvenlySpaced().

79  {
80  // Allocate the storage for points
82 
83  // Populate m_points
84  unsigned int npts = GetNumPoints();
85  NekDouble delta = 2.0/(npts - 1.0);
86  for(int i=0, index=0; i<npts; ++i){ // y-direction
87  for(int j=0; j<npts-i; ++j,++index){ // x-direction
88  NekDouble x = -1.0 + j*delta;
89  NekDouble y = -1.0 + i*delta;
90  m_points[0][index] = x;
91  m_points[1][index] = y;
92  }
93  }
94 
96 
98  npts - 1, m_points[0], m_points[1]);
99  }
std::shared_ptr< NodalUtilTriangle > m_util
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
Array< OneD, DataType > m_points[3]
Definition: Points.h:381
unsigned int GetNumPoints() const
Definition: Points.h:272

◆ CalculateWeights()

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

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

Definition at line 102 of file NodalTriEvenlySpaced.cpp.

References Nektar::LibUtilities::Points< NekDouble >::CalculateWeights(), Nektar::NekVector< DataType >::GetPtr(), Nektar::NekVector< DataType >::GetRows(), m_util, and Nektar::LibUtilities::Points< NekDouble >::m_weights.

Referenced by NodalTriEvenlySpaced().

103  {
104  // Allocate the storage for points
106 
107  typedef DataType T;
108 
109  // Solve the Vandermonde system of integrals for the weight vector
110  NekVector<T> w = m_util->GetWeights();
111 
112  m_weights = Array<OneD,T>( w.GetRows(), w.GetPtr() );
113 
114  }
std::shared_ptr< NodalUtilTriangle > m_util
Array< OneD, DataType > m_weights
Definition: Points.h:382

◆ Create()

std::shared_ptr< PointsBaseType > Nektar::LibUtilities::NodalTriEvenlySpaced::Create ( const PointsKey key)
static

Definition at line 145 of file NodalTriEvenlySpaced.cpp.

Referenced by NodalTriEvenlySpaced().

146  {
147  std::shared_ptr<PointsBaseType> returnval(MemoryManager<NodalTriEvenlySpaced>::AllocateSharedPtr(key));
148 
149  returnval->Initialize();
150 
151  return returnval;
152  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ GetI() [1/2]

const MatrixSharedPtrType Nektar::LibUtilities::NodalTriEvenlySpaced::GetI ( const PointsKey pkey)
inlinevirtual

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

Definition at line 67 of file NodalTriEvenlySpaced.h.

References ASSERTL0, Nektar::LibUtilities::PointsKey::GetPointsDim(), and Nektar::LibUtilities::PointsManager().

68  {
69  ASSERTL0(pkey.GetPointsDim() == 2,
70  "NodalTriEvenlySpaced Points can only interp to other "
71  "2d point distributions");
72  Array<OneD, const NekDouble> x, y;
73  PointsManager()[pkey]->GetPoints(x, y);
74  return GetI(x, y);
75  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
PointsManagerT & PointsManager(void)
const MatrixSharedPtrType GetI(const PointsKey &pkey)

◆ GetI() [2/2]

const MatrixSharedPtrType Nektar::LibUtilities::NodalTriEvenlySpaced::GetI ( const Array< OneD, const NekDouble > &  x,
const Array< OneD, const NekDouble > &  y 
)
inlinevirtual

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

Definition at line 77 of file NodalTriEvenlySpaced.h.

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

80  {
81  size_t numpoints = x.num_elements();
82  unsigned int np = GetTotNumPoints();
83 
84  Array<OneD, NekDouble> interp(GetTotNumPoints()*numpoints);
85  CalculateInterpMatrix(x, y, interp);
86 
87  NekDouble* d = interp.data();
88  return MemoryManager<NekMatrix<NekDouble> >
89  ::AllocateSharedPtr(numpoints, np, d);
90  }
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xi, const Array< OneD, const NekDouble > &yi, Array< OneD, NekDouble > &interp)
double NekDouble
unsigned int GetTotNumPoints() const
Definition: Points.h:277

◆ NodalPointReorder2d()

void Nektar::LibUtilities::NodalTriEvenlySpaced::NodalPointReorder2d ( )
private

Definition at line 154 of file NodalTriEvenlySpaced.cpp.

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

Referenced by CalculatePoints(), and NodalTriEvenlySpaced().

155  {
156  unsigned int npts = GetNumPoints();
157  using std::vector;
158  vector<int> vertex;
159  vector<int> iEdge_1; // interior edge points on the bottom triangle edge
160  vector<int> iEdge_2; // interior edge points on the right triangle edge
161  vector<int> iEdge_3; // interior edge points on the left triangle edge
162  vector<int> interiorPoints;
163  vector<int> map;
164 
165  // Build the lattice triangle left to right - bottom to top
166  for(int i=0, index=0; i<npts; ++i){ // y-direction
167  for(int j=0; j<npts-i; ++j,++index){ // x-direction
168 
169  if( isVertex(i,j,npts) ) {
170 
171  vertex.push_back(index);
172 
173  } else if( isEdge(i,j,npts) ) { // interior edge
174 
175  if(isEdge_1(i,j,npts)){ // bottom edge
176 
177  iEdge_1.push_back(index);
178 
179  }else if(isEdge_2(i,j,npts)){ // right edge
180 
181  iEdge_2.push_back(index);
182 
183  }else // left edge
184  {
185  // Add backwards. This is because of counter clockwise.
186  iEdge_3.insert(iEdge_3.begin(), index);
187  }
188 
189  } else { // Interior points
190 
191  interiorPoints.push_back(index);
192  }
193  }
194  }
195 
196  // Mapping the vertex, edges, and interior points using the permutation matrix,
197  // so the points are ordered anticlockwise.
198  for(unsigned int k=0; k<vertex.size(); ++k){
199 
200  map.push_back(vertex[k]);
201  }
202 
203  for(unsigned int k=0; k<iEdge_1.size(); ++k){
204 
205  map.push_back(iEdge_1[k]);
206  }
207 
208  for(unsigned int k=0; k<iEdge_2.size(); ++k){
209 
210  map.push_back(iEdge_2[k]);
211  }
212 
213  for(unsigned int k=0; k<iEdge_3.size(); ++k){
214 
215  map.push_back(iEdge_3[k]);
216  }
217 
218  for(unsigned int k=0; k<interiorPoints.size(); ++k){
219 
220  map.push_back(interiorPoints[k]);
221  }
222 
223 
224  Array<OneD,NekDouble> points[2];
225  points[0] = Array<OneD,NekDouble>(GetTotNumPoints());
226  points[1] = Array<OneD,NekDouble>(GetTotNumPoints());
227  for(unsigned int index=0; index<map.size(); ++index){
228  points[0][index] = m_points[0][index];
229  points[1][index] = m_points[1][index];
230  }
231 
232  for(unsigned int index=0; index<map.size(); ++index){
233  m_points[0][index] = points[0][map[index]];
234  m_points[1][index] = points[1][map[index]];
235  }
236 
237  }
unsigned int GetTotNumPoints() const
Definition: Points.h:277
Array< OneD, DataType > m_points[3]
Definition: Points.h:381
unsigned int GetNumPoints() const
Definition: Points.h:272

Member Data Documentation

◆ initPointsManager

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

Definition at line 93 of file NodalTriEvenlySpaced.h.

◆ m_util

std::shared_ptr<NodalUtilTriangle> Nektar::LibUtilities::NodalTriEvenlySpaced::m_util
private