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

virtual ~NodalTriElec ()
 
 NodalTriElec (const PointsKey &key)
 
- Public Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual ~Points ()
 
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
 
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 (unsigned int 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_CalculateBaryWeights ()
 This function calculates the barycentric weights used for enhanced interpolation speed. More...
 
 Points (const PointsKey &key)
 
virtual const MatrixSharedPtrType v_GetI (const Array< OneD, const DataType > &x)
 
virtual const MatrixSharedPtrType v_GetI (unsigned int, const Array< OneD, const DataType > &x)
 
virtual const MatrixSharedPtrType v_GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y, const Array< OneD, const DataType > &z)
 
virtual const MatrixSharedPtrType v_GetGalerkinProjection (const PointsKey &pkey)
 

Private Member Functions

 NodalTriElec ()
 
void NodalPointReorder2d ()
 
virtual void v_CalculatePoints () override
 
virtual void v_CalculateWeights () override
 
virtual void v_CalculateDerivMatrix () override
 
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 52 of file NodalTriElec.h.

Constructor & Destructor Documentation

◆ ~NodalTriElec()

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

Definition at line 55 of file NodalTriElec.h.

56  {
57  }

◆ NodalTriElec() [1/2]

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

Definition at line 62 of file NodalTriElec.h.

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

◆ NodalTriElec() [2/2]

Nektar::LibUtilities::NodalTriElec::NodalTriElec ( )
inlineprivate

Definition at line 96 of file NodalTriElec.h.

97  {
98  }
static const PointsKey NullPointsKey(0, eNoPointsType)

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 160 of file NodalTriElec.cpp.

163 {
164  Array<OneD, Array<OneD, NekDouble>> xi(2);
165  xi[0] = xia;
166  xi[1] = yia;
167 
168  std::shared_ptr<NekMatrix<NekDouble>> mat =
169  m_util->GetInterpolationMatrix(xi);
170  Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(), 1,
171  &interp[0], 1);
172 }
std::shared_ptr< NodalUtilTriangle > m_util
Definition: NodalTriElec.h:94
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1255

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 174 of file NodalTriElec.cpp.

175 {
176  std::shared_ptr<PointsBaseType> returnval(
178  returnval->Initialize();
179  return returnval;
180 }
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 182 of file NodalTriElec.cpp.

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

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

Definition at line 149 of file NodalTriElec.cpp.

150 {
151  // Allocate the derivative matrix.
153 
154  m_derivmatrix[0] = m_util->GetDerivMatrix(0);
155  m_derivmatrix[1] = m_util->GetDerivMatrix(1);
156 }
MatrixSharedPtrType m_derivmatrix[3]
Derivative matrices.
Definition: Points.h:381

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

◆ v_CalculatePoints()

void Nektar::LibUtilities::NodalTriElec::v_CalculatePoints ( )
overrideprivatevirtual

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

Definition at line 49 of file NodalTriElec.cpp.

50 {
51  // Allocate the storage for points
53 
54  int index = 0, isum = 0;
55  const int offset = 3; // offset to match Datafile
56  NekDouble b, c;
57  unsigned int numPoints = GetNumPoints();
58 
59  // initialize values
60  for (unsigned int i = 0; i < numPoints - 2; ++i)
61  {
62  index += NodalTriElecNPTS[i];
63  }
64 
65  for (unsigned int i = 0; i < NodalTriElecNPTS[numPoints - 2]; ++i, ++index)
66  {
67  if (int(NodalTriElecData[index][0]))
68  {
69  b = NodalTriElecData[index][4];
70  c = NodalTriElecData[index][5];
71 
72  m_points[0][isum] = 2.0 * b - 1.0;
73  m_points[1][isum] = 2.0 * c - 1.0;
74  isum++;
75  continue;
76  } // end symmetry1
77 
78  if (int(NodalTriElecData[index][1]) == 1)
79  {
80  for (unsigned int j = 0; j < 3; ++j)
81  {
82  b = NodalTriElecData[index][offset + perm3A_2d[j][1]];
83  c = NodalTriElecData[index][offset + perm3A_2d[j][2]];
84  m_points[0][isum] = 2.0 * b - 1.0;
85  m_points[1][isum] = 2.0 * c - 1.0;
86  isum++;
87  } // end j
88  continue;
89  } // end symmetry3a
90 
91  if (int(NodalTriElecData[index][1]) == 2)
92  {
93  for (unsigned int j = 0; j < 3; ++j)
94  {
95  b = NodalTriElecData[index][offset + perm3B_2d[j][1]];
96  c = NodalTriElecData[index][offset + perm3B_2d[j][2]];
97  m_points[0][isum] = 2.0 * b - 1.0;
98  m_points[1][isum] = 2.0 * c - 1.0;
99  isum++;
100  } // end j
101  continue;
102  } // end symmetry3b
103 
104  if (int(NodalTriElecData[index][2]))
105  {
106  for (unsigned int j = 0; j < 6; ++j)
107  {
108  b = NodalTriElecData[index][offset + perm6_2d[j][1]];
109  c = NodalTriElecData[index][offset + perm6_2d[j][2]];
110  m_points[0][isum] = 2.0 * b - 1.0;
111  m_points[1][isum] = 2.0 * c - 1.0;
112  isum++;
113  } // end j
114  continue;
115  } // end symmetry6
116  } // end npts
117 
118  // std::cout << "(x y) = (" << ToVector(m_points[0]) << ", " <<
119  // ToVector(m_points[1]) << ")" << std::endl; cout << "numPoints = " <<
120  // numPoints << endl; cout << "NodalTriElecNPTS[numPoints-2] = " <<
121  // NodalTriElecNPTS[numPoints-2] << endl; cout << "isum = " << isum <<
122  // endl; for( int i = 0; i <= numPoints-2; ++i ) {
123  // cout << "NodalTriElecNPTS[" << i << "] = " << NodalTriElecNPTS[i]
124  // << endl;
125  // }
127 
128  ASSERTL1((static_cast<unsigned int>(isum) == m_pointsKey.GetTotNumPoints()),
129  "sum not equal to npts");
130 
132  numPoints - 1, m_points[0], m_points[1]);
133 
134  // exit(0);
135 }
#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:372
unsigned int GetTotNumPoints() const
Definition: Points.h:177
static const unsigned int perm3A_2d[3][3]
static const NekDouble NodalTriElecData[][6]
static const unsigned int perm6_2d[6][3]
static const unsigned int perm3B_2d[3][3]
static const unsigned int NodalTriElecNPTS[NodalTriElecAvailable]
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 ( )
overrideprivatevirtual

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

Definition at line 137 of file NodalTriElec.cpp.

138 {
139  // Allocate the storage for points
141 
142  typedef DataType T;
143 
144  // Solve the Vandermonde system of integrals for the weight vector
145  NekVector<T> w = m_util->GetWeights();
146  m_weights = Array<OneD, T>(w.GetRows(), w.GetPtr());
147 }
Array< OneD, DataType > m_weights
Quadrature weights for the weights.
Definition: Points.h:377

References Nektar::NekVector< DataType >::GetPtr(), Nektar::NekVector< DataType >::GetRows(), m_util, Nektar::LibUtilities::Points< NekDouble >::m_weights, and Nektar::LibUtilities::Points< NekDouble >::v_CalculateWeights().

◆ 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

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

Definition at line 77 of file NodalTriElec.h.

80  {
81  size_t numpoints = x.size();
82  Array<OneD, NekDouble> interp(GetTotNumPoints() * numpoints);
83  CalculateInterpMatrix(x, y, interp);
84 
85  unsigned int np = GetTotNumPoints();
86  NekDouble *d = interp.data();
87  return MemoryManager<NekMatrix<NekDouble>>::AllocateSharedPtr(numpoints,
88  np, d);
89  }
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xia, const Array< OneD, const NekDouble > &yia, Array< OneD, NekDouble > &interp)
unsigned int GetTotNumPoints() const
Definition: Points.h:278

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

◆ v_GetI() [2/2]

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

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

Definition at line 67 of file NodalTriElec.h.

68  {
69  ASSERTL0(pkey.GetPointsDim() == 2,
70  "NodalTriElec Points can only interpolate to other 2d "
71  "point distributions");
72  Array<OneD, const NekDouble> x, y;
73  PointsManager()[pkey]->GetPoints(x, y);
74  return GetI(x, y);
75  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
const MatrixSharedPtrType GetI(const PointsKey &key)
Definition: Points.h:336
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:170
static std::shared_ptr< PointsBaseType > Create(const PointsKey &key)
@ eNodalTriElec
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:83

Definition at line 92 of file NodalTriElec.h.

◆ m_util

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