Nektar++
Public Member Functions | Static Public 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)
 
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

 NodalTriFekete ()
 
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 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.

References Create(), and LIB_UTILITIES_EXPORT.

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

◆ NodalTriFekete() [2/2]

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

Definition at line 98 of file NodalTriFekete.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::NodalTriFekete::CalculateDerivMatrix ( )
privatevirtual

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

Definition at line 165 of file NodalTriFekete.cpp.

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

Referenced by NodalTriFekete().

166  {
167  // Allocate the derivative matrix.
169 
170  m_derivmatrix[0] = m_util->GetDerivMatrix(0);
171  m_derivmatrix[1] = m_util->GetDerivMatrix(1);
172  }
std::shared_ptr< NodalUtilTriangle > m_util
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:383

◆ 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 150 of file NodalTriFekete.cpp.

References m_util, and Vmath::Vcopy().

Referenced by GetI(), and NodalTriFekete().

152  {
153  Array<OneD, Array<OneD, NekDouble> > xi(2);
154  xi[0] = xia;
155  xi[1] = yia;
156 
157  std::shared_ptr<NekMatrix<NekDouble> > mat =
158  m_util->GetInterpolationMatrix(xi);
159  Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(),
160  1, &interp[0], 1);
161  }
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::NodalTriFekete::CalculatePoints ( )
privatevirtual

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

Definition at line 56 of file NodalTriFekete.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL1, Nektar::LibUtilities::Points< NekDouble >::CalculatePoints(), 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, and Nektar::LibUtilities::perm6_2d.

Referenced by NodalTriFekete().

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

◆ CalculateWeights()

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

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

Definition at line 135 of file NodalTriFekete.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 NodalTriFekete().

136  {
137  // Allocate the storage for points
139 
140  typedef DataType T;
141 
142  // Solve the Vandermonde system of integrals for the weight vector
143  NekVector<T> w = m_util->GetWeights();
144  m_weights = Array<OneD,T>( w.GetRows(), w.GetPtr() );
145 
146  }
Array< OneD, DataType > m_weights
Definition: Points.h:382
std::shared_ptr< NodalUtilTriangle > m_util

◆ Create()

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

Definition at line 174 of file NodalTriFekete.cpp.

Referenced by NodalTriFekete().

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

◆ GetI() [1/2]

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

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

Definition at line 68 of file NodalTriFekete.h.

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

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

◆ GetI() [2/2]

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

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

Definition at line 78 of file NodalTriFekete.h.

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

81  {
82  size_t numpoints = x.num_elements();
83  unsigned int np = GetTotNumPoints();
84 
85  Array<OneD, NekDouble> interp(GetTotNumPoints()*numpoints);
86  CalculateInterpMatrix(x, y, interp);
87 
88  NekDouble* d = interp.data();
89  return MemoryManager<NekMatrix<NekDouble> >
90  ::AllocateSharedPtr(numpoints, np, d);
91  }
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::NodalTriFekete::NodalPointReorder2d ( )
private

Definition at line 181 of file NodalTriFekete.cpp.

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

Referenced by CalculatePoints(), and NodalTriFekete().

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

Member Data Documentation

◆ initPointsManager

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

Definition at line 94 of file NodalTriFekete.h.

◆ m_util

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