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