Skip to main content

Frugal generation of quadrature for polytopal domain

Project description

polyquad

Frugal generation of quadrature for polytopal domains

Python package associated with this paper.

About

polyquad is a tool that generates quadratures (or cubatures) for non necessarily convex polytopal domains. Important points:

  • the distribution of points is shape independent
  • the number of integration points depends only on the polynomial order of the integrand
  • expensive operations (QR decomposition) are done only once per polynomial order, their results are reused from one shape to the other
  • integration points are defined on a bounding box encapsulating the polytope (and can thus fall outside of the polytope), so the integrand should be defined there as well.

Installation

The package is deployed on pypi, so it can be installed simply using pip

pip install polyquad

Note: this package depends on numba. It seems that, at the moment, it's not compatible with the latest python (3.13). Therefore you may need to revert to an older python for a while.

Usage

For a basic usage you have at your disposal 2 functions:

  • polyquad.get_quadrature_2d
  • polyquad.get_quadrature_3d

These should behave nicely as long as you feed them the right data structures. Let us explain them here

polyquad.get_quadrature_2d

As the name suggests, the function should be used to get quadratures over a 2d polygon. Let us tackle the case of a simple pentagon:

We first need to declare the coordinates of vertices

verts = np.array(((1,-1), (-1,0), (0,3), (2,3), (3,0)))

Then we need to specify the ordering of vertices, which is quite straightforward in that case

face = np.array((0,1,2,3,4))

Then, getting the quadrature for a polynomial order k is as simple as

points, weights = polyquad.get_quadrature_2d(k, verts, face)

polyquad.get_quadrature_3d

This one is for polyhedra. The only difference lies the declaration of faces. For sake of simplicity we here give the example of a simple pyramid (this library is intended to be used with way more complex polyhedra)

Again we first declare the coordinates of vertices

verts = np.array(((0,   0, 0),
                  (1,   0, 0),
                  (1,   1, 0),
                  (0,   1, 0),
                  (.5, .5, 1)))

Then we need to declare each planar face. A planar face is defined by the list of the index of vertices comprising it. For example the square base of the pyramid contains the four first vertices defined above, so it is defined as : [0,1,2,3] This is done for each face and gathered in a list of list as follows:

faces = [[0,1,2,3],
         [0,1,4],
         [1,2,4],
         [2,3,4],
         [3,0,4]]

Note: if the faces of the polyhedron all have the same number of vertices then faces can be casted to a np.array of shape (number of faces, number of vertices per face). This slightly speeds up the computation.

cite this work

If you use this code for you work, you are kindly invited to cite the associated paper

@article{langlois2024,
	title= {Frugal numerical integration scheme for polytopal domains},
	author= {Langlois,C. and van Putten,T. and B\'eriot,H. and Deckers,E.},
	journal= {Engineering with computers},
	doi={https://doi.org/10.1007/s00366-024-02080-1},
	url = {https://link.springer.com/article/10.1007/s00366-024-02080-1}
	}

Feedback and comments can be addressed to corresponding authors of the paper.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polyquad-1.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

polyquad-1.2.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

polyquad-1.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file polyquad-1.2.tar.gz.

File metadata

  • Download URL: polyquad-1.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for polyquad-1.2.tar.gz
Algorithm Hash digest
SHA256 e106b9838eba9d1abf931c78f519fb7db38c5b38703c29b6bd85b62974618ca7
MD5 fc2ee3ca5f6e339ff47c23247b356942
BLAKE2b-256 1b6960bc575e0c48ae4a4065a03ec488cb0b624c6913ec102e49c160555fdb38

See more details on using hashes here.

File details

Details for the file polyquad-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: polyquad-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for polyquad-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2796691f403394c745dcec7b1e47249f3bbcb1a6d01c6cb696d7e8a6a2c5c205
MD5 b6247973a751aa8698a9af5d03065fa9
BLAKE2b-256 841bd42a897c1cd76c44e38f3d3262ace139a4800ac6a7a5c778134011ac6020

See more details on using hashes here.

File details

Details for the file polyquad-1.2-py3-none-any.whl.

File metadata

  • Download URL: polyquad-1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for polyquad-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5884def2fc8563ee8da6b6803233eb1f277d36843a64698592ad5007cf35e513
MD5 48dce77ab9674e0dce0842d2fe45e20b
BLAKE2b-256 57378ac55de30fe9f9b395a18e40e300fa63127af374502cbaa655f41559cedb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page