LESARD: Tools¶
The local library LocalLib
contains pythonic hacks that are gathered as simple functions externally accessible.
Page navigation
Simple pythonic hacks¶
-
3_LESARD.LocalLib.ReversedFunctools.
partial
(func, *args)¶ Partial function applying the last arguments
- Parameters
func (function callback) – the function of interest
*args (arguments list) – the arguments to parse to the function from the end.
- Returns
the lambda function defining the partial callback from the last arguments
- Return type
Lmb (function callback)
Tools handling quadrature points (external library)¶
-
3_LESARD.LocalLib.LobattoQuadratureNodes.
GaussLobatto
(n, eps)¶ Computes the Legendre-Gauss-Lobatto nodes, weights and the LGL Vandermonde matrix. The LGL nodes are the zeros of (1-x^2)*P’_N(x). Useful for numerical integration and spectral methods. Initial content from Greg von Winckel - 04/17/2004, Python translation of lglnodes.m, translated and modified into Python by Jacob Schroder - 9/15/2018
- Parameters
n (integer) – requesting an nth-order Gauss-quadrature rule on [-1, 1]
epse (float) – safety net for division
- Returns
representing the quadrature nodes and weights.
- Return type
(nodes, weights) (tuple)
Example
>>> from lglnodes import * >>> (nodes, weights) = lglnodes(3) >>> print(str(nodes) + " " + str(weights)) [-1. -0.4472136 0.4472136 1. ] [0.16666667 0.83333333 0.83333333 0.16666667]
Note
(n+1) nodes and weights are returned
Reference on LGL nodes and weights: C. Canuto, M. Y. Hussaini, A. Quarteroni, T. A. Tang, “Spectral Methods in Fluid Dynamics,” Section 2.3. Springer-Verlag 1987
Tools apparented to Barycentric coordinates¶
-
3_LESARD.LocalLib.BarycentricTools.
GetBarycentricCoordinates
(points, vertices)¶ Barycentric coordinates from the given vertices (forming a triangles)
- Parameters
Points (2D numpy array) – Cartesian coordinates of the points to convert (NbPoints x 2)
vertices (2D numpy array) – Cartesian coordinates of the points taken as reference, ordered. (3 x 2)
- Returns
Barycentric coordinates of points with respect to the vertices (NbPoints x 3)
- Return type
bcoors (2D numpy array)
-
3_LESARD.LocalLib.BarycentricTools.
GetCartesianCoordinates
(bcoords, vertices)¶ Barycentric coordinates from the given vertices (forming a triangles)
- Parameters
bcoors (2D numpy array) – Barycentric coordinates of points with respect to the vertices (NbPoints x 3)
vertices (2D numpy array) – Cartesian coordinates of the points taken as reference, ordered. (3 x 2)
- Returns
Cartesian coordinates of the points to convert (NbPoints x 2)
- Return type
Points (2D numpy array)
Tools apparented to Barycentric basis functions¶
-
3_LESARD.LocalLib.BarycentricBasisFunctions.
BarycentricBasis
(Nele, Type, Order, points)¶ Simple mapping to the implementation giving out the barycentic basis functions according to the elment’s type (simplicial, quad, …)
- Parameters
Nele (integer) – the number of edges of the considered element to compute the basis functions for
Type (string) – type of wished basis functions
Order (integer) – order of the wished basis functions
points (2D numpy array) – the points at which to evaluate the basis functons (NbPoints, 3)
- Returns
- the value of all the basis functions at each given point (NbBasisFunc x NbPoints)
through the call of the relevant function.
- Return type
EvaluatedBase (2D numpy array)
-
3_LESARD.LocalLib.BarycentricBasisFunctions.
BarycentricGradients
(Nele, Type, Order, points, n, vol)¶ Simple mapping to the implementation giving out the barycentic basis functions gradients according to the elment’s type (simplicial, quad, …)
- Parameters
Nele (integer) – the number of edges of the considered element to compute the basis functions for
Type (string) – type of wished basis functions
Order (integer) – order of the wished basis functions
points (2D numpy array) – the points at which to evaluate the basis functons (NbPoints, 3)
n (2D numpy array) – the normal vector to each face, in the order corresponding to the vertices furnishing the barycentric coordinates referential
vol (float) – the volume of the element furnishing the barycentric coordinates referential
- Returns
- the value of all the x and y gradient’s coordinates at each given point, ordered accordingly to the
vertices from which the barycentic coordinates have been generated (NbBasisFunc x NbPoints x 2), through the call of the relevant function.
- Return type
EvaluatedGradient (3D numpy array)