Skip to content

Commit 00193d3

Browse files
docstrings
1 parent d30f07c commit 00193d3

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

src/festim/exports/vtx.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import inspect
12
import warnings
3+
from collections.abc import Callable
24
from pathlib import Path
5+
from typing import Union
36

47
from dolfinx import fem, io
58
import ufl
69

7-
from festim.species import Species
810
from festim.helpers import get_interpolation_points
11+
from festim.species import Species
912
from festim.subdomain.volume_subdomain import VolumeSubdomain
10-
import inspect
1113

1214

1315
class ExportBaseClass:
@@ -178,18 +180,47 @@ def get_functions(self) -> list[fem.Function]:
178180

179181

180182
class CustomField(ExportBaseClass):
183+
"""Export a custom field to a VTX file
184+
185+
Args:
186+
filename: The name of the output file
187+
expression: A function evaluating the custom field. Positional
188+
arguments of the function can be "t" (time), "x" (spatial coordinate),
189+
"T" (temperature), or any key from the `species_dependent_value` dictionary.
190+
species_dependent_value: A dictionary mapping argument names
191+
in `expression` to Species objects. Defaults to None.
192+
times: if provided, the field will be exported at these timesteps. Otherwise
193+
exports at all timesteps. Defaults to None.
194+
subdomain: The volume subdomain on which the custom
195+
field is evaluated. Defaults to None.
196+
checkpoint: If True, the export will be a checkpoint file using
197+
adios4dolfinx and won't be readable by ParaView. Default is False.
198+
199+
Attributes:
200+
filename: The name of the output file
201+
expression: A function evaluating the custom field.
202+
species_dependent_value: A dictionary mapping argument names to Species objects.
203+
subdomain: The volume subdomain on which the custom field is evaluated.
204+
checkpoint: If True, the export will be a checkpoint file.
205+
times: if provided, the field will be exported at these timesteps. Otherwise
206+
exports at all timesteps.
207+
function: the function containing the custom field values
208+
writer: The VTXWriter object used to write the file
209+
dolfinx_expression: the dolfinx expression used to evaluate the function
210+
"""
211+
181212
function: fem.Function
182213
writer: io.VTXWriter
183214
dolfinx_expression: fem.Expression
184215

185216
def __init__(
186217
self,
187-
filename,
188-
expression,
189-
species_dependent_value=None,
190-
times=None,
218+
filename: Union[str, Path],
219+
expression: Callable,
220+
species_dependent_value: Union[dict[str, Species], None] = None,
221+
times: Union[list[float], list[int], None] = None,
191222
subdomain: VolumeSubdomain = None,
192-
checkpoint=False,
223+
checkpoint: bool = False,
193224
):
194225
super().__init__(
195226
filename=filename,

0 commit comments

Comments
 (0)