freegsnke.quadrature module
Quadrature rules for averaging over polygons
Note: integration weights set so that sum of weights is 1 and gives the average of a function over the polygon, not the integral.
Copyright 2019 Ben Dudson, University of York. Email: benjamin.dudson@york.ac.uk
This file is part of FreeGSNKE.
FreeGSNKE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FreeGSNKE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with FreeGSNKE. If not, see <http://www.gnu.org/licenses/>.
- freegsnke.quadrature.average(func: Callable[[float, float], float], quad: list[tuple[float, float, float]]) float[source]
Average
func(r, z)using the given quadrature.- Parameters:
func (Callable[[float, float], float]) – Function of R and Z to average.
quad (list[tuple[float, float, float]]) – Quadrature points and weights
[(r, z, weight), ...], e.g. frompolygon_quad.
- Returns:
Weighted sum of
funcover the quadrature points.- Return type:
float
- freegsnke.quadrature.polygon_quad(polygon: list[tuple[float, float]], n: int = 6) list[tuple[float, float, float]][source]
Quadrature points and weights for averaging over a polygon.
The polygon is split into triangles. The weights are normalised to give the average value of a function over the polygon; multiply by the area to get the integral.
- Parameters:
polygon (list[tuple[float, float]]) – Polygon vertices
[(r1, z1), (r2, z2), (r3, z3), ...].n (int, optional) – Number of quadrature points in each triangle; currently 1, 3 or 6.
- Returns:
Evaluation points and weights
[(r, z, weight), ...].- Return type:
list[tuple[float, float, float]]
- freegsnke.quadrature.triangle_quad(triangle: list[tuple[float, float]], n: int = 6) list[tuple[float, float, float]][source]
Quadrature points and weights for averaging over a triangle.
Coefficients taken from http://www.cs.rpi.edu/~flaherje/pdf/fea6.pdf (Joseph E. Flaherty course notes, Rensselaer Polytechnic Institute).
- Parameters:
triangle (list[tuple[float, float]]) – Triangle vertices
[(r1, z1), (r2, z2), (r3, z3)].n (int, optional) – Number of quadrature points; currently 1, 3 or 6.
- Returns:
Evaluation points and weights
[(r, z, weight), ...]; the weights sum to 1.- Return type:
list[tuple[float, float, float]]
- Raises:
ValueError – If
nis not 1, 3 or 6.