Nektar++
Polylib.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Polylib.h
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:
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef H_PLYLIB
36 
39 #include <complex>
40 
41 /*
42  * LIBRARY ROUTINES FOR POLYNOMIAL CALCULUS AND INTERPOLATION
43  */
44 
45 /** \brief The namespace associated with the the Polylib library
46  * (\ref pagePolylib "Polylib introduction")
47  */
48 namespace Polylib
49 {
50 
51 /**
52  \page pagePolylib The Polylib library
53  \section sectionPolyLib Routines For Orthogonal Polynomial Calculus and
54  Interpolation
55 
56  Spencer Sherwin,
57  Aeronautics, Imperial College London
58 
59  Based on codes by Einar Ronquist and Ron Henderson
60 
61  Abbreviations
62  - z - Set of collocation/quadrature points
63  - w - Set of quadrature weights
64  - D - Derivative matrix
65  - h - Lagrange Interpolant
66  - I - Interpolation matrix
67  - g - Gauss
68  - k - Kronrod
69  - gr - Gauss-Radau
70  - gl - Gauss-Lobatto
71  - j - Jacobi
72  - m - point at minus 1 in Radau rules
73  - p - point at plus 1 in Radau rules
74 
75  -----------------------------------------------------------------------\n
76  MAIN ROUTINES\n
77  -----------------------------------------------------------------------\n
78 
79  Points and Weights:
80 
81  - zwgj Compute Gauss-Jacobi points and weights
82  - zwgrjm Compute Gauss-Radau-Jacobi points and weights (z=-1)
83  - zwgrjp Compute Gauss-Radau-Jacobi points and weights (z= 1)
84  - zwglj Compute Gauss-Lobatto-Jacobi points and weights
85  - zwgk Compute Gauss-Kronrod-Jacobi points and weights
86  - zwrk Compute Radau-Kronrod points and weights
87  - zwlk Compute Lobatto-Kronrod points and weights
88  - JacZeros Compute Gauss-Jacobi points and weights
89 
90  Integration Matrices:
91 
92  - Qg Compute Gauss integration matrix
93 
94  Derivative Matrices:
95 
96  - Dgj Compute Gauss-Jacobi derivative matrix
97  - Dgrjm Compute Gauss-Radau-Jacobi derivative matrix (z=-1)
98  - Dgrjp Compute Gauss-Radau-Jacobi derivative matrix (z= 1)
99  - Dglj Compute Gauss-Lobatto-Jacobi derivative matrix
100 
101  Lagrange Interpolants:
102 
103  - hgj Compute Gauss-Jacobi Lagrange interpolants
104  - hgrjm Compute Gauss-Radau-Jacobi Lagrange interpolants (z=-1)
105  - hgrjp Compute Gauss-Radau-Jacobi Lagrange interpolants (z= 1)
106  - hglj Compute Gauss-Lobatto-Jacobi Lagrange interpolants
107 
108  Interpolation Operators:
109 
110  - Imgj Compute interpolation operator gj->m
111  - Imgrjm Compute interpolation operator grj->m (z=-1)
112  - Imgrjp Compute interpolation operator grj->m (z= 1)
113  - Imglj Compute interpolation operator glj->m
114 
115  Polynomial Evaluation:
116 
117  - polycoeff Returns value and derivative of Jacobi poly.
118  - jacobfd Returns value and derivative of Jacobi poly. at point z
119  - jacobd Returns derivative of Jacobi poly. at point z (valid at z=-1,1)
120 
121  -----------------------------------------------------------------------\n
122  LOCAL ROUTINES\n
123  -----------------------------------------------------------------------\n
124 
125  - jacobz Returns Jacobi polynomial zeros
126  - gammaf Gamma function for integer values and halves
127  - RecCoeff Calculates the recurrence coefficients for orthogonal poly
128  - TriQL QL algorithm for symmetrix tridiagonal matrix
129  - JKMatrix Generates the Jacobi-Kronrod matrix
130 
131  ------------------------------------------------------------------------\n
132 
133  Useful references:
134 
135  - [1] Gabor Szego: Orthogonal Polynomials, American Mathematical Society,
136  Providence, Rhode Island, 1939.
137  - [2] Abramowitz \& Stegun: Handbook of Mathematical Functions,
138  Dover, New York, 1972.
139  - [3] Canuto, Hussaini, Quarteroni \& Zang: Spectral Methods in Fluid
140  Dynamics, Springer-Verlag, 1988.
141  - [4] Ghizzetti \& Ossicini: Quadrature Formulae, Academic Press, 1970.
142  - [5] Karniadakis \& Sherwin: Spectral/hp element methods for CFD, 1999
143 
144 
145  NOTES
146 
147  -# Legendre polynomial \f$ \alpha = \beta = 0 \f$
148  -# Chebychev polynomial \f$ \alpha = \beta = -0.5 \f$
149  -# All routines are double precision.
150  -# All array subscripts start from zero, i.e. vector[0..N-1]
151 */
152 
153 /*-----------------------------------------------------------------------
154  M A I N R O U T I N E S
155  -----------------------------------------------------------------------*/
156 
157 /* Points and weights */
158 LIB_UTILITIES_EXPORT void zwgj(double *, double *, const int, const double,
159  const double);
160 LIB_UTILITIES_EXPORT void zwgrjm(double *, double *, const int, const double,
161  const double);
162 LIB_UTILITIES_EXPORT void zwgrjp(double *, double *, const int, const double,
163  const double);
164 LIB_UTILITIES_EXPORT void zwglj(double *, double *, const int, const double,
165  const double);
166 LIB_UTILITIES_EXPORT void zwgk(double *, double *, const int, const double,
167  const double);
168 LIB_UTILITIES_EXPORT void zwrk(double *, double *, const int, const double,
169  const double);
170 LIB_UTILITIES_EXPORT void zwlk(double *, double *, const int, const double,
171  const double);
172 LIB_UTILITIES_EXPORT void JacZeros(const int, double *, double *, const double,
173  const double);
174 
175 /* Integration operators */
176 LIB_UTILITIES_EXPORT void Qg(double *, const double *, const int, const int);
177 
178 /* Derivative operators */
179 LIB_UTILITIES_EXPORT void Dgj(double *, const double *, const int, const double,
180  const double);
181 LIB_UTILITIES_EXPORT void Dgrjm(double *, const double *, const int,
182  const double, const double);
183 LIB_UTILITIES_EXPORT void Dgrjp(double *, const double *, const int,
184  const double, const double);
185 LIB_UTILITIES_EXPORT void Dglj(double *, const double *, const int,
186  const double, const double);
187 
188 /* Lagrangian interpolants */
189 LIB_UTILITIES_EXPORT double hgj(const int, const double, const double *,
190  const int, const double, const double);
191 LIB_UTILITIES_EXPORT double hgrjm(const int, const double, const double *,
192  const int, const double, const double);
193 LIB_UTILITIES_EXPORT double hgrjp(const int, const double, const double *,
194  const int, const double, const double);
195 LIB_UTILITIES_EXPORT double hglj(const int, const double, const double *,
196  const int, const double, const double);
197 
198 /* Interpolation operators */
199 LIB_UTILITIES_EXPORT void Imgj(double *, const double *, const double *,
200  const int, const int, const double,
201  const double);
202 LIB_UTILITIES_EXPORT void Imgrjm(double *, const double *, const double *,
203  const int, const int, const double,
204  const double);
205 LIB_UTILITIES_EXPORT void Imgrjp(double *, const double *, const double *,
206  const int, const int, const double,
207  const double);
208 LIB_UTILITIES_EXPORT void Imglj(double *, const double *, const double *,
209  const int, const int, const double,
210  const double);
211 
212 /* Polynomial functions */
213 LIB_UTILITIES_EXPORT void polycoeffs(const int, const double *, double *,
214  const int);
215 LIB_UTILITIES_EXPORT void jacobfd(const int, const double *, double *, double *,
216  const int, const double, const double);
217 LIB_UTILITIES_EXPORT void jacobd(const int, const double *, double *, const int,
218  const double, const double);
219 
220 LIB_UTILITIES_EXPORT std::complex<Nektar::NekDouble> ImagBesselComp(
221  const int, std::complex<Nektar::NekDouble>);
222 
223 /* Gamma function routines */
224 LIB_UTILITIES_EXPORT double gammaF(const double);
225 LIB_UTILITIES_EXPORT double gammaFracGammaF(const int, const double, const int,
226  const double);
227 
228 } // namespace Polylib
229 
230 #define H_PLYLIB
231 #endif /* END OF POLYLIB.H DECLARATIONS */
#define LIB_UTILITIES_EXPORT
The namespace associated with the the Polylib library (Polylib introduction)
Definition: Polylib.cpp:52
double gammaF(const double)
Calculate the Gamma function , , for integer values and halves.
Definition: Polylib.cpp:1322
void Dgj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Jacobi zeros.
Definition: Polylib.cpp:627
void zwgrjm(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=-1.
Definition: Polylib.cpp:161
void JacZeros(const int n, double *a, double *b, const double alpha, const double beta)
Zero and Weight determination through the eigenvalues and eigenvectors of a tridiagonal matrix from t...
Definition: Polylib.cpp:1512
void zwgrjp(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=1.
Definition: Polylib.cpp:202
void Dglj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Lobatto-Jacobi zeros.
Definition: Polylib.cpp:787
void Imgrjp(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=1) to an arbitrary distrubtion at ...
Definition: Polylib.cpp:1054
void Qg(double *Q, const double *z, const int np, const int offset)
Compute the Integration Matrix.
Definition: Polylib.cpp:584
void zwglj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Lobatto-Jacobi zeros and weights with end point at z=-1,1.
Definition: Polylib.cpp:241
void zwgj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Jacobi zeros and weights.
Definition: Polylib.cpp:133
void polycoeffs(const int i, const double *z, double *c, const int np)
Definition: Polylib.cpp:1103
void Imgj(double *im, const double *zgj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Jacobi points to an arbitrary distribution at points zm.
Definition: Polylib.cpp:992
double hgrjm(const int i, const double z, const double *zgrj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Radau-Jacobi points zgrj at...
Definition: Polylib.cpp:893
double gammaFracGammaF(const int, const double, const int, const double)
Calculate fraction of two Gamma functions, , for integer values and halves.
Definition: Polylib.cpp:1371
double hgj(const int i, const double z, const double *zgj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Jacobi points zgj at the ar...
Definition: Polylib.cpp:858
void Imgrjm(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=-1) to an arbitrary distrubtion at...
Definition: Polylib.cpp:1023
void zwgk(double *z, double *w, const int npt, const double alpha, const double beta)
Gauss-Kronrod-Jacobi zeros and weights.
Definition: Polylib.cpp:290
void Dgrjm(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Radau-Jacobi zeros with a z...
Definition: Polylib.cpp:674
std::complex< Nektar::NekDouble > ImagBesselComp(int n, std::complex< Nektar::NekDouble > y)
Calcualte the bessel function of the first kind with complex double input y. Taken from Numerical Rec...
Definition: Polylib.cpp:1837
void Dgrjp(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Radau-Jacobi zeros with a zero at z=1.
Definition: Polylib.cpp:730
double hgrjp(const int i, const double z, const double *zgrj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Radau-Jacobi points zgrj at...
Definition: Polylib.cpp:929
void zwrk(double *z, double *w, const int npt, const double alpha, const double beta)
Gauss-Radau-Kronrod-Jacobi zeros and weights.
Definition: Polylib.cpp:362
double hglj(const int i, const double z, const double *zglj, const int np, const double alpha, const double beta)
Compute the value of the i th Lagrangian interpolant through the np Gauss-Lobatto-Jacobi points zgrj ...
Definition: Polylib.cpp:964
void Imglj(double *im, const double *zglj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Lobatto-Jacobi points to an arbitrary distrubtion at points zm.
Definition: Polylib.cpp:1085
void jacobd(const int np, const double *z, double *polyd, const int n, const double alpha, const double beta)
Calculate the derivative of Jacobi polynomials.
Definition: Polylib.cpp:1293
void jacobfd(const int np, const double *z, double *poly_in, double *polyd, const int n, const double alpha, const double beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .
Definition: Polylib.cpp:1181
void zwlk(double *z, double *w, const int npt, const double alpha, const double beta)
Gauss-Lobatto-Kronrod-Jacobi zeros and weights.
Definition: Polylib.cpp:468