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