Degrees of Freedom#
With a defined function space using FunctionSpace, it is possible to now define a function
using a finite number of degrees of freedom (DoF). To help with that,
the DegreesOfFreedom is provided. A new DegreesOfFreedom
object is created by specifying the FunctionSpace and optionally values of the
corresponding DoFs.
This type can be used to reconstruct the values of the function or its gradients,
thought they are never cached. The only exceptions are the partially cached methods
DegreesOfFreedom.reconstruct_at_integration_points() and
DegreesOfFreedom.reconstruct_derivative_at_integration_points(), which make use
of BasisRegistry and IntegrationRegistry to cache values of basis
functions at integration points.
- class fdg.DegreesOfFreedom(function_space: FunctionSpace, values: numpy.typing.ArrayLike | None = None)#
Degrees of freedom associated with a function space.
- Parameters:
function_space (FunctionSpace) – Function space the degrees of freedom belong to.
values (array_like, optional) – Values of the degrees of freedom. When not specified, they are zero initialized.
- derivative(idim: int) DegreesOfFreedom#
Return degrees of freedom of the derivative along the reference dimension.
- Parameters:
idim (int) – Index of the reference dimension along which the derivative should be taken.
- Returns:
Degrees of freedom of the computed derivative.
- Return type:
- reconstruct_at_integration_points(integration_space: IntegrationSpace, integration_registry: IntegrationRegistry = DEFAULT_INTEGRATION_REGISTRY, basis_registry: BasisRegistry = DEFAULT_BASIS_REGISTRY, *, out: numpy.typing.NDArray[numpy.double] | None = None) numpy.typing.NDArray[numpy.double]#
Reconstruct the function at the integration points of the given space.
- Parameters:
integration_space (IntegrationSpace) – Integration space where the function should be reconstructed.
integration_registry (IntegrationRegistry, default: DEFAULT_INTEGRATION_REGISTRY) – Registry used to retrieve the integration rules.
basis_registry (BasisRegistry, default: DEFAULT_BASIS_REGISTRY) – Registry used to retrieve the basis specifications.
out (array, optional) – Array where the results should be written to. If not given, a new one will be created and returned. It should have the same shape as the integration points.
- Returns:
Array of reconstructed function values at the integration points.
- Return type:
array
- reconstruct_derivative_at_integration_points(integration_space: IntegrationSpace, idim: Sequence[int], integration_registry: IntegrationRegistry = DEFAULT_INTEGRATION_REGISTRY, basis_registry: BasisRegistry = DEFAULT_BASIS_REGISTRY, *, out: numpy.typing.NDArray[numpy.double] | None = None) numpy.typing.NDArray[numpy.double]#
Reconstruct the derivative of the function in given dimension.
- Parameters:
integration_space (IntegrationSpace) – Integration space where the function derivative should be reconstructed.
idim (Sequence[int]) – Dimensions in which the derivative should be computed. All values should appear at most once.
integration_registry (IntegrationRegistry, default: DEFAULT_INTEGRATION_REGISTRY) – Registry used to retrieve the integration rules.
basis_registry (BasisRegistry, default: DEFAULT_BASIS_REGISTRY) – Registry used to retrieve the basis specifications.
out (array, optional) – Array where the results should be written to. If not given, a new one will be created and returned. It should have the same shape as the integration points.
- Returns:
Array of reconstructed function derivative values at the integration points.
- Return type:
array
- function_space#
Function space the degrees of freedom belong to.
- Type:
- values#
Values of the degrees of freedom.
- Type:
numpy.typing.NDArray[numpy.double]
As a minor utility for reconstructing DegreesOfFreedom at arbitrary points
reconstruct() is provided.
- class fdg.reconstruct(dof: DegreesOfFreedom, *x: ndarray[tuple[Any, ...], dtype[float64]])[source]#
Reconstruct function values at given locations.
- Parameters:
*x (array) – Coordinates where the function should be reconstructed. Each array corresponds to a dimension.
- Returns:
Array of reconstructed function values at the specified locations.
- Return type:
array