forge.quadrature

Quadrature rules for averaging over polygons.

Based on the quadrature module from FreeGS (https://github.com/freegs-plasma/freegs), modified for FORGE.

Note: integration weights are set so that the sum of weights is 1, giving the average of a function over the polygon rather than the integral.

Copyright 2019 Ben Dudson, University of York. Email: benjamin.dudson@york.ac.uk Copyright 2025-2026 Chris Marsden

This file is part of FORGE.

FORGE 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.

FORGE 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 FORGE. If not, see <http://www.gnu.org/licenses/>.

forge.quadrature.triangle_quad(triangle, n=6)[source]

Creates quadrature evaluation points.

Given a triangle, calculates the evaluation points and weights. Coefficients taken from http://www.cs.rpi.edu/~flaherje/pdf/fea6.pdf Joseph E. Flaherty course notes, Rensselaer Polytechnic Institute

Parameters:
  • triangle (list) – List of points defining the triangle of the form [(r1,z1), (r2,z2), (r3,z3)].

  • n (int) – Number of quadrature points, currently; 1, 3 or 6.

Returns:

Evaluation points and weights (list) – A list of evaluation points and their weights of the form [(r,z,weight),…]

forge.quadrature.polygon_quad(polygon, n=6)[source]

Calculates quadrature points for an arbitary polygon.

A polygon is provided, which is meshed into a triangular mesh, with the quadrature points and weights for these triangles then calculated.

Parameters:

polygon (shapely.geometry.Polygon object) – A Shapely Polygon to be evaluated.

Returns:

quadrature (list) – A list of evaluation points and their weights of the form [(r,z,weight),…]

forge.quadrature.average(func, quad)[source]

Average func(r,z) using given quadrature.