Mathematical Operations

Integral Operations

class underworld3.maths.Integral

Bases: object

The Integral class constructs the volume integral

\[F_{i} = \int_V \, f(\mathbf{x}) \, \mathrm{d} V\]

for some scalar function \(f\) over the mesh domain \(V\).

Parameters:
  • mesh – The mesh over which integration is performed.

  • fn – Function to be integrated.

Example

Calculate volume of mesh:

>>> import underworld3 as uw
>>> import numpy as np
>>> mesh = uw.discretisation.Box()
>>> volumeIntegral = uw.maths.Integral(mesh=mesh, fn=1.)
>>> np.allclose( 1., volumeIntegral.evaluate(), rtol=1e-8)
True
__init__(mesh, fn)
Parameters:
evaluate(verbose=False)

Evaluate the integral and return the result with units (if applicable).

Returns:

The integral value. If the integrand has units AND the mesh coordinates have units, returns a UWQuantity with proper dimensional analysis (integrand_units * volume_units). Otherwise returns a plain float.

Return type:

float or UWQuantity

Vector Calculus

underworld3.maths.delta_function(x, epsilon)

Smoothed (Gaussian) approximation to the Dirac delta function.

Returns a Gaussian with integral 1, approximating \(\delta(x)\) as \(\epsilon \to 0\):

\[\delta_\epsilon(x) = \frac{1}{\epsilon\sqrt{2\pi}} \exp\left(-\frac{x^2}{2\epsilon^2}\right)\]
Parameters:
  • x (sympy.Basic) – Symbolic expression (typically a coordinate or distance function).

  • epsilon (float) – Smoothing width. Smaller values give sharper peaks.

Returns:

Gaussian approximation to the delta function.

Return type:

sympy.Expr

Notes

Useful for representing interfaces, point sources, or boundary layers in a regularized form suitable for finite element integration.