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)
 
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

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_CalculatePoints ()
 
virtual void v_CalculateWeights ()
 

Private Member Functions

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

Constructor & Destructor Documentation

◆ ~NodalTriFekete()

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

Definition at line 52 of file NodalTriFekete.h.

53 {
54 }

◆ NodalTriFekete() [1/3]

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

Definition at line 56 of file NodalTriFekete.h.

56 : PointsBaseType(key)
57 {
58 }
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 139 of file NodalTriFekete.cpp.

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

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

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

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

Definition at line 155 of file NodalTriFekete.cpp.

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

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

◆ v_CalculatePoints()

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

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

Definition at line 47 of file NodalTriFekete.cpp.

48{
49 // Allocate the storage for points
51
52 size_t index = 0, isum = 0;
53 const size_t offset = 3; // offset to match Datafile
54 NekDouble b, c;
55 size_t numPoints = GetNumPoints();
56
57 // initialize values
58 for (size_t i = 0; i < numPoints - 2; ++i)
59 {
60 index += NodalTriFeketeNPTS[i];
61 }
62
63 for (size_t i = 0; i < NodalTriFeketeNPTS[numPoints - 2]; ++i, ++index)
64 {
65 if (int(NodalTriFeketeData[index][0]))
66 {
67 b = NodalTriFeketeData[index][4];
68 c = NodalTriFeketeData[index][5];
69
70 m_points[0][isum] = 2.0 * b - 1.0;
71 m_points[1][isum] = 2.0 * c - 1.0;
72 isum++;
73 continue;
74 } // end symmetry1
75
76 if (int(NodalTriFeketeData[index][1]) == 1)
77 {
78 for (size_t j = 0; j < 3; ++j)
79 {
80 b = NodalTriFeketeData[index][offset + perm3A_2d[j][1]];
81 c = NodalTriFeketeData[index][offset + perm3A_2d[j][2]];
82 m_points[0][isum] = 2.0 * b - 1.0;
83 m_points[1][isum] = 2.0 * c - 1.0;
84 isum++;
85 } // end j
86 continue;
87 } // end symmetry3a
88
89 if (int(NodalTriFeketeData[index][1]) == 2)
90 {
91 for (size_t j = 0; j < 3; ++j)
92 {
93 b = NodalTriFeketeData[index][offset + perm3B_2d[j][1]];
94 c = NodalTriFeketeData[index][offset + perm3B_2d[j][2]];
95 m_points[0][isum] = 2.0 * b - 1.0;
96 m_points[1][isum] = 2.0 * c - 1.0;
97 isum++;
98 } // end j
99 continue;
100 } // end symmetry3b
101
102 if (int(NodalTriFeketeData[index][2]))
103 {
104 for (size_t j = 0; j < 6; ++j)
105 {
106 b = NodalTriFeketeData[index][offset + perm6_2d[j][1]];
107 c = NodalTriFeketeData[index][offset + perm6_2d[j][2]];
108 m_points[0][isum] = 2.0 * b - 1.0;
109 m_points[1][isum] = 2.0 * c - 1.0;
110 isum++;
111 } // end j
112 continue;
113 } // end symmetry6
114 } // end npts
115
117
118 ASSERTL1((static_cast<size_t>(isum) == m_pointsKey.GetTotNumPoints()),
119 "sum not equal to npts");
120
122 numPoints - 1, m_points[0], m_points[1]);
123}
#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:358
size_t GetTotNumPoints() const
Definition: Points.h:163
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 ( )
finaloverrideprivatevirtual

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

Definition at line 125 of file NodalTriFekete.cpp.

126{
127 // Allocate the storage for points
129
130 typedef DataType T;
131
132 // Solve the Vandermonde system of integrals for the weight vector
133 NekVector<T> w = m_util->GetWeights();
134 m_weights = Array<OneD, T>(w.GetRows(), w.GetPtr());
135}
Array< OneD, DataType > m_weights
Quadrature weights for the weights.
Definition: Points.h:363
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]

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

Definition at line 74 of file NodalTriFekete.h.

77 {
78 size_t numpoints = x.size();
79 size_t np = GetTotNumPoints();
80
81 Array<OneD, NekDouble> interp(GetTotNumPoints() * numpoints);
82 CalculateInterpMatrix(x, y, interp);
83
84 NekDouble *d = interp.data();
85 return MemoryManager<NekMatrix<NekDouble>>::AllocateSharedPtr(numpoints,
86 np, d);
87 }
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]

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

Definition at line 64 of file NodalTriFekete.h.

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

Definition at line 90 of file NodalTriFekete.h.

◆ m_util

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