@@ -447,18 +447,6 @@ def results(self) -> CaseResults:
447
447
"""
448
448
return self ._results
449
449
450
- def download_log (self , log_file , to_file = "." , keep_folder : bool = True ):
451
- """
452
- Download log
453
- :param log_file:
454
- :param to_file: file name on local disk, could be either folder or file name.
455
- :param keep_folder: If true, the downloaded file will be put in the same folder as the file on cloud. Only work
456
- when file_name is a folder name.
457
- :return:
458
- """
459
-
460
- self .download_file (f"logs/{ log_file .value } " , to_file , keep_folder )
461
-
462
450
def is_steady (self ):
463
451
"""
464
452
returns True when case is steady state
@@ -770,30 +758,52 @@ def plot(self):
770
758
"""
771
759
return self ._plotter
772
760
773
- def download_file (self , downloadable : CaseDownloadable , overwrite : bool = True , ** kwargs ):
774
- """
775
- download specific file by filename
776
- :param downloadable: filename to download
777
- :param overwrite: when True, overwrites existing file, otherwise skip
761
+ # pylint: disable=protected-access
762
+ def _download_file (
763
+ self ,
764
+ downloadable : CaseDownloadable ,
765
+ to_file = "." ,
766
+ to_folder = "." ,
767
+ overwrite : bool = True ,
768
+ ** kwargs ,
769
+ ):
778
770
"""
779
- return self ._case .download_file (
780
- f"results/{ downloadable .value } " , overwrite = overwrite , ** kwargs
781
- )
771
+ Download a specific file associated with the case.
782
772
783
- def download_volumetric (self ):
784
- """
785
- download volumetric results data
786
- """
787
- self .download_file (CaseDownloadable .VOLUME )
773
+ Parameters
774
+ ----------
775
+ downloadable : flow360.CaseDownloadable
776
+ The type of file to be downloaded (e.g., surface, volume, forces, etc.).
788
777
789
- def download_surface (self ):
790
- """
791
- download surface results data
778
+ to_file : str, optional
779
+ File path to save the downloaded file. If None, the file will be saved in the current directory.
780
+ If provided without an extension, the extension will be automatically added based on the file type.
781
+
782
+ to_folder : str, optional
783
+ Folder name to save the downloaded file. If None, the file will be saved in the current directory.
784
+
785
+ overwrite : bool, optional
786
+ If True, overwrite existing files with the same name in the destination.
787
+
788
+ **kwargs : dict, optional
789
+ Additional arguments to be passed to the download process.
790
+
791
+ Returns
792
+ -------
793
+ str
794
+ File path of the downloaded file.
792
795
"""
793
- self .download_file (CaseDownloadable .SURFACE )
796
+
797
+ return self ._case ._download_file (
798
+ f"results/{ downloadable .value } " ,
799
+ to_file = to_file ,
800
+ to_folder = to_folder ,
801
+ overwrite = overwrite ,
802
+ ** kwargs ,
803
+ )
794
804
795
805
# pylint: disable=redefined-builtin,too-many-locals,too-many-arguments
796
- def download_manager (
806
+ def download (
797
807
self ,
798
808
surface : bool = False ,
799
809
volume : bool = False ,
@@ -807,42 +817,44 @@ def download_manager(
807
817
actuator_disk_output : bool = False ,
808
818
all : bool = False ,
809
819
overwrite : bool = False ,
820
+ destination : str = "." ,
810
821
):
811
- """download manager for downloading many files at once
822
+ """
823
+ Download result files associated with the case.
812
824
813
825
Parameters
814
826
----------
815
827
surface : bool, optional
816
- _description_, by default False
828
+ Download surface result file if True.
817
829
volume : bool, optional
818
- _description_, by default False
830
+ Download volume result file if True.
819
831
nonlinear_residuals : bool, optional
820
- _description_, by default False
832
+ Download nonlinear residuals file if True.
821
833
linear_residuals : bool, optional
822
- _description_, by default False
834
+ Download linear residuals file if True.
823
835
cfl : bool, optional
824
- _description_, by default False
836
+ Download CFL file if True.
825
837
minmax_state : bool, optional
826
- _description_, by default False
838
+ Download minmax state file if True.
827
839
surface_forces : bool, optional
828
- _description_, by default False
840
+ Download surface forces file if True.
829
841
total_forces : bool, optional
830
- _description_, by default False
842
+ Download total forces file if True.
831
843
bet_forces : bool, optional
832
- _description_, by default False
844
+ Download BET (Blade Element Theory) forces file if True.
833
845
actuator_disk_output : bool, optional
834
- _description_, by default False
846
+ Download actuator disk output file if True.
835
847
all : bool, optional
836
- _description_, by default False
848
+ Download all result files if True (ignores other parameters).
837
849
overwrite : bool, optional
838
- _description_, by default False
850
+ If True, overwrite existing files with the same name in the destination.
851
+ destination : str, optional
852
+ Location to save downloaded files. If None, files will be saved in the current directory under ID folder.
839
853
840
- Raises
841
- ------
842
- e
843
- _description_
844
- e
845
- _description_
854
+ Returns
855
+ -------
856
+ List of str
857
+ File paths of the downloaded files.
846
858
"""
847
859
848
860
download_map = [
@@ -855,15 +867,22 @@ def download_manager(
855
867
(surface_forces , CaseDownloadable .SURFACE_FORCES ),
856
868
(total_forces , CaseDownloadable .TOTAL_FORCES ),
857
869
]
858
-
870
+ downloaded_files = []
859
871
for do_download , filename in download_map :
860
872
if do_download or all :
861
- self .download_file (filename , overwrite = overwrite )
873
+ downloaded_files .append (
874
+ self ._download_file (filename , to_folder = destination , overwrite = overwrite )
875
+ )
862
876
863
877
if bet_forces or all :
864
878
try :
865
- self .download_file (
866
- CaseDownloadable .BET_FORCES , overwrite = overwrite , log_error = False
879
+ downloaded_files .append (
880
+ self ._download_file (
881
+ CaseDownloadable .BET_FORCES ,
882
+ to_folder = destination ,
883
+ overwrite = overwrite ,
884
+ log_error = False ,
885
+ )
867
886
)
868
887
except CloudFileNotFoundError as err :
869
888
if not self ._case .has_bet_disks ():
@@ -877,8 +896,13 @@ def download_manager(
877
896
878
897
if actuator_disk_output or all :
879
898
try :
880
- self .download_file (
881
- CaseDownloadable .ACTUATOR_DISK_OUTPUT , overwrite = overwrite , log_error = False
899
+ downloaded_files .append (
900
+ self ._download_file (
901
+ CaseDownloadable .ACTUATOR_DISK_OUTPUT ,
902
+ to_folder = destination ,
903
+ overwrite = overwrite ,
904
+ log_error = False ,
905
+ )
882
906
)
883
907
except CloudFileNotFoundError as err :
884
908
if not self ._case .has_actuator_disks ():
@@ -893,6 +917,8 @@ def download_manager(
893
917
)
894
918
raise err
895
919
920
+ return downloaded_files
921
+
896
922
897
923
class CaseList (Flow360ResourceListBase ):
898
924
"""
0 commit comments