diff --git a/src/ansys/dpf/core/data_sources.py b/src/ansys/dpf/core/data_sources.py index f434867532..7b8eeec0de 100644 --- a/src/ansys/dpf/core/data_sources.py +++ b/src/ansys/dpf/core/data_sources.py @@ -211,6 +211,36 @@ def add_file_path(self, filepath, key="", is_domain: bool = False, domain_id=0): else: self._api.data_sources_add_file_path_with_key_utf8(self, str(filepath), key) + def add_domain_file_path(self, filepath, key, domain_id): + """Add a file path to the data sources. + + Files not added as result files are accessory files, which contain accessory + information not present in the result files. + + Parameters + ---------- + filepath: + Path of the file. + key: + Extension of the file, which is used as a key for choosing the correct + plugin when a result is requested by an operator. + domain_id: + Domain ID for the distributed files. + Examples + -------- + >>> from ansys.dpf import core as dpf + >>> data_sources = dpf.DataSources() + >>> data_sources.add_domain_file_path('/tmp/ds.dat', "dat", 1) + + """ + # The filename needs to be a fully qualified file name + if not os.path.dirname(filepath): + # append local path + filepath = os.path.join(os.getcwd(), os.path.basename(filepath)) + self._api.data_sources_add_domain_file_path_with_key_utf8( + self, str(filepath), key, domain_id + ) + def add_file_path_for_specified_result(self, filepath, key="", result_key=""): """Add a file path for a specified result file key to the data sources. diff --git a/tests/test_datasources.py b/tests/test_datasources.py index 25852b01db..383601a577 100644 --- a/tests/test_datasources.py +++ b/tests/test_datasources.py @@ -33,6 +33,11 @@ def test_addpath_data_sources(allkindofcomplexity, server_type): data_sources.add_file_path(allkindofcomplexity) +def test_add_domain_file_path_data_sources(allkindofcomplexity, server_type): + data_sources = dpf.core.DataSources(server=server_type) + data_sources.add_domain_file_path(allkindofcomplexity, "rst", 1) + + def test_adddomainpath_data_sources(allkindofcomplexity, server_type): data_sources = dpf.core.DataSources(server=server_type) data_sources.add_file_path(allkindofcomplexity, "rst", is_domain=True, domain_id=1)