Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

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

 NodalTriElec ()=delete
 
 NodalTriElec (const NodalTriElec &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 > &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 47 of file NodalTriElec.h.

Constructor & Destructor Documentation

◆ ~NodalTriElec()

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

Definition at line 50 of file NodalTriElec.h.

51 {
52 }

◆ NodalTriElec() [1/3]

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

Definition at line 57 of file NodalTriElec.h.

57 : PointsBaseType(key)
58 {
59 }
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 147 of file NodalTriElec.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
Definition: NodalTriElec.h:89
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::NodalTriElec::Create ( const PointsKey key)
static

Definition at line 161 of file NodalTriElec.cpp.

162{
163 std::shared_ptr<PointsBaseType> returnval(
165 returnval->Initialize();
166 return returnval;
167}
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 169 of file NodalTriElec.cpp.

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

Definition at line 136 of file NodalTriElec.cpp.

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

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

Definition at line 44 of file NodalTriElec.cpp.

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

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

Definition at line 124 of file NodalTriElec.cpp.

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

Definition at line 72 of file NodalTriElec.h.

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

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

Definition at line 62 of file NodalTriElec.h.

63 {
64 ASSERTL0(pkey.GetPointsDim() == 2,
65 "NodalTriElec Points can only interpolate 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: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::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:169
static std::shared_ptr< PointsBaseType > Create(const PointsKey &key)
@ eNodalTriElec
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:83

Definition at line 87 of file NodalTriElec.h.

◆ m_util

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