Skip to content

Commit 919d943

Browse files
authored
Pull Request: Add a new selection latestTime to the parameter fields_time_instants (#45)
* Add a new selection latestTime to the parameter fields_time_instants
1 parent 7fecfd0 commit 919d943

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

smithers/io/openfoam/openfoamhandler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ def _find_time_instants_subfolders(cls, path, fields_time_instants):
186186
* `'first'`: same of `'all_numeric'`, but return only the folder whose
187187
name is the smallest number of the set;
188188
* `'not_first'`: same of `'all_numeric'`, but exclude the first folder;
189+
* `'latestTime'`: same of `'all_numeric'`, but return only the folder
190+
whose name is the largest number of the set;
189191
* a list of folder names.
190192
:type fields_time_instants: str or list
191193
:returns: A list of tuples (first item: subfolder name, second item:
@@ -209,6 +211,7 @@ def is_numeric(x):
209211
fields_time_instants == "all_numeric"
210212
or fields_time_instants == "first"
211213
or fields_time_instants == "not_first"
214+
or fields_time_instants == "latestTime"
212215
):
213216
subfolders = next(os.walk(path))[1]
214217
subfolders = list(filter(is_numeric, subfolders))
@@ -220,6 +223,8 @@ def is_numeric(x):
220223
time_instant_subfolders = subfolders
221224
elif fields_time_instants == "not_first":
222225
time_instant_subfolders = sorted(subfolders)[1:]
226+
elif fields_time_instants == "latestTime":
227+
time_instant_subfolders = [sorted(subfolders)[-1]]
223228
else:
224229
# we want a list in order to return an iterable object
225230
time_instant_subfolders = [sorted(subfolders)[0]]

0 commit comments

Comments
 (0)