system#

This system contains the type KFormSystem, used to hold the equations described by mfv2d.kform.KEquation.

class mfv2d.system.KFormSystem(*equations: KEquation, sorting: Callable[[KForm], Any] | None = None)[source]#

System of equations of differential forms, which are optionally sorted.

This is a collection of equations, which fully describe a problem to be solved for the degrees of freedom of differential forms.

Parameters:
  • *equations (KFormEquation) – Equations which are to be used.

  • sorting ((KForm) -> Any, optional) – Callable passed to the sorted() builtin to sort the primal forms. This corresponds to sorting the columns of the system matrix.

equations: tuple[KEquation, ...]#
unknown_forms: ElementFormSpecification#

There is also the wrapper around the C type mfv2d._mfv2d.ElementFormSpecification provided by ElementFormSpecification. It provides a nice constructor, as well as wrappers that allow to use types from mfv2d.kform instead of “raw” Python strings and integers. Some utility methods are also provided.

class mfv2d.system.ElementFormSpecification(*forms: KFormUnknown)[source]#

Specifications of element forms on an element.

Parameters:

*specs (tuple of KFormUnknowns) – Specifications for differential forms on the element. Each form must be unique.

__contains__(item: tuple[str, int] | KFormUnknown) bool[source]#

Check if the item is contained in the specifications.

__eq__(other) bool[source]#

Check if the other is identical to itself.

__getitem__(idx: SupportsIndex) tuple[str, UnknownFormOrder][source]#

Get the entry at the specified index.

__iter__() Iterator[tuple[str, UnknownFormOrder]][source]#

Iterate over labels and orders of forms specified.

static __new__(cls, *forms: KFormUnknown) Self[source]#

Create a new form specification.

form_offset(idx: SupportsIndex, /, order_1: int, order_2: int) int#

Get the offset of the form in the element.

Parameters:
  • idx (SupportsIndex) – Index of the form.

  • order_1 (int) – Order of the element in the first dimension.

  • order_2 (int) – Order of the element in the second dimension.

Returns:

Offset of degrees of freedom of the differential form.

Return type:

int

form_offsets(order_1: int, order_2: int) tuple[int, ...]#

Get the offsets of all forms in the element.

Parameters:
  • order_1 (int) – Order of the element in the first dimension.

  • order_2 (int) – Order of the element in the second dimension.

Returns:

Offsets of degrees of freedom for all differential forms, with an extra entry at the end, which is the count of all degrees of freedom.

Return type:

tuple of int

form_size(idx: SupportsIndex, /, order_1: int, order_2: int) int#

Get the number of degrees of freedom of the form in the element.

Parameters:
  • idx (SupportsIndex) – Index of the form.

  • order_1 (int) – Order of the element in the first dimension.

  • order_2 (int) – Order of the element in the second dimension.

Returns:

Number of degrees of freedom of the differential form.

Return type:

int

form_sizes(order_1: int, order_2: int) tuple[int, ...]#

Get the number of degrees of freedom for each form in the element.

Parameters:
  • order_1 (int) – Order of the element in the first dimension.

  • order_2 (int) – Order of the element in the second dimension.

Returns:

Number of degrees of freedom for each differential form.

Return type:

tuple of int

get_form(idx: SupportsIndex, /) KFormUnknown[source]#

Get the entry at the specified index, but converted to a form.

index(value: tuple[str, int] | KFormUnknown) int[source]#

Return the index of the form with the given label and order in the specs.

Parameters:

value (tuple of (str, int) or KFormUnknown) – Label and index of the form, or the form itself.

Returns:

Index of the form in the specification.

Return type:

int

iter_forms() Iterator[KFormUnknown][source]#

Iterate over forms in the specifications.

names#

Returns a tuple of form names.

Type:

tuple[str, …]

orders#

Returns a tuple of form orders.

Type:

tuple[int, …]

total_size(order_1: int, order_2: int) int#

Get the total number of degrees of freedom of the forms.

Parameters:
  • idx (SupportsIndex) – Index of the form.

  • order_1 (int) – Order of the element in the first dimension.

  • order_2 (int) – Order of the element in the second dimension.

Returns:

Total number of degrees of freedom of all differential forms.

Return type:

int