Skip to content

Commit e4675cc

Browse files
authored
Add DataSources.add_domain_file_path (#1475)
* Add DataSources.add_domain_file_path Signed-off-by: paul.profizi <[email protected]> * Add test_add_domain_file_path_data_sources Signed-off-by: paul.profizi <[email protected]> --------- Signed-off-by: paul.profizi <[email protected]>
1 parent 6a803b5 commit e4675cc

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,36 @@ def add_file_path(self, filepath, key="", is_domain: bool = False, domain_id=0):
211211
else:
212212
self._api.data_sources_add_file_path_with_key_utf8(self, str(filepath), key)
213213

214+
def add_domain_file_path(self, filepath, key, domain_id):
215+
"""Add a file path to the data sources.
216+
217+
Files not added as result files are accessory files, which contain accessory
218+
information not present in the result files.
219+
220+
Parameters
221+
----------
222+
filepath:
223+
Path of the file.
224+
key:
225+
Extension of the file, which is used as a key for choosing the correct
226+
plugin when a result is requested by an operator.
227+
domain_id:
228+
Domain ID for the distributed files.
229+
Examples
230+
--------
231+
>>> from ansys.dpf import core as dpf
232+
>>> data_sources = dpf.DataSources()
233+
>>> data_sources.add_domain_file_path('/tmp/ds.dat', "dat", 1)
234+
235+
"""
236+
# The filename needs to be a fully qualified file name
237+
if not os.path.dirname(filepath):
238+
# append local path
239+
filepath = os.path.join(os.getcwd(), os.path.basename(filepath))
240+
self._api.data_sources_add_domain_file_path_with_key_utf8(
241+
self, str(filepath), key, domain_id
242+
)
243+
214244
def add_file_path_for_specified_result(self, filepath, key="", result_key=""):
215245
"""Add a file path for a specified result file key to the data sources.
216246

tests/test_datasources.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def test_addpath_data_sources(allkindofcomplexity, server_type):
3333
data_sources.add_file_path(allkindofcomplexity)
3434

3535

36+
def test_add_domain_file_path_data_sources(allkindofcomplexity, server_type):
37+
data_sources = dpf.core.DataSources(server=server_type)
38+
data_sources.add_domain_file_path(allkindofcomplexity, "rst", 1)
39+
40+
3641
def test_adddomainpath_data_sources(allkindofcomplexity, server_type):
3742
data_sources = dpf.core.DataSources(server=server_type)
3843
data_sources.add_file_path(allkindofcomplexity, "rst", is_domain=True, domain_id=1)

0 commit comments

Comments
 (0)