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

 ~NodalTriFekete () override
 
 NodalTriFekete (const PointsKey &key)
 
- Public Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual ~Points ()
 
void Initialize (void)
 
size_t GetPointsDim () const
 
size_t GetNumPoints () const
 
size_t 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 (size_t 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

const MatrixSharedPtrType v_GetI (const PointsKey &pkey) override
 
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_CalculatePoints ()
 
virtual void v_CalculateWeights ()
 

Private Member Functions

 NodalTriFekete ()=delete
 
 NodalTriFekete (const NodalTriFekete &points)=delete
 
void NodalPointReorder2d ()
 
void v_CalculatePoints () final
 
void v_CalculateWeights () final
 
void v_CalculateDerivMatrix () final
 
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 47 of file NodalTriFekete.h.

Constructor & Destructor Documentation

◆ ~NodalTriFekete()

Nektar::LibUtilities::NodalTriFekete::~NodalTriFekete ( )
inlineoverride

Definition at line 50 of file NodalTriFekete.h.

51 {
52 }

◆ NodalTriFekete() [1/3]

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

Definition at line 54 of file NodalTriFekete.h.

54 : PointsBaseType(key)
55 {
56 }
Points< NekDouble > PointsBaseType

◆ NodalTriFekete() [2/3]

Nektar::LibUtilities::NodalTriFekete::NodalTriFekete ( )
privatedelete

◆ NodalTriFekete() [3/3]

Nektar::LibUtilities::NodalTriFekete::NodalTriFekete ( const NodalTriFekete points)
privatedelete

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

140{
141 Array<OneD, Array<OneD, NekDouble>> xi(2);
142 xi[0] = xia;
143 xi[1] = yia;
144
145 std::shared_ptr<NekMatrix<NekDouble>> mat =
146 m_util->GetInterpolationMatrix(xi);
147 Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(), 1,
148 &interp[0], 1);
149}
std::shared_ptr< NodalUtilTriangle > m_util
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

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

163{
164 std::shared_ptr<PointsBaseType> returnval(
166 returnval->Initialize();
167 return returnval;
168}
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 170 of file NodalTriFekete.cpp.

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

Definition at line 153 of file NodalTriFekete.cpp.

154{
155 // Allocate the derivative matrix.
156 PointsBaseType::v_CalculateDerivMatrix();
157
158 m_derivmatrix[0] = m_util->GetDerivMatrix(0);
159 m_derivmatrix[1] = m_util->GetDerivMatrix(1);
160}
MatrixSharedPtrType m_derivmatrix[3]
Derivative matrices.
Definition: Points.h:362

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

◆ v_CalculatePoints()

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

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

Definition at line 45 of file NodalTriFekete.cpp.

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

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

Definition at line 123 of file NodalTriFekete.cpp.

124{
125 // Allocate the storage for points
127
128 typedef DataType T;
129
130 // Solve the Vandermonde system of integrals for the weight vector
131 NekVector<T> w = m_util->GetWeights();
132 m_weights = Array<OneD, T>(w.GetRows(), w.GetPtr());
133}
Array< OneD, DataType > m_weights
Quadrature weights for the weights.
Definition: Points.h:358
std::vector< double > w(NPUPPER)

References m_util, Nektar::LibUtilities::Points< NekDouble >::m_weights, Nektar::LibUtilities::Points< NekDouble >::v_CalculateWeights(), and Nektar::UnitTests::w().

◆ v_GetI() [1/2]

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

Definition at line 72 of file NodalTriFekete.h.

75 {
76 size_t numpoints = x.size();
77 size_t np = GetTotNumPoints();
78
79 Array<OneD, NekDouble> interp(GetTotNumPoints() * numpoints);
80 CalculateInterpMatrix(x, y, interp);
81
82 NekDouble *d = interp.data();
83 return MemoryManager<NekMatrix<NekDouble>>::AllocateSharedPtr(numpoints,
84 np, d);
85 }
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xi, const Array< OneD, const NekDouble > &yi, Array< OneD, NekDouble > &interp)
std::vector< double > d(NPUPPER *NPUPPER)

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

◆ v_GetI() [2/2]

const MatrixSharedPtrType Nektar::LibUtilities::NodalTriFekete::v_GetI ( const PointsKey pkey)
inlineoverrideprotected

Definition at line 62 of file NodalTriFekete.h.

63 {
64 ASSERTL0(pkey.GetPointsDim() == 2,
65 "Fekete Points can only interp to other 2d "
66 "point distributions");
67 Array<OneD, const NekDouble> x, y;
68 PointsManager()[pkey]->GetPoints(x, y);
69 return GetI(x, y);
70 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
const MatrixSharedPtrType GetI(const PointsKey &key)
Definition: Points.h:317
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:168
static std::shared_ptr< PointsBaseType > Create(const PointsKey &key)
@ eNodalTriFekete
2D Nodal Fekete Points on a Triangle
Definition: PointsType.h:82

Definition at line 88 of file NodalTriFekete.h.

◆ m_util

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