Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Points.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Points.hpp
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: Header file of Points definition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_FOUNDATIONS_POINTS_H
37 #define NEKTAR_LIB_UTILITIES_FOUNDATIONS_POINTS_H
38 
43 
44 //#include <LibUtilities/BasicUtils/BasicUtilsFwd.hpp> // for NekManager
47 
48 
49 namespace Nektar
50 {
51 
52  namespace LibUtilities
53  {
54  // Need to add method to compute total number of points given dimension
55  // and number of points.
56 
57  /// Defines a specification for a set of points.
58  class PointsKey
59  {
60  public:
61  // Used for looking up the creator. The creator for number of points
62  // can generate for any number, so we want the same creator called
63  // for all number.
64  struct opLess
65  {
66  LIB_UTILITIES_EXPORT bool operator()(const PointsKey &lhs, const PointsKey &rhs) const;
67  };
68 
69  /// Default constructor.
70  PointsKey(void):
71  m_numpoints(0),
73  m_factor(NekConstants::kNekUnsetDouble)
74  {
75  }
76 
77  /// Constructor defining the number and distribution of points.
78  PointsKey(const int &numpoints, const PointsType &pointstype,
80  m_numpoints(numpoints),
81  m_pointstype(pointstype),
82  m_factor(factor)
83  {
84  }
85 
86  /// Destructor.
87  virtual ~PointsKey()
88  {
89  }
90 
91  /// Copy constructor.
92  PointsKey(const PointsKey &key)
93  {
94  *this = key; // defer to assignment operator
95  }
96 
98  {
101  m_factor = key.m_factor;
102 
103  return *this;
104  }
105 
106  inline unsigned int GetNumPoints() const
107  {
108  return m_numpoints;
109  }
110 
111  inline PointsType GetPointsType() const
112  {
113  return m_pointstype;
114  }
115 
116  inline NekDouble GetFactor() const
117  {
118  return m_factor;
119  }
120 
121  inline bool operator==(const PointsKey &key)
122  {
123 
125  {
126  return (m_numpoints == key.m_numpoints &&
127  m_pointstype == key.m_pointstype);
128  }
129 
130  return false;
131  }
132 
133  inline bool operator== (const PointsKey *y)
134  {
135  return (*this == *y);
136  }
137 
138  inline bool operator != (const PointsKey& y)
139  {
140  return (!(*this == y));
141  }
142 
143  inline bool operator != (const PointsKey *y)
144  {
145  return (!(*this == *y));
146  }
147 
148  // If new points are added, this function must be modified
149  inline unsigned int GetPointsDim() const
150  {
151  int dimpoints = 1;
152 
153  switch(m_pointstype)
154  {
155  case eNodalTriElec:
156  case eNodalTriFekete:
158  case eNodalTriSPI:
159  case eNodalQuadElec:
160  dimpoints = 2;
161  break;
162 
163  case eNodalTetElec:
166  case eNodalPrismElec:
167  case eNodalHexElec:
168  dimpoints = 3;
169  break;
170 
171  default:
172  break;
173  }
174 
175  return dimpoints;
176  }
177 
178  // If new points are added, this function must be modified
179  inline unsigned int GetTotNumPoints() const
180  {
181  int totpoints = m_numpoints;
182 
183  switch(m_pointstype)
184  {
185  case eNodalTriElec:
186  case eNodalTriFekete:
188  totpoints = m_numpoints*(m_numpoints+1)/2;
189  break;
190  case eNodalTriSPI:
191  ASSERTL0(false,"this method cannot be implemented");
192  break;
193 
194  case eNodalQuadElec:
195  totpoints = m_numpoints*m_numpoints;
196  break;
197 
198  case eNodalTetElec:
200  totpoints = m_numpoints*(m_numpoints+1)*(m_numpoints+2)/6;
201  break;
202  case eNodalTetSPI:
203  ASSERTL0(false,"this method cannot be implemented");
204  break;
205 
207  case eNodalPrismElec:
208  totpoints = m_numpoints*m_numpoints*(m_numpoints+1)/2;
209  break;
210  case eNodalPrismSPI:
211  ASSERTL0(false,"this method cannot be implemented");
212  break;
213 
214  case eNodalHexElec:
215  totpoints = m_numpoints*m_numpoints*m_numpoints;
216  break;
217 
218  default:
219  break;
220  }
221 
222  return totpoints;
223  }
224 
225  LIB_UTILITIES_EXPORT friend bool operator==(const PointsKey &lhs, const PointsKey &rhs);
226  LIB_UTILITIES_EXPORT friend bool operator<(const PointsKey &lhs, const PointsKey &rhs);
227  LIB_UTILITIES_EXPORT friend bool opLess::operator()(const PointsKey &lhs, const PointsKey &rhs) const;
228 
229  protected:
230  unsigned int m_numpoints; //!< number of the points (as appropriately defined for PointsType)
231  PointsType m_pointstype; //!< Type of Points
232  NekDouble m_factor; //!< optional factor
233  private:
234  };
235 
236  static const PointsKey NullPointsKey(0, eNoPointsType);
237 
238  LIB_UTILITIES_EXPORT bool operator==(const PointsKey &lhs, const PointsKey &rhs);
239  LIB_UTILITIES_EXPORT bool operator<(const PointsKey &lhs, const PointsKey &rhs);
240  LIB_UTILITIES_EXPORT std::ostream& operator<<(std::ostream& os, const PointsKey& rhs);
241 
242  typedef std::vector<PointsKey> PointsKeyVector;
243 
244  /// Stores a set of points of datatype DataT, defined by a PointKey.
245  template<typename DataT>
246  class Points
247  {
248  public:
249  typedef DataT DataType;
250  typedef boost::shared_ptr<NekMatrix<DataType> > MatrixSharedPtrType;
251 
252  virtual ~Points()
253  {
254  }
255 
256  virtual void Initialize(void)
257  {
258  CalculatePoints();
261  }
262 
263  inline unsigned int GetPointsDim() const
264  {
265  return m_pointsKey.GetPointsDim();
266  }
267 
268  inline unsigned int GetNumPoints() const
269  {
270  return m_pointsKey.GetNumPoints();
271  }
272 
273  inline unsigned int GetTotNumPoints() const
274  {
275  return m_pointsKey.GetTotNumPoints();
276  }
277 
278  inline PointsType GetPointsType() const
279  {
280  return m_pointsKey.GetPointsType();
281  }
282 
283  inline const Array<OneD, const DataType>& GetZ() const
284  {
285  return m_points[0];
286  }
287 
288  inline const Array<OneD, const DataType>& GetW() const
289  {
290  return m_weights;
291  }
292 
295  {
296  z = m_points[0];
297  w = m_weights;
298  }
299 
301  {
302  x = m_points[0];
303  }
304 
307  {
308  x = m_points[0];
309  y = m_points[1];
310  }
311 
315  {
316  x = m_points[0];
317  y = m_points[1];
318  z = m_points[2];
319  }
320 
321  inline const MatrixSharedPtrType& GetD(Direction dir = xDir) const
322  {
323  return m_derivmatrix[(int)dir];
324  }
325 
326  virtual const MatrixSharedPtrType GetI(const PointsKey &pkey)
327  {
328  ASSERTL0(false, "Method not implemented ");
329  boost::shared_ptr<NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr());
330  return returnval;
331  }
332 
333  virtual const MatrixSharedPtrType GetI(const Array<OneD, const DataType>& x)
334  {
335  ASSERTL0(false, "Method not implemented");
336  boost::shared_ptr<NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr());
337  return returnval;
338  }
339 
340  virtual const MatrixSharedPtrType GetI(unsigned int numpoints, const Array<OneD, const DataType>& x)
341  {
342  ASSERTL0(false, "Method not implemented");
343  boost::shared_ptr<NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr());
344  return returnval;
345  }
346 
347  virtual const MatrixSharedPtrType GetI(const Array<OneD, const DataType>& x, const Array<OneD, const DataType>& y)
348  {
349  ASSERTL0(false, "Method not implemented");
350  boost::shared_ptr<NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr());
351  return returnval;
352  }
353 
354  virtual const MatrixSharedPtrType GetI(const Array<OneD, const DataType>& x, const Array<OneD, const DataType>& y,
356  {
357  ASSERTL0(false, "Method not implemented");
358  boost::shared_ptr<NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr());
359  return returnval;
360  }
361 
362  virtual const MatrixSharedPtrType GetGalerkinProjection(const PointsKey &pkey)
363  {
364  ASSERTL0(false, "Method not implemented ");
365  boost::shared_ptr<NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr());
366  return returnval;
367  }
368 
369  protected:
373  MatrixSharedPtrType m_derivmatrix[3];
376 
377  virtual void CalculatePoints()
378  {
379  unsigned int pointsDim = GetPointsDim();
380  unsigned int totNumPoints = GetTotNumPoints();
381 
382  for (unsigned int i=0; i<pointsDim; ++i)
383  {
384  m_points[i] = Array<OneD, DataType>(totNumPoints);
385  }
386  }
387 
388  virtual void CalculateWeights()
389  {
390  m_weights = Array<OneD, DataType>(GetTotNumPoints());
391  }
392 
393  virtual void CalculateDerivMatrix()
394  {
395  int totNumPoints = GetTotNumPoints();
396  for(unsigned int i = 0; i < m_pointsKey.GetPointsDim(); ++i)
397  {
398  m_derivmatrix[i] = MemoryManager<NekMatrix<DataType> >::AllocateSharedPtr(totNumPoints,totNumPoints);
399  }
400  }
401 
402  Points(const PointsKey &key):m_pointsKey(key)
403  {
404  }
405 
406  private:
407  // These should never be called
408  Points(const Points &pts)
409  {
410  NEKERROR(ErrorUtil::efatal,"Copy Constructor for Points should not be called");
411  }
413  {
414  NEKERROR(ErrorUtil::efatal,"Default Constructor for Points should not be called");
415  }
416  };
417 
418  }; // end of namespace
419 } // end of namespace
420 
421 #endif //NEKTAR_LIB_UTILITIES_FOUNDATIONS_POINTS_H
const MatrixSharedPtrType & GetD(Direction dir=xDir) const
Definition: Points.h:321
bool operator!=(const PointsKey &y)
Definition: Points.h:138
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_GalerkinProjectionManager
Definition: Points.h:375
static const PointsKey NullPointsKey(0, eNoPointsType)
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
Points(const Points &pts)
Definition: Points.h:408
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:191
virtual const MatrixSharedPtrType GetI(const Array< OneD, const DataType > &x)
Definition: Points.h:333
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:242
virtual void CalculatePoints()
Definition: Points.h:377
NekDouble GetFactor() const
Definition: Points.h:116
virtual const MatrixSharedPtrType GetI(const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y)
Definition: Points.h:347
PointsType GetPointsType() const
Definition: Points.h:278
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
PointsKey(const PointsKey &key)
Copy constructor.
Definition: Points.h:92
NekDouble m_factor
optional factor
Definition: Points.h:232
void GetPoints(Array< OneD, const DataType > &x, Array< OneD, const DataType > &y) const
Definition: Points.h:305
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:373
Array< OneD, DataType > m_points[3]
Definition: Points.h:371
PointsType m_pointstype
Type of Points.
Definition: Points.h:231
unsigned int m_numpoints
number of the points (as appropriately defined for PointsType)
Definition: Points.h:230
3D Nodal Symmetric positive internal tet (Whitherden, Vincent)
Definition: PointsType.h:78
StandardMatrixTag & lhs
bool operator==(const BasisKey &x, const BasisKey &y)
Definition: Basis.cpp:703
const Array< OneD, const DataType > & GetW() const
Definition: Points.h:288
unsigned int GetPointsDim() const
Definition: Points.h:263
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
Definition: Basis.cpp:85
virtual const MatrixSharedPtrType GetI(const PointsKey &pkey)
Definition: Points.h:326
boost::shared_ptr< NekMatrix< DataType > > MatrixSharedPtrType
Definition: Points.h:250
bool operator()(const PointsKey &lhs, const PointsKey &rhs) const
Definition: Points.cpp:90
const Array< OneD, const DataType > & GetZ() const
Definition: Points.h:283
static const NekDouble kNekZeroTol
virtual const MatrixSharedPtrType GetI(unsigned int numpoints, const Array< OneD, const DataType > &x)
Definition: Points.h:340
PointsKey & operator=(const PointsKey &key)
Definition: Points.h:97
virtual const MatrixSharedPtrType GetGalerkinProjection(const PointsKey &pkey)
Definition: Points.h:362
unsigned int GetNumPoints() const
Definition: Points.h:268
#define LIB_UTILITIES_EXPORT
Points(const PointsKey &key)
Definition: Points.h:402
3D Nodal Electrostatic Points on a Tetrahedron
Definition: PointsType.h:74
unsigned int GetTotNumPoints() const
Definition: Points.h:179
unsigned int GetPointsDim() const
Definition: Points.h:149
Array< OneD, DataType > m_weights
Definition: Points.h:372
Defines a specification for a set of points.
Definition: Points.h:58
double NekDouble
void GetPoints(Array< OneD, const DataType > &x) const
Definition: Points.h:300
bool operator==(const PointsKey &key)
Definition: Points.h:121
virtual void CalculateDerivMatrix()
Definition: Points.h:393
static const NekDouble kNekUnsetDouble
bool operator<(const BasisKey &lhs, const BasisKey &rhs)
Definition: Basis.cpp:49
3D Evenly-spaced points on a Tetrahedron
Definition: PointsType.h:73
virtual const MatrixSharedPtrType GetI(const Array< OneD, const DataType > &x, const Array< OneD, const DataType > &y, const Array< OneD, const DataType > &z)
Definition: Points.h:354
2D Nodal Fekete Points on a Triangle
Definition: PointsType.h:71
void GetPoints(Array< OneD, const DataType > &x, Array< OneD, const DataType > &y, Array< OneD, const DataType > &z) const
Definition: Points.h:312
virtual ~PointsKey()
Destructor.
Definition: Points.h:87
PointsKey(void)
Default constructor.
Definition: Points.h:70
void GetZW(Array< OneD, const DataType > &z, Array< OneD, const DataType > &w) const
Definition: Points.h:293
friend bool operator<(const PointsKey &lhs, const PointsKey &rhs)
Definition: Points.cpp:55
unsigned int GetNumPoints() const
Definition: Points.h:106
PointsKey(const int &numpoints, const PointsType &pointstype, const NekDouble factor=NekConstants::kNekUnsetDouble)
Constructor defining the number and distribution of points.
Definition: Points.h:78
3D Evenly-spaced points on a Prism
Definition: PointsType.h:75
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:72
virtual void Initialize(void)
Definition: Points.h:256
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_InterpManager
Definition: Points.h:374
unsigned int GetTotNumPoints() const
Definition: Points.h:273
1D Array of constant elements with garbage collection and bounds checking.
Definition: SharedArray.hpp:60
PointsType GetPointsType() const
Definition: Points.h:111
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:70
Stores a set of points of datatype DataT, defined by a PointKey.
3D electrostatically spaced points on a Prism
Definition: PointsType.h:76
2D Nodal Symmetric positive internal triangle (Whitherden, Vincent)
Definition: PointsType.h:77
virtual void CalculateWeights()
Definition: Points.h:388