Nektar++
Loading...
Searching...
No Matches
Foundations/Points.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: Points.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// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: 1D Points definitions
32//
33///////////////////////////////////////////////////////////////////////////////
34
36
38{
39/**
40 * @class PointsKey
41 * Specification for a set of points. This includes the total number of
42 * points, as well as their distribution.
43 */
44
45bool operator==(const PointsKey &lhs, const PointsKey &rhs)
46{
47 return (lhs.m_numpoints == rhs.m_numpoints &&
48 lhs.m_pointstype == rhs.m_pointstype);
49}
50
51bool operator<(const PointsKey &lhs, const PointsKey &rhs)
52{
53 if (lhs.m_pointstype < rhs.m_pointstype)
54 {
55 return true;
56 }
57
58 if (lhs.m_pointstype > rhs.m_pointstype)
59 {
60 return false;
61 }
62
63 if (lhs.m_numpoints < rhs.m_numpoints)
64 {
65 return true;
66 }
67
68 if (lhs.m_numpoints > rhs.m_numpoints)
69 {
70 return false;
71 }
72
73 if (lhs.m_factor < rhs.m_factor)
74 {
75 return true;
76 }
77
78 if (lhs.m_factor > rhs.m_factor)
79 {
80 return false;
81 }
82
83 return false;
84}
85
87 const PointsKey &rhs) const
88{
89 return (lhs.m_pointstype < rhs.m_pointstype);
90}
91
92std::ostream &operator<<(std::ostream &os, const PointsKey &rhs)
93{
94 os << "NumPoints: " << rhs.GetNumPoints()
95 << " PointsType: " << kPointsTypeStr[rhs.GetPointsType()] << std::endl;
96
97 return os;
98}
99
100void GetEffectiveQuadRange(const LibUtilities::PointsKey &pkey, int &q_begin,
101 int &q_end)
102{
103 switch (pkey.GetPointsType())
104 {
106 {
107 q_begin = 1;
108 q_end = pkey.GetNumPoints();
109 }
110 break;
112 {
113 q_begin = 1;
114 q_end = pkey.GetNumPoints() - 1;
115 }
116 break;
117 default:
118 {
119 q_begin = 0;
120 q_end = pkey.GetNumPoints();
121 }
122 }
123}
124
125int GetDegreeOfExactness(const PointsType ptype, const int npt)
126{
127 switch (ptype)
128 {
131 {
132 return 2 * npt - 1;
133 }
135 {
136 return 2 * (npt - 2) - 1;
137 }
139 {
140 return 2 * (npt - 1) - 1;
141 }
146 case eGaussRadauMAlpha0Beta2:
147 case eGaussRadauMAlpha1Beta0:
148 case eGaussRadauMAlpha2Beta0:
149 {
150 return 2 * npt - 2;
151 }
154 {
155 return 2 * npt - 3;
156 }
157 case eGaussKronrodLegendre:
158 {
159 return 3 * (npt - 1) / 2 + 1;
160 }
163 {
164 return 3 * (npt - 2) / 2; // not for sure
165 }
167 {
168 return 3 * (npt - 3) / 2; // not for sure
169 }
170 default:
171 break; // make it happy
172 }
173 return npt;
174}
175/**
176 * @class Nektar::LibUtilities::Points
177 * This encapsulates a set of points, specified by a PointKey. The
178 * class stores not only the point coordinates, but also the
179 * integration weights and derivative matrix coefficients. Memory is
180 * allocated from the memory pool if in use.
181 */
182
183} // namespace Nektar::LibUtilities
Defines a specification for a set of points.
Definition Points.h:50
size_t m_numpoints
number of the points (as appropriately defined for PointsType)
Definition Points.h:216
PointsType GetPointsType() const
Definition Points.h:90
PointsType m_pointstype
Type of Points.
Definition Points.h:218
size_t GetNumPoints() const
Definition Points.h:85
NekDouble m_factor
optional factor
Definition Points.h:219
bool operator==(const BasisKey &x, const BasisKey &y)
void GetEffectiveQuadRange(const LibUtilities::PointsKey &pkey, int &q_begin, int &q_end)
const std::string kPointsTypeStr[]
bool operator<(const BasisKey &lhs, const BasisKey &rhs)
int GetDegreeOfExactness(const PointsType ptype, const int npt)
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
@ eGaussRadauMLegendre
1D Gauss-Radau-Legendre quadrature points, pinned at x=-1
Definition PointsType.h:47
@ eGaussLegendreWithMP
1D Gauss-Legendre quadrature points with additional x=-1 and x=1 end points
Definition PointsType.h:95
@ eGaussRadauMAlpha0Beta1
Gauss Radau pinned at x=-1,.
Definition PointsType.h:58
@ eGaussRadauKronrodMLegendre
1D Gauss-Radau-Kronrod-Legendre quadrature points, pinned at x=-1
Definition PointsType.h:67
@ eGaussLobattoChebyshev
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:57
@ eGaussRadauMChebyshev
1D Gauss-Radau-Chebyshev quadrature points, pinned at x=-1
Definition PointsType.h:53
@ eGaussRadauKronrodMAlpha1Beta0
1D Gauss-Radau-Kronrod-Legendre pinned at x=-1,
Definition PointsType.h:69
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eGaussLegendreWithM
1D Gauss-Legendre quadrature points with additional x=-1 point
Definition PointsType.h:97
@ eGaussGaussChebyshev
1D Gauss-Gauss-Chebyshev quadrature points
Definition PointsType.h:52
@ eGaussLobattoKronrodLegendre
1D Lobatto Kronrod quadrature points
Definition PointsType.h:72
@ eGaussGaussLegendre
1D Gauss-Gauss-Legendre quadrature points
Definition PointsType.h:46
@ eGaussRadauPLegendre
1D Gauss-Radau-Legendre quadrature points, pinned at x=1
Definition PointsType.h:49
bool operator()(const PointsKey &lhs, const PointsKey &rhs) const