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::NodalTriElec Class Reference

#include <NodalTriElec.h>

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

Public Member Functions

 ~NodalTriElec () override
 
 NodalTriElec (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

 NodalTriElec ()=delete
 
 NodalTriElec (const NodalTriElec &points)=delete
 
void NodalPointReorder2d ()
 
void v_CalculatePoints () final
 
void v_CalculateWeights () final
 
void v_CalculateDerivMatrix () final
 
void CalculateInterpMatrix (const Array< OneD, const NekDouble > &xia, const Array< OneD, const NekDouble > &yia, 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 45 of file NodalTriElec.h.

Constructor & Destructor Documentation

◆ ~NodalTriElec()

Nektar::LibUtilities::NodalTriElec::~NodalTriElec ( )
inlineoverride

Definition at line 48 of file NodalTriElec.h.

49 {
50 }

◆ NodalTriElec() [1/3]

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

Definition at line 55 of file NodalTriElec.h.

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

◆ NodalTriElec() [2/3]

Nektar::LibUtilities::NodalTriElec::NodalTriElec ( )
privatedelete

◆ NodalTriElec() [3/3]

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

Member Function Documentation

◆ CalculateInterpMatrix()

void Nektar::LibUtilities::NodalTriElec::CalculateInterpMatrix ( const Array< OneD, const NekDouble > &  xia,
const Array< OneD, const NekDouble > &  yia,
Array< OneD, NekDouble > &  interp 
)
private

Definition at line 145 of file NodalTriElec.cpp.

148{
149 Array<OneD, Array<OneD, NekDouble>> xi(2);
150 xi[0] = xia;
151 xi[1] = yia;
152
153 std::shared_ptr<NekMatrix<NekDouble>> mat =
154 m_util->GetInterpolationMatrix(xi);
155 Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(), 1,
156 &interp[0], 1);
157}
std::shared_ptr< NodalUtilTriangle > m_util
Definition: NodalTriElec.h:87
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::NodalTriElec::Create ( const PointsKey key)
static

Definition at line 159 of file NodalTriElec.cpp.

160{
161 std::shared_ptr<PointsBaseType> returnval(
163 returnval->Initialize();
164 return returnval;
165}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ NodalPointReorder2d()

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

Definition at line 167 of file NodalTriElec.cpp.

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

Definition at line 134 of file NodalTriElec.cpp.

135{
136 // Allocate the derivative matrix.
137 PointsBaseType::v_CalculateDerivMatrix();
138
139 m_derivmatrix[0] = m_util->GetDerivMatrix(0);
140 m_derivmatrix[1] = m_util->GetDerivMatrix(1);
141}
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::NodalTriElec::v_CalculatePoints ( )
finalprivatevirtual

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

Definition at line 42 of file NodalTriElec.cpp.

43{
44 // Allocate the storage for points
46
47 size_t index = 0, isum = 0;
48 const size_t offset = 3; // offset to match Datafile
49 NekDouble b, c;
50 size_t numPoints = GetNumPoints();
51
52 // initialize values
53 for (size_t i = 0; i < numPoints - 2; ++i)
54 {
55 index += NodalTriElecNPTS[i];
56 }
57
58 for (size_t i = 0; i < NodalTriElecNPTS[numPoints - 2]; ++i, ++index)
59 {
60 if (int(NodalTriElecData[index][0]))
61 {
62 b = NodalTriElecData[index][4];
63 c = NodalTriElecData[index][5];
64
65 m_points[0][isum] = 2.0 * b - 1.0;
66 m_points[1][isum] = 2.0 * c - 1.0;
67 isum++;
68 continue;
69 } // end symmetry1
70
71 if (int(NodalTriElecData[index][1]) == 1)
72 {
73 for (size_t j = 0; j < 3; ++j)
74 {
75 b = NodalTriElecData[index][offset + perm3A_2d[j][1]];
76 c = NodalTriElecData[index][offset + perm3A_2d[j][2]];
77 m_points[0][isum] = 2.0 * b - 1.0;
78 m_points[1][isum] = 2.0 * c - 1.0;
79 isum++;
80 } // end j
81 continue;
82 } // end symmetry3a
83
84 if (int(NodalTriElecData[index][1]) == 2)
85 {
86 for (size_t j = 0; j < 3; ++j)
87 {
88 b = NodalTriElecData[index][offset + perm3B_2d[j][1]];
89 c = NodalTriElecData[index][offset + perm3B_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 symmetry3b
96
97 if (int(NodalTriElecData[index][2]))
98 {
99 for (size_t j = 0; j < 6; ++j)
100 {
101 b = NodalTriElecData[index][offset + perm6_2d[j][1]];
102 c = NodalTriElecData[index][offset + perm6_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 symmetry6
109 } // end npts
110
112
113 ASSERTL1((static_cast<size_t>(isum) == m_pointsKey.GetTotNumPoints()),
114 "sum not equal to npts");
115
117 numPoints - 1, m_points[0], m_points[1]);
118
119 // exit(0);
120}
#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 NekDouble NodalTriElecData[][6]
static const size_t NodalTriElecNPTS[NodalTriElecAvailable]
static const size_t perm6_2d[6][3]
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::NodalTriElecData, Nektar::LibUtilities::NodalTriElecNPTS, Nektar::LibUtilities::perm3A_2d, Nektar::LibUtilities::perm3B_2d, Nektar::LibUtilities::perm6_2d, and Nektar::LibUtilities::Points< NekDouble >::v_CalculatePoints().

◆ v_CalculateWeights()

void Nektar::LibUtilities::NodalTriElec::v_CalculateWeights ( )
finalprivatevirtual

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

Definition at line 122 of file NodalTriElec.cpp.

123{
124 // Allocate the storage for points
126
127 typedef DataType T;
128
129 // Solve the Vandermonde system of integrals for the weight vector
130 NekVector<T> w = m_util->GetWeights();
131 m_weights = Array<OneD, T>(w.GetRows(), w.GetPtr());
132}
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::NodalTriElec::v_GetI ( const Array< OneD, const NekDouble > &  x,
const Array< OneD, const NekDouble > &  y 
)
inlineoverrideprotected

Definition at line 70 of file NodalTriElec.h.

73 {
74 size_t numpoints = x.size();
75 Array<OneD, NekDouble> interp(GetTotNumPoints() * numpoints);
76 CalculateInterpMatrix(x, y, interp);
77
78 size_t np = GetTotNumPoints();
79 NekDouble *d = interp.data();
80 return MemoryManager<NekMatrix<NekDouble>>::AllocateSharedPtr(numpoints,
81 np, d);
82 }
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xia, const Array< OneD, const NekDouble > &yia, 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::NodalTriElec::v_GetI ( const PointsKey pkey)
inlineoverrideprotected

Definition at line 60 of file NodalTriElec.h.

61 {
62 ASSERTL0(pkey.GetPointsDim() == 2,
63 "NodalTriElec Points can only interpolate to other 2d "
64 "point distributions");
65 Array<OneD, const NekDouble> x, y;
66 PointsManager()[pkey]->GetPoints(x, y);
67 return GetI(x, y);
68 }
#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::NodalTriElec::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)
@ eNodalTriElec
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:81

Definition at line 85 of file NodalTriElec.h.

◆ m_util

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