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

#include <NodalTriFekete.h>

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

Public Member Functions

virtual ~NodalTriFekete ()
 
 NodalTriFekete (const PointsKey &key)
 
- Public Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual ~Points ()
 
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
 
const Array< OneD, const NekDouble > & GetBaryWeights () 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
 
const MatrixSharedPtrType GetI (const PointsKey &key)
 
const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x)
 
const MatrixSharedPtrType GetI (unsigned int uint, const Array< OneD, const DataType > &x)
 
const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y)
 
const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y, const Array< OneD, const DataType > &z)
 
const MatrixSharedPtrType GetGalerkinProjection (const PointsKey &pkey)
 

Static Public Member Functions

static std::shared_ptr< PointsBaseTypeCreate (const PointsKey &key)
 

Protected Member Functions

virtual const MatrixSharedPtrType v_GetI (const PointsKey &pkey) override
 
virtual const MatrixSharedPtrType v_GetI (const Array< OneD, const NekDouble > &x, const Array< OneD, const NekDouble > &y) override
 
- Protected Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual void v_Initialize (void)
 
virtual void v_CalculateBaryWeights ()
 This function calculates the barycentric weights used for enhanced interpolation speed. More...
 
 Points (const PointsKey &key)
 
virtual const MatrixSharedPtrType v_GetI (const Array< OneD, const DataType > &x)
 
virtual const MatrixSharedPtrType v_GetI (unsigned int, const Array< OneD, const DataType > &x)
 
virtual const MatrixSharedPtrType v_GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y, const Array< OneD, const DataType > &z)
 
virtual const MatrixSharedPtrType v_GetGalerkinProjection (const PointsKey &pkey)
 

Private Member Functions

 NodalTriFekete ()
 
void NodalPointReorder2d ()
 
virtual void v_CalculatePoints () override
 
virtual void v_CalculateWeights () override
 
virtual void v_CalculateDerivMatrix () override
 
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 Attributes inherited from Nektar::LibUtilities::Points< NekDouble >
PointsKey m_pointsKey
 Points type for this points distributions. More...
 
Array< OneD, DataTypem_points [3]
 Storage for the point locations, allowing for up to a 3D points storage. More...
 
Array< OneD, DataTypem_weights
 Quadrature weights for the weights. More...
 
Array< OneD, DataTypem_bcweights
 Barycentric weights. More...
 
MatrixSharedPtrType m_derivmatrix [3]
 Derivative matrices. More...
 
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLessm_InterpManager
 
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLessm_GalerkinProjectionManager
 

Detailed Description

Definition at line 54 of file NodalTriFekete.h.

Constructor & Destructor Documentation

◆ ~NodalTriFekete()

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

Definition at line 57 of file NodalTriFekete.h.

58  {
59  }

◆ NodalTriFekete() [1/2]

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

Definition at line 61 of file NodalTriFekete.h.

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

◆ NodalTriFekete() [2/2]

Nektar::LibUtilities::NodalTriFekete::NodalTriFekete ( )
inlineprivate

Definition at line 99 of file NodalTriFekete.h.

100  {
101  }
static const PointsKey NullPointsKey(0, eNoPointsType)

Member Function Documentation

◆ CalculateInterpMatrix()

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

Definition at line 147 of file NodalTriFekete.cpp.

150 {
151  Array<OneD, Array<OneD, NekDouble>> xi(2);
152  xi[0] = xia;
153  xi[1] = yia;
154 
155  std::shared_ptr<NekMatrix<NekDouble>> mat =
156  m_util->GetInterpolationMatrix(xi);
157  Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(), 1,
158  &interp[0], 1);
159 }
std::shared_ptr< NodalUtilTriangle > m_util
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1255

References m_util, and Vmath::Vcopy().

Referenced by v_GetI().

◆ Create()

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

Definition at line 172 of file NodalTriFekete.cpp.

173 {
174  std::shared_ptr<PointsBaseType> returnval(
176  returnval->Initialize();
177  return returnval;
178 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ NodalPointReorder2d()

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

Definition at line 180 of file NodalTriFekete.cpp.

181 {
182  int i, j;
183  int cnt;
184  int istart, iend;
185 
186  const int nVerts = 3;
187  const int nEdgeInteriorPoints = GetNumPoints() - 2;
188  const int nBoundaryPoints = 3 * nEdgeInteriorPoints + 3;
189 
190  if (nEdgeInteriorPoints == 0)
191  {
192  return;
193  }
194 
195  // group the points of edge 1 together;
196  istart = nVerts;
197  for (i = cnt = istart; i < nBoundaryPoints; i++)
198  {
199  if (fabs(m_points[1][i] + 1.0) < NekConstants::kNekZeroTol)
200  {
201  std::swap(m_points[0][cnt], m_points[0][i]);
202  std::swap(m_points[1][cnt], m_points[1][i]);
203  cnt++;
204  }
205  }
206 
207  // bubble sort edge 1 (counterclockwise numbering)
208  iend = istart + nEdgeInteriorPoints;
209  for (i = istart; i < iend; i++)
210  {
211  for (j = istart + 1; j < iend; j++)
212  {
213  if (m_points[0][j] < m_points[0][j - 1])
214  {
215  std::swap(m_points[0][j], m_points[0][j - 1]);
216  std::swap(m_points[1][j], m_points[1][j - 1]);
217  }
218  }
219  }
220 
221  // group the points of edge 2 together;
222  istart = iend;
223  for (i = cnt = istart; i < nBoundaryPoints; i++)
224  {
225  if (fabs(m_points[1][i] + m_points[0][i]) < NekConstants::kNekZeroTol)
226  {
227  std::swap(m_points[0][cnt], m_points[0][i]);
228  std::swap(m_points[1][cnt], m_points[1][i]);
229  cnt++;
230  }
231  }
232 
233  // bubble sort edge 2 (counterclockwise numbering)
234  iend = istart + nEdgeInteriorPoints;
235  for (i = istart; i < iend; i++)
236  {
237  for (j = istart + 1; j < iend; j++)
238  {
239  if (m_points[1][j] < m_points[1][j - 1])
240  {
241  std::swap(m_points[0][j], m_points[0][j - 1]);
242  std::swap(m_points[1][j], m_points[1][j - 1]);
243  }
244  }
245  }
246 
247  // group the points of edge 3 together;
248  istart = iend;
249  for (i = cnt = istart; i < nBoundaryPoints; i++)
250  {
251  if (fabs(m_points[0][i] + 1.0) < NekConstants::kNekZeroTol)
252  {
253  std::swap(m_points[0][cnt], m_points[0][i]);
254  std::swap(m_points[1][cnt], m_points[1][i]);
255  cnt++;
256  }
257  }
258  // bubble sort edge 3 (counterclockwise numbering)
259  iend = istart + nEdgeInteriorPoints;
260  for (i = istart; i < iend; i++)
261  {
262  for (j = istart + 1; j < iend; j++)
263  {
264  if (m_points[1][j] > m_points[1][j - 1])
265  {
266  std::swap(m_points[0][j], m_points[0][j - 1]);
267  std::swap(m_points[1][j], m_points[1][j - 1]);
268  }
269  }
270  }
271 
272  if (GetNumPoints() < 5)
273  {
274  // at numpoints = 4 there is only one interior point so doesnt
275  // need sorting
276  return;
277  }
278 
279  // someone forgot to finish this piece of code and tell anyone
280  // that they didnt
281  // face interior nodes needs to be considered
282  // make a copy of the unsorted nodes
283  // bubble sort by smallest y
284  // which will put them into sets of ever decreasing size
285  // which can be bubble sorted by x to obtain the distrobution
286 
287  Array<OneD, NekDouble> xc(m_points[0].size() - iend);
288  Array<OneD, NekDouble> yc(m_points[0].size() - iend);
289  int ct = 0;
290  for (i = iend; i < m_points[0].size(); i++, ct++)
291  {
292  xc[ct] = m_points[0][i];
293  yc[ct] = m_points[1][i];
294  }
295 
296  // sort smallest first
297  bool repeat = true;
298  while (repeat)
299  {
300  repeat = false;
301  for (i = 0; i < xc.size() - 1; i++)
302  {
303  if (yc[i] > yc[i + 1])
304  {
305  std::swap(xc[i], xc[i + 1]);
306  std::swap(yc[i], yc[i + 1]);
307  repeat = true;
308  }
309  }
310  }
311 
312  int offset = 0;
313  int npl = GetNumPoints() - 3;
314  while (npl > 1)
315  {
316  repeat = true;
317  while (repeat)
318  {
319  repeat = false;
320  for (i = offset; i < offset + npl - 1; i++)
321  {
322  if (xc[i] > xc[i + 1])
323  {
324  std::swap(xc[i], xc[i + 1]);
325  std::swap(yc[i], yc[i + 1]);
326  repeat = true;
327  }
328  }
329  }
330  offset += npl;
331  npl--;
332  }
333 
334  // copy back in
335  ct = 0;
336  for (i = iend; i < m_points[0].size(); i++, ct++)
337  {
338  m_points[0][i] = xc[ct];
339  m_points[1][i] = yc[ct];
340  }
341  return;
342 }
size_type size() const
Returns the array's size.
Array< OneD, DataType > m_points[3]
Storage for the point locations, allowing for up to a 3D points storage.
Definition: Points.h:375
unsigned int GetNumPoints() const
Definition: Points.h:273
static const NekDouble kNekZeroTol

References Nektar::LibUtilities::Points< NekDouble >::GetNumPoints(), Nektar::NekConstants::kNekZeroTol, Nektar::LibUtilities::Points< NekDouble >::m_points, and Nektar::Array< OneD, const DataType >::size().

Referenced by v_CalculatePoints().

◆ v_CalculateDerivMatrix()

void Nektar::LibUtilities::NodalTriFekete::v_CalculateDerivMatrix ( )
overrideprivatevirtual

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

Definition at line 163 of file NodalTriFekete.cpp.

164 {
165  // Allocate the derivative matrix.
167 
168  m_derivmatrix[0] = m_util->GetDerivMatrix(0);
169  m_derivmatrix[1] = m_util->GetDerivMatrix(1);
170 }
MatrixSharedPtrType m_derivmatrix[3]
Derivative matrices.
Definition: Points.h:381

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

◆ v_CalculatePoints()

void Nektar::LibUtilities::NodalTriFekete::v_CalculatePoints ( )
overrideprivatevirtual

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

Definition at line 54 of file NodalTriFekete.cpp.

55 {
56  // Allocate the storage for points
58 
59  int index = 0, isum = 0;
60  const int offset = 3; // offset to match Datafile
61  NekDouble b, c;
62  unsigned int numPoints = GetNumPoints();
63 
64  // initialize values
65  for (unsigned int i = 0; i < numPoints - 2; ++i)
66  {
67  index += NodalTriFeketeNPTS[i];
68  }
69 
70  for (unsigned int i = 0; i < NodalTriFeketeNPTS[numPoints - 2];
71  ++i, ++index)
72  {
73  if (int(NodalTriFeketeData[index][0]))
74  {
75  b = NodalTriFeketeData[index][4];
76  c = NodalTriFeketeData[index][5];
77 
78  m_points[0][isum] = 2.0 * b - 1.0;
79  m_points[1][isum] = 2.0 * c - 1.0;
80  isum++;
81  continue;
82  } // end symmetry1
83 
84  if (int(NodalTriFeketeData[index][1]) == 1)
85  {
86  for (unsigned int j = 0; j < 3; ++j)
87  {
88  b = NodalTriFeketeData[index][offset + perm3A_2d[j][1]];
89  c = NodalTriFeketeData[index][offset + perm3A_2d[j][2]];
90  m_points[0][isum] = 2.0 * b - 1.0;
91  m_points[1][isum] = 2.0 * c - 1.0;
92  isum++;
93  } // end j
94  continue;
95  } // end symmetry3a
96 
97  if (int(NodalTriFeketeData[index][1]) == 2)
98  {
99  for (unsigned int j = 0; j < 3; ++j)
100  {
101  b = NodalTriFeketeData[index][offset + perm3B_2d[j][1]];
102  c = NodalTriFeketeData[index][offset + perm3B_2d[j][2]];
103  m_points[0][isum] = 2.0 * b - 1.0;
104  m_points[1][isum] = 2.0 * c - 1.0;
105  isum++;
106  } // end j
107  continue;
108  } // end symmetry3b
109 
110  if (int(NodalTriFeketeData[index][2]))
111  {
112  for (unsigned int j = 0; j < 6; ++j)
113  {
114  b = NodalTriFeketeData[index][offset + perm6_2d[j][1]];
115  c = NodalTriFeketeData[index][offset + perm6_2d[j][2]];
116  m_points[0][isum] = 2.0 * b - 1.0;
117  m_points[1][isum] = 2.0 * c - 1.0;
118  isum++;
119  } // end j
120  continue;
121  } // end symmetry6
122  } // end npts
123 
125 
126  ASSERTL1((static_cast<unsigned int>(isum) == m_pointsKey.GetTotNumPoints()),
127  "sum not equal to npts");
128 
130  numPoints - 1, m_points[0], m_points[1]);
131 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
PointsKey m_pointsKey
Points type for this points distributions.
Definition: Points.h:372
unsigned int GetTotNumPoints() const
Definition: Points.h:177
static const unsigned int perm3A_2d[3][3]
static const NekDouble NodalTriFeketeData[][6]
static const unsigned int perm6_2d[6][3]
static const unsigned int perm3B_2d[3][3]
static const unsigned int NodalTriFeketeNPTS[NodalTriFeketeAvailable]
double NekDouble

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL1, Nektar::LibUtilities::Points< NekDouble >::GetNumPoints(), Nektar::LibUtilities::PointsKey::GetTotNumPoints(), Nektar::LibUtilities::Points< NekDouble >::m_points, Nektar::LibUtilities::Points< NekDouble >::m_pointsKey, m_util, NodalPointReorder2d(), Nektar::LibUtilities::NodalTriFeketeData, Nektar::LibUtilities::NodalTriFeketeNPTS, Nektar::LibUtilities::perm3A_2d, Nektar::LibUtilities::perm3B_2d, Nektar::LibUtilities::perm6_2d, and Nektar::LibUtilities::Points< NekDouble >::v_CalculatePoints().

◆ v_CalculateWeights()

void Nektar::LibUtilities::NodalTriFekete::v_CalculateWeights ( )
overrideprivatevirtual

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

Definition at line 133 of file NodalTriFekete.cpp.

134 {
135  // Allocate the storage for points
137 
138  typedef DataType T;
139 
140  // Solve the Vandermonde system of integrals for the weight vector
141  NekVector<T> w = m_util->GetWeights();
142  m_weights = Array<OneD, T>(w.GetRows(), w.GetPtr());
143 }
Array< OneD, DataType > m_weights
Quadrature weights for the weights.
Definition: Points.h:377

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

◆ v_GetI() [1/2]

virtual const MatrixSharedPtrType Nektar::LibUtilities::NodalTriFekete::v_GetI ( const Array< OneD, const NekDouble > &  x,
const Array< OneD, const NekDouble > &  y 
)
inlineoverrideprotectedvirtual

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

Definition at line 79 of file NodalTriFekete.h.

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

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

◆ v_GetI() [2/2]

virtual const MatrixSharedPtrType Nektar::LibUtilities::NodalTriFekete::v_GetI ( const PointsKey pkey)
inlineoverrideprotectedvirtual

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

Definition at line 69 of file NodalTriFekete.h.

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

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

Member Data Documentation

◆ initPointsManager

bool Nektar::LibUtilities::NodalTriFekete::initPointsManager
staticprivate
Initial value:
bool RegisterCreator(const KeyType &key, const CreateFuncType &createFunc)
Register the given function and associate it with the key. The return value is just to facilitate cal...
Definition: NekManager.hpp:170
static std::shared_ptr< PointsBaseType > Create(const PointsKey &key)
@ eNodalTriFekete
2D Nodal Fekete Points on a Triangle
Definition: PointsType.h:84

Definition at line 95 of file NodalTriFekete.h.

◆ m_util

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