Nektar++
Python/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: Python wrapper for Points.
32//
33///////////////////////////////////////////////////////////////////////////////
34
38
40
41using namespace Nektar;
42using namespace Nektar::LibUtilities;
43
44typedef std::shared_ptr<Points<double>> PointsSharedPtr;
45typedef std::shared_ptr<NekMatrix<NekDouble>> MatrixSharedPtrType;
46
48{
49 return PointsManager()[pts];
50}
51
53{
54 return py::make_tuple(pts->GetZ(), pts->GetW());
55}
56
58{
59 return pts->GetD();
60}
61
63{
64 return pts->GetD(dir);
65}
66
67/**
68 * @brief Points exports.
69 */
71{
74 "Characterise the type of points.\n"
75 "\n"
76 "Sample usage: PointsType.GaussLobattoLegendre\n"
77 "\n"
78 "Available point types:\n"
79 "\tNoPointsType: No points type.\n"
80 "\tGaussGaussLegendre: 1D Gauss-Gauss-Legendre quadrature points.\n"
81 "\tGaussRadauMLegendre: 1D Gauss-Radau-Legendre quadrature points,\n"
82 "\t\tpinned at x=-1.\n"
83 "\tGaussRadauPLegendre: 1D Gauss-Radau-Legendre quadrature points,\n"
84 "\t\tpinned at x=1.\n"
85 "\tGaussLobattoLegendre: 1D Gauss-Lobatto-Legendre quadrature points.\n"
86 "\tGaussGaussChebyshev: 1D Gauss-Gauss-Chebyshev quadrature points.\n"
87 "\tGaussRadauMChebyshev: 1D Gauss-Radau-Chebyshev quadrature points,\n"
88 "\t\tpinned at x=-1.\n"
89 "\tGaussRadauPChebyshev: 1D Gauss-Radau-Chebyshev quadrature points,\n"
90 "\t\tpinned at x=1.\n"
91 "\tGaussLobattoChebyshev: 1D Gauss-Lobatto-Legendre quadrature points\n"
92 "\tGaussRadauMAlpha0Beta1: Gauss Radau pinned at x=-1,\n"
93 "\t\talpha = 0, beta = 1\n"
94 "\tGaussRadauMAlpha0Beta2: Gauss Radau pinned at x=-1,\n"
95 "\t\talpha = 0, beta = 2\n"
96 "\tGaussRadauMAlpha1Beta0: Gauss Radau pinned at x=-1,\n"
97 "\t\talpha = 1, beta = 0\n"
98 "\tGaussRadauMAlpha2Beta0: Gauss Radau pinned at x=-1,\n"
99 "\t\talpha = 2, beta = 0\n"
100 "\tGaussKronrodLegendre: 1D Gauss-Kronrod-Legendre quadrature points.\n"
101 "\tGaussRadauKronrodMLegendre: 1D Gauss-Radau-Kronrod-Legendre "
102 "quadrature\n"
103 "\t\tpoints, pinned at x=-1.\n"
104 "\tGaussRadauKronrodMAlpha1Beta0: 1D Gauss-Radau-Kronrod-Legendre\n"
105 "\t\tpinned at x=-1, alpha = 1, beta = 0\n"
106 "\tGaussLobattoKronrodLegendre: 1D Lobatto Kronrod quadrature points.\n"
107 "\tPolyEvenlySpaced: 1D Evenly-spaced points using Lagrange "
108 "polynomial.\n"
109 "\tFourierEvenlySpaced: 1D Evenly-spaced points using Fourier Fit.\n"
110 "\tFourierSingleModeSpaced: 1D Non Evenly-spaced points for Single "
111 "Mode\n"
112 "\t\tanalysis.\n"
113 "\tBoundaryLayerPoints: 1D power law distribution for boundary layer "
114 "points.\n"
115 "\tBoundaryLayerPointsRev: 1D power law distribution for boundary "
116 "layer\n"
117 "\t\tpoints.\n"
118 "\tNodalTriElec: 2D Nodal Electrostatic Points on a Triangle.\n"
119 "\tNodalTriFekete: 2D Nodal Fekete Points on a Triangle.\n"
120 "\tNodalTriEvenlySpaced: 2D Evenly-spaced points on a Triangle.\n"
121 "\tNodalTetEvenlySpaced: 3D Evenly-spaced points on a Tetrahedron.\n"
122 "\tNodalTetElec: 3D Nodal Electrostatic Points on a Tetrahedron.\n"
123 "\tNodalPrismEvenlySpaced: 3D Evenly-spaced points on a Prism.\n"
124 "\tNodalPrismElec: 3D electrostatically spaced points on a Prism.\n"
125 "\tNodalTriSPI: 2D Nodal Symmetric positive internal triangle\n"
126 "\t\t(Whitherden, Vincent).\n"
127 "\tNodalTetSPI: 3D Nodal Symmetric positive internal tet\n"
128 "\t\t(Whitherden, Vincent).\n"
129 "\tNodalPrismSPI: 3D prism SPI.\n"
130 "\tNodalQuadElec: 2D GLL for quad.\n"
131 "\tNodalHexElec: 3D GLL for hex");
132
133 py::class_<PointsKey>(
134 "PointsKey",
135 "Create a PointsKey which uniquely defines quadrature points.\n"
136 "\n"
137 "Args:\n"
138 "\tnQuadPoints (integer): The number of quadrature points.\n"
139 "\tpointsType (PointsType object): The type of quadrature points.",
140 py::init<const int, const PointsType &>())
141
142 .def("GetNumPoints", &PointsKey::GetNumPoints,
143 "Get the number of quadrature points in PointsKey.\n"
144 "\n"
145 "Args:\n"
146 "\tNone\n"
147 "Returns:\n"
148 "\tInteger defining the number of quadrature points in PointsKey.")
149 .def("GetPointsType", &PointsKey::GetPointsType,
150 "Get the type of points in PointsKey.\n"
151 "\n"
152 "Args:\n"
153 "\tNone\n"
154 "Returns:\n"
155 "\tPointsType object specifying the type of points in PointsKey.")
156 .def("GetPointsDim", &PointsKey::GetPointsDim,
157 "Get the dimension of the PointsKey.\n"
158 "\n"
159 "Args:\n"
160 "\tNone\n"
161 "Returns:\n"
162 "\tInteger characterising the dimension of the PointsKey (e.g. 2\n"
163 "\tfor 2D PointsKey).")
164 .def("GetTotNumPoints", &PointsKey::GetTotNumPoints,
165 "Get the total number of points in PointsKey.\n"
166 "\n"
167 "Args:\n"
168 "\tNone\n"
169 "Returns:\n"
170 "\tInteger defining the total number of points in PointsKey.");
171
172 py::class_<Points<double>, std::shared_ptr<Points<double>>,
173 boost::noncopyable>(
174 "Points",
175 "Create a set of points which can be used to calculate\n"
176 "quadrature zeros, weights etc."
177 "\n"
178 "Args:\n"
179 "\tNone",
180 py::no_init)
181 .def("Create", &Points_Create,
182 "Create a Points object using PointsKey.\n"
183 "\n"
184 "Args:\n"
185 "\tpointsKey (PointsKey object): The PointsKey to be used to\n"
186 "\tcreate points.\n"
187 "Returns:\n"
188 "\tPoints object created with the given PointsKey.")
189 .staticmethod("Create")
190
191 .def("Initialise", &Points<double>::Initialize,
192 "Initialise Points object by calculating points, weights\n"
193 "and differentiation matrix.\n"
194 "\n"
195 "Args:\n"
196 "\tNone\n"
197 "Returns:\n"
198 "\tNone")
199 .def("GetPointsDim", &Points<double>::GetPointsDim,
200 "Get the dimension of the Points object.\n"
201 "\n"
202 "Args:\n"
203 "\tNone\n"
204 "Returns:\n"
205 "\tInteger characterising the dimension of the Points object\n"
206 "\t(e.g. 2 for 2D Points object).")
207 .def("GetPointsType", &Points<double>::GetPointsType,
208 "Get the type of points in Points object.\n"
209 "\n"
210 "Args:\n"
211 "\tNone\n"
212 "Returns:\n"
213 "\tPointsType object specifying the type of points in Points\n"
214 "\tobject.")
215 .def("GetNumPoints", &Points<double>::GetNumPoints,
216 "Get the number of quadrature points in Points object.\n"
217 "\n"
218 "Args:\n"
219 "\tNone\n"
220 "Returns:\n"
221 "\tInteger defining the number of quadrature points in Points\n"
222 "\tobject.")
223 .def("GetTotNumPoints", &Points<double>::GetTotNumPoints,
224 "Get the total number of points in Points object.\n"
225 "\n"
226 "Args:\n"
227 "\tNone\n"
228 "Returns:\n"
229 "\tInteger defining the total number of points in Points\n"
230 "\tobject.")
231
232 .def("GetZ", &Points<double>::GetZ,
233 py::return_value_policy<py::copy_const_reference>(),
234 "Get quadrature zeros.\n"
235 "\n"
236 "Args:\n"
237 "\tNone\n"
238 "Returns:\n"
239 "\tNumPy ndarray of length equal to the number of quadrature\n"
240 "\tpoints, containing quadrature zeros.")
241 .def("GetW", &Points<double>::GetW,
242 py::return_value_policy<py::copy_const_reference>(),
243 "Get quadrature weights.\n"
244 "\n"
245 "Args:\n"
246 "\tNone\n"
247 "Returns:\n"
248 "\tNumPy ndarray of length equal to the number of quadrature\n"
249 "\tpoints, containing quadrature weights.")
250 .def("GetZW", &Points_GetZW,
251 "Get quadrature zeros and weights.\n"
252 "\n"
253 "Args:\n"
254 "\tNone\n"
255 "Returns:\n"
256 "\tTuple containing the quadrature zeros and quadrature weights,\n"
257 "\ti.e. (Points.GetZ(), Points.GetW()).")
258 .def("GetD", &Points_GetD,
259 "Get the differentiation matrix.\n"
260 "\n"
261 "Args:\n"
262 "\tNone\n"
263 "Returns:\n"
264 "\tNumPy ndarray of n x n dimensions, where n is equal to\n"
265 "\tthe number of quadrature points, containing the\n"
266 "\tdifferentiation matrix.")
267 .def("GetD", &Points_GetD2,
268 "Get the differentiation matrix.\n"
269 "\n"
270 "Args:\n"
271 "\tdir (Direction object): The direction of the desired\n"
272 "\tdifferentiation matrix.\n"
273 "Returns:\n"
274 "\tNumPy ndarray of n x n dimensions, where n is equal to\n"
275 "\tthe number of quadrature points containing the\n"
276 "\tdifferentiation matrix.");
277}
#define NEKPY_WRAP_ENUM_STRING_DOCS(ENUMNAME, MAPNAME, DOCSTRING)
py::tuple Points_GetZW(PointsSharedPtr pts)
MatrixSharedPtrType Points_GetD(PointsSharedPtr pts)
std::shared_ptr< NekMatrix< NekDouble > > MatrixSharedPtrType
std::shared_ptr< Points< double > > PointsSharedPtr
void export_Points()
Points exports.
PointsSharedPtr Points_Create(const PointsKey &pts)
MatrixSharedPtrType Points_GetD2(PointsSharedPtr pts, Direction dir)
Stores a set of points of datatype DataT, defined by a PointKey.
Definition: Points.h:235
Defines a specification for a set of points.
Definition: Points.h:50
std::shared_ptr< Points< NekDouble > > PointsSharedPtr
const std::string kPointsTypeStr[]
Definition: Foundations.hpp:52
PointsManagerT & PointsManager(void)