Skip to content

Commit be1231e

Browse files
authored
Documentation (#200)
* document finite_element.py * document functionals.py * document geometry.py * doucment mappings.py * Document moments.py * document plotting.py * document elements/tnt.py * document elements/q * document elements/kmv * document element/guzman_neilan * document elements/dual * document functions * document polynomials * document polynomials.py * .
1 parent b3054c3 commit be1231e

File tree

14 files changed

+2329
-365
lines changed

14 files changed

+2329
-365
lines changed

symfem/elements/dual.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,32 @@ def __init__(
5353
def get_polynomial_basis(
5454
self, reshape: bool = True
5555
) -> typing.List[AnyFunction]:
56-
"""Get the symbolic polynomial basis for the element."""
56+
"""Get the symbolic polynomial basis for the element.
57+
58+
Returns:
59+
The polynomial basis
60+
"""
5761
raise ValueError("Polynomial basis not supported for barycentric dual elements.")
5862

5963
def get_dual_matrix(self) -> sympy.matrices.dense.MutableDenseMatrix:
60-
"""Get the dual matrix."""
64+
"""Get the dual matrix.
65+
66+
Returns:
67+
The dual matrix
68+
"""
6169
raise ValueError("Dual matrix not supported for barycentric dual elements.")
6270

6371
def get_basis_functions(
6472
self, use_tensor_factorisation: bool = False
6573
) -> typing.List[AnyFunction]:
66-
"""Get the basis functions of the element."""
74+
"""Get the basis functions of the element.
75+
76+
Args:
77+
use_tensor_factorisation: Should a tensor factorisation be used?
78+
79+
Returns:
80+
The basis functions
81+
"""
6782
assert not use_tensor_factorisation
6883

6984
if self._basis_functions is None:
@@ -102,7 +117,15 @@ def get_basis_functions(
102117
return self._basis_functions
103118

104119
def entity_dofs(self, entity_dim: int, entity_number: int) -> typing.List[int]:
105-
"""Get the numbers of the DOFs associated with the given entity."""
120+
"""Get the numbers of the DOFs associated with the given entity.
121+
122+
Args:
123+
entity_dim: The dimension of the entity
124+
entity_number: The number of the entity
125+
126+
Returns:
127+
The numbers of the DOFs associated with the entity
128+
"""
106129
out = []
107130
for i, e in enumerate(self.dof_entities):
108131
if e == (entity_dim, entity_number):
@@ -115,14 +138,30 @@ def map_to_cell(
115138
forward_map: typing.Optional[PointType] = None,
116139
inverse_map: typing.Optional[PointType] = None
117140
) -> typing.List[AnyFunction]:
118-
"""Map the basis onto a cell using the appropriate mapping for the element."""
141+
"""Map the basis onto a cell using the appropriate mapping for the element.
142+
143+
Args:
144+
vertices_in: The vertices of the cell
145+
basis: The basis functions
146+
forward_map: The map from the reference to the cell
147+
inverse_map: The map to the reference from the cell
148+
149+
Returns:
150+
The basis functions mapped to the cell
151+
"""
119152
raise NotImplementedError()
120153

121154
def plot_dof_diagram(
122155
self, filename: typing.Union[str, typing.List[str]],
123156
plot_options: typing.Dict[str, typing.Any] = {}, **kwargs: typing.Any
124157
):
125-
"""Plot a diagram showing the DOFs of the element."""
158+
"""Plot a diagram showing the DOFs of the element.
159+
160+
Args:
161+
filename: The file name
162+
plot_options: Options for the plot
163+
kwargs: Keyword arguments
164+
"""
126165
img = Picture(**kwargs)
127166

128167
for entities in self.reference.z_ordered_entities():

symfem/elements/guzman_neilan.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ def __init__(self, reference: Reference, order: int):
8787
def _make_polyset_triangle(
8888
self, reference: Reference, order: int
8989
) -> typing.List[FunctionInput]:
90-
"""Make the polyset for a triangle."""
90+
"""Make the polyset for a triangle.
91+
92+
Args:
93+
reference: The reference cell
94+
order: The polynomial order
95+
96+
Returns:
97+
The polynomial set
98+
"""
9199
assert order == 1
92100

93101
from ._guzman_neilan_triangle import coeffs
@@ -123,7 +131,15 @@ def _make_polyset_triangle(
123131
def _make_polyset_tetrahedron(
124132
self, reference: Reference, order: int
125133
) -> typing.List[FunctionInput]:
126-
"""Make the polyset for a tetrahedron."""
134+
"""Make the polyset for a tetrahedron.
135+
136+
Args:
137+
reference: The reference cell
138+
order: The polynomial order
139+
140+
Returns:
141+
The polynomial set
142+
"""
127143
assert order in [1, 2]
128144
from ._guzman_neilan_tetrahedron import coeffs
129145

@@ -167,7 +183,18 @@ def make_piecewise_lagrange(
167183
sub_cells: typing.List[SetOfPoints], cell_name, order: int, zero_on_boundary: bool = False,
168184
zero_at_centre: bool = False
169185
) -> typing.List[PiecewiseFunction]:
170-
"""Make the basis functions of a piecewise Lagrange space."""
186+
"""Make the basis functions of a piecewise Lagrange space.
187+
188+
Args:
189+
sub_cells: A list of vertices of sub cells
190+
cell_name: The cell type of the sub cells
191+
order: The polynomial order
192+
zero_in_boundary: Should the functions be zero on the boundary?
193+
zero_at_centre: Should the functions be zero at the centre?
194+
195+
Returns:
196+
The basis functions
197+
"""
171198
from symfem import create_reference
172199
lagrange_space = VectorLagrange(create_reference(cell_name), order)
173200
lagrange_bases: typing.List[typing.List[VectorFunction]] = []

symfem/elements/kmv.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717

1818

1919
def kmv_tri_polyset(m: int, mf: int) -> typing.List[FunctionInput]:
20-
"""Create the polynomial set for a KMV space on a triangle."""
20+
"""Create the polynomial set for a KMV space on a triangle.
21+
22+
Args:
23+
m: The parameter m
24+
mf: The parameter mf
25+
26+
Returns:
27+
The polynomial set
28+
"""
2129
poly: typing.List[FunctionInput] = []
2230
poly += polynomial_set_1d(2, m)
2331

@@ -29,7 +37,16 @@ def kmv_tri_polyset(m: int, mf: int) -> typing.List[FunctionInput]:
2937

3038

3139
def kmv_tet_polyset(m: int, mf: int, mi: int) -> typing.List[FunctionInput]:
32-
"""Create the polynomial set for a KMV space on a tetrahedron."""
40+
"""Create the polynomial set for a KMV space on a tetrahedron.
41+
42+
Args:
43+
m: The parameter m
44+
mf: The parameter mf
45+
mi: The parameter mi
46+
47+
Returns:
48+
The polynomial set
49+
"""
3350
poly: typing.List[FunctionInput] = []
3451
poly += polynomial_set_1d(3, m)
3552

symfem/elements/q.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def __init__(self, reference: Reference, order: int, variant: str = "equispaced"
5757
def get_tensor_factorisation(
5858
self
5959
) -> typing.List[typing.Tuple[str, typing.List[FiniteElement], typing.List[int]]]:
60-
"""Get the representation of the element as a tensor product."""
60+
"""Get the representation of the element as a tensor product.
61+
62+
Returns:
63+
The tensor factorisation
64+
"""
6165
from symfem import create_element
6266
interval_q = create_element("interval", "Lagrange", self.order)
6367

symfem/elements/tnt.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@
2121

2222

2323
def p(k: int, v: sympy.core.symbol.Symbol) -> ScalarFunction:
24-
"""Return the kth Legendre polynomial."""
24+
"""Return the kth Legendre polynomial.
25+
26+
Args:
27+
k: k
28+
v: The variable to use
29+
30+
Returns:
31+
The kth Legendre polynomial
32+
"""
2533
return orthogonal_basis("interval", k, 0, [v])[0][-1]
2634

2735

@@ -30,6 +38,13 @@ def b(k: int, v: sympy.core.symbol.Symbol) -> ScalarFunction:
3038
3139
This function is defined on page 4 (606) of
3240
https://doi.org/10.1090/S0025-5718-2013-02729-9 (Cockburn, Qiu, 2013).
41+
42+
Args:
43+
k: k
44+
v: The variable to use
45+
46+
Returns:
47+
The function B_k
3348
"""
3449
if k == 1:
3550
return ScalarFunction(0)

0 commit comments

Comments
 (0)