Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NodalTriFekete.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File NodalTriFekete.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: 2D Nodal Triangle Fekete Point Definitions
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
45 
46 
47 namespace Nektar
48 {
49  namespace LibUtilities
50  {
51 
52 
53  // ////////////////////////////////////////////////////////
54  // Coordinate the nodal trianlge Fekete points
56  {
57  // Allocate the storage for points
59 
60  int index=0,isum=0;
61  const int offset = 3; //offset to match Datafile
62  NekDouble b,c;
63  unsigned int numPoints = GetNumPoints();
64 
65  // initialize values
66  for(unsigned int i=0; i < numPoints-2; ++i)
67  {
68  index += NodalTriFeketeNPTS[i];
69  }
70 
71  for(unsigned int i=0; i < NodalTriFeketeNPTS[numPoints-2]; ++i, ++index)
72  {
73  if(int(NodalTriFeketeData[index][0]))
74  {
75  b = NodalTriFeketeData[index][4];
76  c = NodalTriFeketeData[index][5];
77 
78  m_points[0][isum] = 2.0*b - 1.0;
79  m_points[1][isum] = 2.0*c - 1.0;
80  isum++;
81  continue;
82  }//end symmetry1
83 
84 
85  if(int(NodalTriFeketeData[index][1]) == 1)
86  {
87  for(unsigned int j=0; j < 3; ++j)
88  {
89  b = NodalTriFeketeData[index][offset+perm3A_2d[j][1]];
90  c = NodalTriFeketeData[index][offset+perm3A_2d[j][2]];
91  m_points[0][isum] = 2.0*b - 1.0;
92  m_points[1][isum] = 2.0*c - 1.0;
93  isum++;
94  }//end j
95  continue;
96  }//end symmetry3a
97 
98  if(int(NodalTriFeketeData[index][1]) == 2)
99  {
100  for(unsigned int j=0; j < 3; ++j)
101  {
102  b = NodalTriFeketeData[index][offset+perm3B_2d[j][1]];
103  c = NodalTriFeketeData[index][offset+perm3B_2d[j][2]];
104  m_points[0][isum] = 2.0*b - 1.0;
105  m_points[1][isum] = 2.0*c - 1.0;
106  isum++;
107  }//end j
108  continue;
109  }//end symmetry3b
110 
111 
112  if(int(NodalTriFeketeData[index][2]))
113  {
114  for(unsigned int j=0; j < 6; ++j)
115  {
116  b = NodalTriFeketeData[index][offset+perm6_2d[j][1]];
117  c = NodalTriFeketeData[index][offset+perm6_2d[j][2]];
118  m_points[0][isum] = 2.0*b - 1.0;
119  m_points[1][isum] = 2.0*c - 1.0;
120  isum++;
121  }//end j
122  continue;
123  }//end symmetry6
124  }//end npts
125 
127 
128  ASSERTL1((static_cast<unsigned int>(isum)==m_pointsKey.GetTotNumPoints()),"sum not equal to npts");
129  }
130 
132  {
133  // Allocate the storage for points
135 
136  typedef DataType T;
137 
138  // Solve the Vandermonde system of integrals for the weight vector
140 
141  m_weights = Array<OneD,T>( w.GetRows(), w.GetPtr() );
142 
143  }
144 
145  // ////////////////////////////////////////
146  // CalculateInterpMatrix()
148  Array<OneD, NekDouble>& interp)
149  {
152  NekVector<NekDouble> xi( xia );
153  NekVector<NekDouble> yi( yia );
154  NekMatrix<NekDouble> interMat = GetInterpolationMatrix(x, y, xi, yi);
155 
156  int rows = xi.GetRows(), cols = GetTotNumPoints();
157  for( int i = 0; i < rows; ++i ) {
158  for( int j = 0; j < cols; ++j ) {
159  interp[j + i*cols] = interMat(i,j);
160  }
161  }
162  }
163 
164  // ////////////////////////////////////////
165  // CalculateDerivMatrix()
167  {
168  // Allocate the derivative matrix.
170 
173  NekVector<NekDouble> xi = x;
174  NekVector<NekDouble> yi = y;
175 
176  m_derivmatrix[0] = GetXDerivativeMatrix(x,y,xi,yi);
177  m_derivmatrix[1] = GetYDerivativeMatrix(x,y,xi,yi);
178 
179  }
180 
181  boost::shared_ptr<PointsBaseType> NodalTriFekete::Create(const PointsKey &key)
182  {
183  boost::shared_ptr<PointsBaseType> returnval(MemoryManager<NodalTriFekete>::AllocateSharedPtr(key));
184  returnval->Initialize();
185  return returnval;
186  }
187 
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  }
281 
282 
283  } // end of namespace stdregion
284 } // end of namespace stdregion
285 
static const unsigned int perm3B_2d[3][3]
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:351
Array< OneD, DataType > m_points[3]
Definition: Points.h:349
static const unsigned int NodalTriFeketeNPTS[NodalTriFeketeAvailable]
NekVector< NekDouble > MakeQuadratureWeights(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y)
Definition: NodalUtil.cpp:579
static const NekDouble kNekZeroTol
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xi, const Array< OneD, const NekDouble > &yi, Array< OneD, NekDouble > &interp)
unsigned int GetNumPoints() const
Definition: Points.h:246
unsigned int GetTotNumPoints() const
Definition: Points.h:175
Points< NekDouble >::MatrixSharedPtrType GetXDerivativeMatrix(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y, const NekVector< NekDouble > &xi, const NekVector< NekDouble > &yi)
Definition: NodalUtil.cpp:852
Array< OneD, DataType > m_weights
Definition: Points.h:350
Defines a specification for a set of points.
Definition: Points.h:58
double NekDouble
static const unsigned int perm3A_2d[3][3]
unsigned int GetRows() const
Definition: NekVector.cpp:218
NekMatrix< NekDouble > GetInterpolationMatrix(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y, const NekVector< NekDouble > &xi, const NekVector< NekDouble > &yi)
Definition: NodalUtil.cpp:609
static boost::shared_ptr< PointsBaseType > Create(const PointsKey &key)
static const unsigned int perm6_2d[6][3]
unsigned int GetTotNumPoints() const
Definition: Points.h:251
static const NekDouble NodalTriFeketeData[][6]
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
Points< NekDouble >::MatrixSharedPtrType GetYDerivativeMatrix(const NekVector< NekDouble > &x, const NekVector< NekDouble > &y, const NekVector< NekDouble > &xi, const NekVector< NekDouble > &yi)
Definition: NodalUtil.cpp:1303
Array< OneD, DataType > & GetPtr()
Definition: NekVector.cpp:230