Skip to content

Commit d50139f

Browse files
updates in the DataSources api reference
1 parent a17b2b4 commit d50139f

File tree

1 file changed

+59
-3
lines changed

1 file changed

+59
-3
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ def set_domain_result_file_path(
271271
) -> None:
272272
"""Set a result file path by domain.
273273
274-
This method is used to handle files created by a
275-
distributed solve.
274+
This method is used to handle files created by a distributed solve.
276275
277276
Parameters
278277
----------
@@ -562,10 +561,67 @@ def result_files(self):
562561
"""List of result files contained in the data sources.
563562
564563
Returns
565-
----------
564+
-------
566565
list :
567566
List of result files.
568567
568+
Examples
569+
--------
570+
>>> # If you use the :func:`set_result_file_path() <ansys.dpf.core.data_sources.DataSources.set_result_file_path>`
571+
>>> # function, it will return only the file path given as an argument to this function.
572+
>>>
573+
>>> from ansys.dpf import core as dpf
574+
>>>
575+
>>> # Create the DataSources object
576+
>>> my_data_sources = dpf.DataSources()
577+
>>> # Define the path where the main result file can be found
578+
>>> my_data_sources.set_result_file_path(filepath='/tmp/file.cas', key='cas')
579+
>>> # Add the additional result file to the DataSources object
580+
>>> my_data_sources.add_file_path(filepath='/tmp/ds.dat', key='dat')
581+
>>> # Get the path to the main result file
582+
>>> my_data_sources.result_files
583+
['/tmp/file.cas']
584+
585+
>>> # If you added an upstream result file, it is not listed in the main ``DataSources`` object. You have to
586+
>>> # check directly in the ``DataSources`` object created to define the upstream data.
587+
>>>
588+
>>> from ansys.dpf import core as dpf
589+
>>>
590+
>>> # Create the main DataSources object with a main file path
591+
>>> my_data_sources = dpf.DataSources(result_path='/tmp/file.rfrq')
592+
>>>
593+
>>> # Create the DataSources object for the upstream data
594+
>>> my_data_sources_upstream = dpf.DataSources(result_path='/tmp/file.mode')
595+
>>> # Add the additional upstream data to the upstream DataSources object
596+
>>> my_data_sources_upstream.add_file_path(filepath='/tmp/file.rst', key='rst')
597+
>>>
598+
>>> # Add the upstream DataSources to the main DataSources object
599+
>>> my_data_sources.add_upstream(upstream_data_sources=my_data_sources_upstream)
600+
>>>
601+
>>> # Get the path to the main result file of the main DataSources object
602+
>>> my_data_sources.result_files
603+
['/tmp/file.rfrq']
604+
605+
>>> # If you are checking the DataSources object created to define the upstream data, only the first one is listed.
606+
>>>
607+
>>> # Get the path to the upstream file of the upstream DataSources object
608+
>>> my_data_sources_upstream.result_files
609+
['/tmp/file.mode']
610+
611+
>>> # If you have a ``DataSources`` object with more than one domain, a empty list is returned.
612+
>>>
613+
>>> from ansys.dpf import core as dpf
614+
>>>
615+
>>> # Create the DataSources object
616+
>>> my_data_sources = dpf.DataSources()
617+
>>> # Define the path where the main result data can be found and specify its domain
618+
>>> my_data_sources.set_domain_result_file_path(path='/tmp/file0.rst', key='rst', domain_id=0)
619+
>>> my_data_sources.set_domain_result_file_path(path='/tmp/file1.rst', key='rst', domain_id=1)
620+
>>>
621+
>>> # Get the path to the main result files of the DataSources object
622+
>>> my_data_sources.result_files
623+
[None, None]
624+
569625
"""
570626
result_key = self.result_key
571627
if result_key == "":

0 commit comments

Comments
 (0)