Integration#

Many of the higher level functions need to integrate functions or differential forms over a domain. As such numerical integration is one of the cornerstones of this module. For an example of the different integration rules and their relative performance see Integration Rules.

Integration Specifications#

The way the method of integration is specified in \(N\)-dimensional space is by “outer-product” grid, where for each dimension the method (as given by IntegrationMethod) and order of integration is specified using IntegrationSpecs.

class fdg.IntegrationMethod(*values)[source]#

Methods of integration which are supported.

GAUSS = 'gauss'#
GAUSS_LOBATTO = 'gauss-lobatto'#
class fdg.IntegrationSpecs(order: int, /, method: Literal['gauss', 'gauss-lobatto'] = 'gauss')#

Type that describes an integration rule.

Parameters:
  • order (int) – Order of the integration rule.

  • method (Literal["gauss", "gauss-lobatto"], default: "gauss") – Method used for integration.

nodes(registry: IntegrationRegistry = DEFAULT_INTEGRATION_REGISTRY) numpy.typing.NDArray[numpy.double]#

Get the integration nodes.

Parameters:

registry (fdg.IntegrationRegistry, default: DEFAULT_INTEGRATION_REGISTRY) – Registry used to retrieve the integration rule.

Returns:

Array of integration nodes.

Return type:

array

weights(registry: IntegrationRegistry = DEFAULT_INTEGRATION_REGISTRY) numpy.typing.NDArray[numpy.double]#

Get the integration weights.

Parameters:

registry (fdg.IntegrationRegistry, default: DEFAULT_INTEGRATION_REGISTRY) – Registry used to retrieve the integration rule.

Returns:

Array of integration weights.

Return type:

array

accuracy#

Highest order of polynomial that is integrated exactly.

Type:

int

method#

Method used for integration.

Type:

_IntegrationMethodHint

order#

Order of the integration rule.

Type:

int

Since values of integration nodes and weights are ofter reused, they are not stored inside IntegrationSpecs objects. Instead, they are stored in IntegrationRegistry objects. By default, the fdg module provides one already, however any number of new registries can be created.

class fdg.IntegrationRegistry#

Registry for integration rules.

This registry contains all available integration rules and caches them for efficient retrieval.

clear() None#

Clears all stored rules.

usage() tuple[IntegrationSpecs, ...]#

Returns a list of currently stored rules.

fdg.DEFAULT_INTEGRATION_REGISTRY = <fdg._fdg.IntegrationRegistry>#

Registry for integration rules.

This registry contains all available integration rules and caches them for efficient retrieval.

Default IntegrationRegistry used by fdg unless another is provided.

Integration Space#

To define how an integration should be done on a \(N\)-dimensional domain the individual specifications for each dimension (given as IntegrationSpecs) are bundled together into IntegrationSpace.

class fdg.IntegrationSpace(*specs : IntegrationSpecs, /)#

Integration space defined with integration rules.

Integration space defined by tensor product of integration rules in each dimension. Integration rule for each dimension are defined by an IntegrationSpecs object.

Parameters:

*integration_specs (IntegrationSpecs) – Integration specifications for each dimension of the integration space.

nodes(registry: IntegrationRegistry = DEFAULT_INTEGRATION_REGISTRY, /) numpy.typing.NDArray[numpy.double]#

Get the integration nodes of the space.

registryfdg.IntegrationRegistry, default: DEFAULT_INTEGRATION_REGISTRY

Registry used to retrieve the integration rules.

Returns:

Array of integration nodes.

Return type:

array

weights(registry: IntegrationRegistry = DEFAULT_INTEGRATION_REGISTRY, /) numpy.typing.NDArray[numpy.double]#

Get the integration weights of the space.

registryfdg.IntegrationRegistry, default: DEFAULT_INTEGRATION_REGISTRY

Registry used to retrieve the integration rules.

Returns:

Array of integration weights.

Return type:

array

dimension#

Number of dimensions in the integration space.

Type:

int

integration_specs#

Integration specifications that define the integration space.

Type:

tuple[IntegrationSpecs, …]

orders#

Orders of the integration rules.

Type:

tuple[int, …]