Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | 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)
 

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 51 of file NodalTriElec.h.

Constructor & Destructor Documentation

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

Definition at line 55 of file NodalTriElec.h.

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

Definition at line 86 of file NodalTriElec.h.

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

Definition at line 91 of file NodalTriElec.h.

92  {
93  }
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 146 of file NodalTriElec.cpp.

References Nektar::LibUtilities::Points< NekDouble >::CalculateDerivMatrix(), Nektar::LibUtilities::GetXDerivativeMatrix(), Nektar::LibUtilities::GetYDerivativeMatrix(), Nektar::LibUtilities::Points< NekDouble >::m_derivmatrix, and Nektar::LibUtilities::Points< NekDouble >::m_points.

147  {
148  // Allocate the derivative matrix.
150 
151  NekVector<NekDouble> x( m_points[0] );
152  NekVector<NekDouble> y( m_points[1] );
153  NekVector<NekDouble> xi = x;
154  NekVector<NekDouble> yi = y;
155 
156  m_derivmatrix[0] = GetXDerivativeMatrix(x,y,xi,yi);
157  m_derivmatrix[1] = GetYDerivativeMatrix(x,y,xi,yi);
158 
159  }
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:351
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
Points< NekDouble >::MatrixSharedPtrType GetXDerivativeMatrix(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y, const NekVector< NekDouble > &xi, const NekVector< NekDouble > &yi)
Definition: NodalUtil.cpp:852
Points< NekDouble >::MatrixSharedPtrType GetYDerivativeMatrix(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y, const NekVector< NekDouble > &xi, const NekVector< NekDouble > &yi)
Definition: NodalUtil.cpp:1303
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 163 of file NodalTriElec.cpp.

References Nektar::LibUtilities::GetInterpolationMatrix(), Nektar::NekVector< DataType >::GetRows(), Nektar::LibUtilities::Points< NekDouble >::GetTotNumPoints(), and Nektar::LibUtilities::Points< NekDouble >::m_points.

Referenced by GetI().

165  {
166  NekVector<NekDouble> x( m_points[0] );
167  NekVector<NekDouble> y( m_points[1] );
168  NekVector<NekDouble> xi( xia );
169  NekVector<NekDouble> yi( yia );
170  NekMatrix<NekDouble> interMat = GetInterpolationMatrix(x, y, xi, yi);
171 
172  int rows = xi.GetRows(), cols = GetTotNumPoints();
173  for( int i = 0; i < rows; ++i ) {
174  for( int j = 0; j < cols; ++j ) {
175  interp[j + i*cols] = interMat(i,j);
176  }
177  }
178  }
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
NekMatrix< NekDouble > GetInterpolationMatrix(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y, const NekVector< NekDouble > &xi, const NekVector< NekDouble > &yi)
Definition: NodalUtil.cpp:609
unsigned int GetTotNumPoints() const
Definition: Points.h:251
void Nektar::LibUtilities::NodalTriElec::CalculatePoints ( )
privatevirtual

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

Definition at line 48 of file NodalTriElec.cpp.

References 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, 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 
130  //exit(0);
131  }
static const unsigned int perm3B_2d[3][3]
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
static const unsigned int NodalTriElecNPTS[NodalTriElecAvailable]
unsigned int GetNumPoints() const
Definition: Points.h:246
unsigned int GetTotNumPoints() const
Definition: Points.h:175
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:218
static const NekDouble NodalTriElecData[][6]
void Nektar::LibUtilities::NodalTriElec::CalculateWeights ( )
privatevirtual

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

Definition at line 133 of file NodalTriElec.cpp.

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

134  {
135  // Allocate the storage for points
137 
138  typedef DataType T;
139 
140  // Solve the Vandermonde system of integrals for the weight vector
141  NekVector<T> w = MakeQuadratureWeights(NekVector<T>(m_points[0]), NekVector<T>(m_points[1]));
142 
143  m_weights = Array<OneD,T>( w.GetRows(), w.GetPtr() );
144  }
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
NekVector< NekDouble > MakeQuadratureWeights(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y)
Definition: NodalUtil.cpp:579
Array< OneD, DataType > m_weights
Definition: Points.h:350
boost::shared_ptr< PointsBaseType > Nektar::LibUtilities::NodalTriElec::Create ( const PointsKey key)
static

Definition at line 181 of file NodalTriElec.cpp.

182  {
183  boost::shared_ptr<PointsBaseType> returnval(MemoryManager<NodalTriElec>::AllocateSharedPtr(key));
184  returnval->Initialize();
185  return returnval;
186  }
const MatrixSharedPtrType Nektar::LibUtilities::NodalTriElec::GetI ( const PointsKey pkey)
inlinevirtual

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

Definition at line 62 of file NodalTriElec.h.

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

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:188
PointsManagerT & PointsManager(void)
const MatrixSharedPtrType GetI(const PointsKey &pkey)
Definition: NodalTriElec.h:62
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 72 of file NodalTriElec.h.

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

75  {
76  int numpoints = x.num_elements();
77  Array<OneD, NekDouble> interp(GetTotNumPoints()*numpoints);
78  CalculateInterpMatrix(x, y, interp);
79 
80  unsigned int np = GetTotNumPoints();
81  NekDouble* d = interp.data();
82  return MemoryManager<NekMatrix<NekDouble> >
83  ::AllocateSharedPtr(numpoints, np, d);
84  }
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:251
void Nektar::LibUtilities::NodalTriElec::NodalPointReorder2d ( )
private

Definition at line 188 of file NodalTriElec.cpp.

References Nektar::LibUtilities::Points< NekDouble >::GetNumPoints(), Nektar::NekConstants::kNekZeroTol, and Nektar::LibUtilities::Points< NekDouble >::m_points.

Referenced by CalculatePoints().

189  {
190  int i,j;
191  int cnt;
192  int istart,iend;
193 
194  const int nVerts = 3;
195  const int nEdgeInteriorPoints = GetNumPoints()-2;
196  const int nBoundaryPoints = 3*nEdgeInteriorPoints + 3;
197 
198  if(nEdgeInteriorPoints==0)
199  {
200  return;
201  }
202 
203  // group the points of edge 1 together;
204  istart = nVerts;
205  for(i = cnt = istart; i < nBoundaryPoints; i++)
206  {
207  if( fabs(m_points[1][i] + 1.0) < NekConstants::kNekZeroTol)
208  {
209  std::swap(m_points[0][cnt], m_points[0][i]);
210  std::swap(m_points[1][cnt], m_points[1][i]);
211  cnt++;
212  }
213  }
214 
215  // bubble sort edge 1 (counterclockwise numbering)
216  iend = istart + nEdgeInteriorPoints;
217  for(i = istart; i < iend; i++)
218  {
219  for(j = istart+1; j < iend; j++)
220  {
221  if(m_points[0][j] < m_points[0][j-1])
222  {
223  std::swap(m_points[0][j], m_points[0][j-1]);
224  std::swap(m_points[1][j], m_points[1][j-1]);
225  }
226  }
227  }
228 
229  // group the points of edge 2 together;
230  istart = iend;
231  for(i = cnt = istart; i < nBoundaryPoints; i++)
232  {
233  if( fabs(m_points[1][i]+m_points[0][i]) < NekConstants::kNekZeroTol)
234  {
235  std::swap(m_points[0][cnt], m_points[0][i]);
236  std::swap(m_points[1][cnt], m_points[1][i]);
237  cnt++;
238  }
239  }
240 
241  // bubble sort edge 2 (counterclockwise numbering)
242  iend = istart + nEdgeInteriorPoints;
243  for(i = istart; i < iend; i++)
244  {
245  for(j = istart+1; j < iend; j++)
246  {
247  if(m_points[1][j] < m_points[1][j-1])
248  {
249  std::swap(m_points[0][j], m_points[0][j-1]);
250  std::swap(m_points[1][j], m_points[1][j-1]);
251  }
252  }
253  }
254 
255  // group the points of edge 3 together;
256  istart = iend;
257  for(i = cnt = istart; i < nBoundaryPoints; i++)
258  {
259  if( fabs(m_points[0][i]+1.0) < NekConstants::kNekZeroTol)
260  {
261  std::swap(m_points[0][cnt], m_points[0][i]);
262  std::swap(m_points[1][cnt], m_points[1][i]);
263  cnt++;
264  }
265  }
266  // bubble sort edge 3 (counterclockwise numbering)
267  iend = istart + nEdgeInteriorPoints;
268  for(i = istart; i < iend; i++)
269  {
270  for(j = istart+1; j < iend; j++)
271  {
272  if(m_points[1][j] > m_points[1][j-1])
273  {
274  std::swap(m_points[0][j], m_points[0][j-1]);
275  std::swap(m_points[1][j], m_points[1][j-1]);
276  }
277  }
278  }
279  return;
280  }
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
static const NekDouble kNekZeroTol
unsigned int GetNumPoints() const
Definition: Points.h:246