Skip to content

Commit f738317

Browse files
changes in the add_upstream_for_domain function
1 parent 3eb4157 commit f738317

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,20 +472,51 @@ def add_upstream(
472472
self, upstream_data_sources, result_key
473473
)
474474

475-
def add_upstream_for_domain(self, upstream_data_sources, domain_id):
476-
"""Add an upstream data sources for a given domain.
475+
def add_upstream_for_domain(self, upstream_data_sources: DataSources, domain_id: int):
476+
"""Add an upstream data sources to the main DataSources object for a given domain.
477477
478478
This is used to add a set of path creating an upstream for
479479
recursive workflows in a distributed solve.
480480
481481
Parameters
482482
----------
483-
upstream_data_sources : DataSources
483+
upstream_data_sources
484484
Set of paths creating an upstream for recursive workflows.
485485
486-
domain_id: int
486+
domain_id
487487
Domain id for distributed files.
488488
489+
Examples
490+
--------
491+
Add an upstream data to the main DataSources object of an expansion distributed analysis
492+
493+
>>> from ansys.dpf import core as dpf
494+
>>> from ansys.dpf.core import examples
495+
>>>
496+
>>> # Download the result files
497+
>>> paths = examples.find_distributed_msup_folder()
498+
>>> # Create the main DataSources object
499+
>>> my_data_sources = dpf.DataSources()
500+
>>> # Define the path where the main result file can be found and specify its domain
501+
>>> # We use a format string here because the function used to define the path gives the path to a folder
502+
>>> my_data_sources.set_domain_result_file_path(path=rf"{paths}\file_load_1.rfrq", key='rfrq', domain_id=0)
503+
>>> # Add the additional result file to the DataSources object and specify its domain
504+
>>> my_data_sources.add_domain_file_path(filepath=rf"{paths}\file_load_2.rfrq", key='rfrq', domain_id=1)
505+
>>>
506+
>>> # Create the DataSources object for the first and second upstream files
507+
>>> my_data_sources_upstream_g0 = dpf.DataSources()
508+
>>> my_data_sources_upstream_g1 = dpf.DataSources()
509+
>>> # Define the path where the main upstream files can be found
510+
>>> my_data_sources_upstream_g0.set_result_file_path(filepath=rf"{paths}\file0.mode", key='mode')
511+
>>> my_data_sources_upstream_g1.set_result_file_path(filepath=rf"{paths}\file1.mode", key='mode')
512+
>>> # Add the additional upstream files to the upstream DataSources objectS
513+
>>> my_data_sources_upstream_g0.add_file_path(filepath=rf"{paths}\file0.rst", key='rst')
514+
>>> my_data_sources_upstream_g1.add_file_path(filepath=rf"{paths}\file1.rst", key='rst')
515+
>>>
516+
>>> # Add the upstream DataSources to the main DataSources object and specify its domain
517+
>>> my_data_sources.add_upstream_for_domain(upstream_data_sources=my_data_sources_upstream_g0, domain_id=0)
518+
>>> my_data_sources.add_upstream_for_domain(upstream_data_sources=my_data_sources_upstream_g1, domain_id=1)
519+
489520
"""
490521
self._api.data_sources_add_upstream_domain_data_sources(
491522
self, upstream_data_sources, domain_id

0 commit comments

Comments
 (0)