Skip to content

Commit 46175a7

Browse files
changes in the register_namespace function
1 parent 9a9ab89 commit 46175a7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,43 @@ def register_namespace(self, result_key: str, namespace: str):
635635
This ``result_key`` to ``namespace`` mapping is used by source operators
636636
to find internal operators to call.
637637
638+
639+
When using an operator that requires data from a ``DataSources`` object, DPF must find
640+
a corresponding entry to this call in its code. This entry is given
641+
by the namespace, the file extension, and the operator name: ``namespace::key::operator_name``.
642+
643+
For example, if the results file comes from a MAPDL solver and has an '.rst' extension
644+
and you want to get the displacement results in this file, DPF code will get the
645+
corresponding operator: ``mapdl::rst::displacement``.
646+
647+
So, if you have an extension that is not registered in DPF you have to define its namespace.
648+
This function is mainly used when creating your own operators and plugins, or when you have
649+
a file with an unknown namespace, but you know that it corresponds to a given solver.
650+
651+
Parameters
652+
----------
653+
result_key
654+
Extension of the file, which is used as a key for choosing the correct
655+
plugin when a result is requested by an operator.
656+
namespace
657+
Namespace to associate the file extension to.
658+
638659
Notes
639660
-----
640661
Available with server's version starting at 7.0.
662+
663+
Examples
664+
--------
665+
666+
>>> from ansys.dpf import core as dpf
667+
>>>
668+
>>> # Create the main DataSources object
669+
>>> my_data_sources = dpf.DataSources()
670+
>>> # Define the path where the main result data can be found
671+
>>> my_data_sources.set_result_file_path(filepath=r'file.extension', key='extension')
672+
>>> # Define the namespace for the results in the given path
673+
>>> my_data_sources.register_namespace(result_key='extension', namespace='namespace')
674+
641675
"""
642676
self._api.data_sources_register_namespace(self, result_key, namespace)
643677

0 commit comments

Comments
 (0)