Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::LibUtilities::NodalTriElec Class Reference

#include <NodalTriElec.h>

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

Public Member Functions

virtual ~NodalTriElec ()
 
const MatrixSharedPtrType GetI (const PointsKey &pkey)
 
const MatrixSharedPtrType GetI (const Array< OneD, const NekDouble > &x, const Array< OneD, const NekDouble > &y)
 
 NodalTriElec (const PointsKey &key)
 
- Public Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
virtual ~Points ()
 
virtual 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
 
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
 
virtual const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x)
 
virtual const MatrixSharedPtrType GetI (unsigned int numpoints, const Array< OneD, const DataType > &x)
 
virtual const MatrixSharedPtrType GetI (const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y, const Array< OneD, const DataType > &z)
 
virtual const MatrixSharedPtrType GetGalerkinProjection (const PointsKey &pkey)
 

Static Public Member Functions

static boost::shared_ptr
< PointsBaseType
Create (const PointsKey &key)
 

Private Member Functions

 NodalTriElec ()
 
void CalculatePoints ()
 
void CalculateWeights ()
 
void CalculateDerivMatrix ()
 
void NodalPointReorder2d ()
 
void CalculateInterpMatrix (const Array< OneD, const NekDouble > &xia, const Array< OneD, const NekDouble > &yia, Array< OneD, NekDouble > &interp)
 

Private Attributes

boost::shared_ptr
< NodalUtilTriangle
m_util
 

Additional Inherited Members

- Public Types inherited from Nektar::LibUtilities::Points< NekDouble >
typedef NekDouble DataType
 
typedef boost::shared_ptr
< NekMatrix< DataType > > 
MatrixSharedPtrType
 
- Protected Member Functions inherited from Nektar::LibUtilities::Points< NekDouble >
 Points (const PointsKey &key)
 
- Protected Attributes inherited from Nektar::LibUtilities::Points< NekDouble >
PointsKey m_pointsKey
 
Array< OneD, DataTypem_points [3]
 
Array< OneD, DataTypem_weights
 
MatrixSharedPtrType m_derivmatrix [3]
 
NekManager< PointsKey,
NekMatrix< DataType >
, PointsKey::opLess
m_InterpManager
 
NekManager< PointsKey,
NekMatrix< DataType >
, PointsKey::opLess
m_GalerkinProjectionManager
 

Detailed Description

Definition at line 52 of file NodalTriElec.h.

Constructor & Destructor Documentation

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

Definition at line 56 of file NodalTriElec.h.

57  {
58  }
Nektar::LibUtilities::NodalTriElec::NodalTriElec ( const PointsKey key)
inline

Definition at line 87 of file NodalTriElec.h.

87  :PointsBaseType(key)
88  {
89  }
Points< NekDouble > PointsBaseType
Nektar::LibUtilities::NodalTriElec::NodalTriElec ( )
inlineprivate

Definition at line 94 of file NodalTriElec.h.

95  {
96  }
static const PointsKey NullPointsKey(0, eNoPointsType)
Points< NekDouble > PointsBaseType

Member Function Documentation

void Nektar::LibUtilities::NodalTriElec::CalculateDerivMatrix ( )
privatevirtual

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

Definition at line 148 of file NodalTriElec.cpp.

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

149  {
150  // Allocate the derivative matrix.
152 
153  m_derivmatrix[0] = m_util->GetDerivMatrix(0);
154  m_derivmatrix[1] = m_util->GetDerivMatrix(1);
155  }
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:373
boost::shared_ptr< NodalUtilTriangle > m_util
Definition: NodalTriElec.h:92
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 159 of file NodalTriElec.cpp.

References m_util, and Vmath::Vcopy().

Referenced by GetI().

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

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

Definition at line 48 of file NodalTriElec.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL1, Nektar::LibUtilities::Points< NekDouble >::CalculatePoints(), 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, and Nektar::LibUtilities::perm6_2d.

49  {
50  // Allocate the storage for points
52 
53  int index=0,isum=0;
54  const int offset = 3; //offset to match Datafile
55  NekDouble b,c;
56  unsigned int numPoints = GetNumPoints();
57 
58  // initialize values
59  for(unsigned int i=0; i < numPoints-2; ++i)
60  {
61  index += NodalTriElecNPTS[i];
62  }
63 
64  for(unsigned int i=0; i < NodalTriElecNPTS[numPoints-2]; ++i, ++index)
65  {
66  if(int(NodalTriElecData[index][0]))
67  {
68  b = NodalTriElecData[index][4];
69  c = NodalTriElecData[index][5];
70 
71  m_points[0][isum] = 2.0*b - 1.0;
72  m_points[1][isum] = 2.0*c - 1.0;
73  isum++;
74  continue;
75  }//end symmetry1
76 
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 
105  if(int(NodalTriElecData[index][2]))
106  {
107  for(unsigned int j=0; j < 6; ++j)
108  {
109  b = NodalTriElecData[index][offset+perm6_2d[j][1]];
110  c = NodalTriElecData[index][offset+perm6_2d[j][2]];
111  m_points[0][isum] = 2.0*b - 1.0;
112  m_points[1][isum] = 2.0*c - 1.0;
113  isum++;
114  }//end j
115  continue;
116  }//end symmetry6
117  }//end npts
118 
119  // std::cout << "(x y) = (" << ToVector(m_points[0]) << ", " << ToVector(m_points[1]) << ")" << std::endl;
120  // cout << "numPoints = " << numPoints << endl;
121  // cout << "NodalTriElecNPTS[numPoints-2] = " << NodalTriElecNPTS[numPoints-2] << endl;
122  // cout << "isum = " << isum << endl;
123  // for( int i = 0; i <= numPoints-2; ++i ) {
124  // cout << "NodalTriElecNPTS[" << i << "] = " << NodalTriElecNPTS[i] << endl;
125  // }
127 
128  ASSERTL1((static_cast<unsigned int>(isum)==m_pointsKey.GetTotNumPoints()),"sum not equal to npts");
129 
131  numPoints - 1, m_points[0], m_points[1]);
132 
133  //exit(0);
134  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
static const unsigned int perm3B_2d[3][3]
Array< OneD, DataType > m_points[3]
Definition: Points.h:371
static const unsigned int NodalTriElecNPTS[NodalTriElecAvailable]
boost::shared_ptr< NodalUtilTriangle > m_util
Definition: NodalTriElec.h:92
unsigned int GetNumPoints() const
Definition: Points.h:268
unsigned int GetTotNumPoints() const
Definition: Points.h:179
double NekDouble
static const unsigned int perm3A_2d[3][3]
static const unsigned int perm6_2d[6][3]
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
static const NekDouble NodalTriElecData[][6]
void Nektar::LibUtilities::NodalTriElec::CalculateWeights ( )
privatevirtual

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

Definition at line 136 of file NodalTriElec.cpp.

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

137  {
138  // Allocate the storage for points
140 
141  typedef DataType T;
142 
143  // Solve the Vandermonde system of integrals for the weight vector
144  NekVector<T> w = m_util->GetWeights();
145  m_weights = Array<OneD,T>( w.GetRows(), w.GetPtr() );
146  }
boost::shared_ptr< NodalUtilTriangle > m_util
Definition: NodalTriElec.h:92
Array< OneD, DataType > m_weights
Definition: Points.h:372
boost::shared_ptr< PointsBaseType > Nektar::LibUtilities::NodalTriElec::Create ( const PointsKey key)
static

Definition at line 173 of file NodalTriElec.cpp.

174  {
175  boost::shared_ptr<PointsBaseType> returnval(MemoryManager<NodalTriElec>::AllocateSharedPtr(key));
176  returnval->Initialize();
177  return returnval;
178  }
const MatrixSharedPtrType Nektar::LibUtilities::NodalTriElec::GetI ( const PointsKey pkey)
inlinevirtual

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

Definition at line 63 of file NodalTriElec.h.

References ASSERTL0, Nektar::LibUtilities::PointsKey::GetPointsDim(), and Nektar::LibUtilities::PointsManager().

64  {
65  ASSERTL0(pkey.GetPointsDim()==2,
66  "NodalTriElec Points can only interpolate to other 2d "
67  "point distributions");
68  Array<OneD, const NekDouble> x, y;
69  PointsManager()[pkey]->GetPoints(x, y);
70  return GetI(x, y);
71  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
PointsManagerT & PointsManager(void)
const MatrixSharedPtrType GetI(const PointsKey &pkey)
Definition: NodalTriElec.h:63
const MatrixSharedPtrType Nektar::LibUtilities::NodalTriElec::GetI ( const Array< OneD, const NekDouble > &  x,
const Array< OneD, const NekDouble > &  y 
)
inlinevirtual

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

Definition at line 73 of file NodalTriElec.h.

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

76  {
77  int numpoints = x.num_elements();
78  Array<OneD, NekDouble> interp(GetTotNumPoints()*numpoints);
79  CalculateInterpMatrix(x, y, interp);
80 
81  unsigned int np = GetTotNumPoints();
82  NekDouble* d = interp.data();
83  return MemoryManager<NekMatrix<NekDouble> >
84  ::AllocateSharedPtr(numpoints, np, d);
85  }
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xia, const Array< OneD, const NekDouble > &yia, Array< OneD, NekDouble > &interp)
double NekDouble
unsigned int GetTotNumPoints() const
Definition: Points.h:273
void Nektar::LibUtilities::NodalTriElec::NodalPointReorder2d ( )
private

Definition at line 180 of file NodalTriElec.cpp.

References Nektar::LibUtilities::Points< NekDouble >::GetNumPoints(), Nektar::NekConstants::kNekZeroTol, Nektar::LibUtilities::Points< NekDouble >::m_points, and Nektar::Array< OneD, const DataType >::num_elements().

Referenced by CalculatePoints().

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

Member Data Documentation

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