Skip to content

Commit

Permalink
suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
KulaginVladimir committed Dec 21, 2024
1 parent f639d2a commit 468611d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions festim/exports/txt_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def filename(self, value):
def is_it_time_to_export(self, current_time):
"""
Checks if the exported field should be written to a file or not
based on the current time and the TXTExport.times
based on the current time and the ``TXTExport.times``
Args:
current_time (float): the current simulation time
Expand All @@ -97,40 +97,39 @@ def is_it_time_to_export(self, current_time):
def is_last(self, current_time, final_time):
"""
Checks if the current simulation step equals to the last export time.
based on the final simulation time, TXTExport.times, and the current time
based on the final simulation time, ``TXTExport.times``, and the current time
Args:
current_time (float): the current simulation time.
final_time (float, None): the final simulation time.
Returns:
bool: True if simulation is steady (final_time is None), if TXTExport.times
are not provided and the current time equals to the final time, or if
TXTExport.times are provided and the current time equals to the last time in
TXTExport.times, else False.
bool: True if simulation is steady (final_time is None), if ``TXTExport.times`` are not
provided and the current time equals to the final time, or if
``TXTExport.times`` are provided and the current time equals to the last time in
``TXTExport.times``, else False.
"""

if final_time is None:
# write if steady
return True
elif self.times is None:
if np.isclose(current_time, final_time, atol=0):
# write at final time if exports at each timestep
return True
else:
if np.isclose(current_time, self.times[-1], atol=0):
# write at final time if exports at specific times
# write at the final time if exports at each timestep
return True
elif np.isclose(current_time, self.times[-1], atol=0):
# write at the final time if exports at specific times
return True
return False

def initialise(self, mesh, project_to_DG=False, materials=None):
"""
Initialises TXTExport. Depending on the project_to_DG flag, defines a function space (DG1 or CG1)
Initialises ``TXTExport``. Depending on the ``project_to_DG flag``, defines a function space (DG1 or CG1)
for projection of the exported field. After that, an unsorted array of mesh vertices is created for export.
The array is then used to obtain indices of sorted elements for the data export.
.. note::
If DG1 is used and filter flag is True, the duplicated vertices in the array are filtered except those near interfaces,
If DG1 is used and the ``filter`` flag is True, the duplicated vertices in the array are filtered except those near interfaces.
The interfaces are defined by ``material.borders`` in the ``Materials`` list.
Args:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_exports/test_txt_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_duplicates(
current_time=current_time,
final_time=None,
)
print(my_export._unique_indices)

assert len(my_export.data) == export_len


Expand Down

0 comments on commit 468611d

Please sign in to comment.