Skip to content

Commit 77618ba

Browse files
authored
Merge branch 'master' into fix/associate_mesh_to_coordinates_field
2 parents 649143b + a9d68bb commit 77618ba

31 files changed

+1553
-1388
lines changed

doc/source/_static/dpf_operators.html

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

doc/source/getting_started/licensing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ The following Ansys licensing increments provide rights to use the licensed DPF
182182
- ``cfd_solve_level2`` available in the ``Ansys CFD Enterprise`` product
183183
- ``cfd_solve_level3`` available in the ``Ansys CFD Enterprise`` product
184184
- ``fluent_meshing`` available in the ``Ansys CFD Enterprise`` product
185-
- ``avrxp_snd_level1`` available in the ``Ansys Sound Enterprise`` product
185+
- ``avrxp_snd_level1`` available in the ``Ansys Sound Pro`` product
186186
- ``sherlock`` available in the ``Ansys Sherlock`` product
187187

188188
Each increment may be available in other products. On the Ansys Customer Portal,

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

src/ansys/dpf/core/operator_specification.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
The OperatorSpecification Provides a documentation for each Operator
77
"""
88

9+
from __future__ import annotations
910
import abc
11+
from typing import Union
1012
from ansys.dpf.core import server as server_module
1113
from ansys.dpf.gate import (
1214
operator_specification_capi,
@@ -58,7 +60,7 @@ class PinSpecification:
5860
name_derived_class = str
5961

6062
def __init__(
61-
self, name, type_names, document="", optional=False, ellipsis=False, name_derived_class=""
63+
self, name: str, type_names: list, document="", optional=False, ellipsis=False, name_derived_class=""
6264
):
6365
self.name = name
6466
self.type_names = type_names
@@ -68,7 +70,7 @@ def __init__(
6870
self.name_derived_class = name_derived_class
6971

7072
@property
71-
def type_names(self):
73+
def type_names(self) -> list[str]:
7274
"""
7375
Returns
7476
-------
@@ -103,7 +105,7 @@ def type_names(self, val):
103105
self._type_names = val
104106

105107
@staticmethod
106-
def _get_copy(other, changed_types):
108+
def _get_copy(other, changed_types) -> PinSpecification:
107109
return PinSpecification(
108110
other.name,
109111
changed_types,
@@ -170,7 +172,7 @@ class ConfigOptionSpec:
170172
default_value_str: str
171173
document: str
172174

173-
def __init__(self, name, type_names, default_value_str, document):
175+
def __init__(self, name: str, type_names: list, default_value_str: str, document: str):
174176
self.name = name
175177
self.type_names = type_names
176178
self.default_value_str = default_value_str
@@ -189,17 +191,17 @@ def __repr__(self):
189191
class SpecificationBase:
190192
@property
191193
@abc.abstractmethod
192-
def description(self):
194+
def description(self) -> Union[str, None]:
193195
pass
194196

195197
@property
196198
@abc.abstractmethod
197-
def inputs(self):
199+
def inputs(self) -> dict:
198200
pass
199201

200202
@property
201203
@abc.abstractmethod
202-
def outputs(self):
204+
def outputs(self) -> dict:
203205
pass
204206

205207

@@ -231,7 +233,7 @@ class Specification(SpecificationBase):
231233
'result file path container, used if no streams are set'
232234
"""
233235

234-
def __init__(self, operator_name=None, specification=None, server=None):
236+
def __init__(self, operator_name: Union[str, None]=None, specification: Union[Specification, None]=None, server: Union[server_module.BaseServer, None]=None):
235237
# step 1: get server
236238
self._server = server_module.get_or_create_server(server)
237239

@@ -272,9 +274,9 @@ def __str__(self):
272274
return "Description:\n" + str(self.description) + "\nProperties:\n" + str(self.properties)
273275

274276
@property
275-
def properties(self):
276-
"""Returns some additional properties of the Operator, like the category, the exposure,
277-
the scripting and user names and the plugin
277+
def properties(self) -> dict:
278+
"""some additional properties of the Operator, like the category, the exposure,
279+
the scripting and user names, and the plugin
278280
279281
Examples
280282
--------
@@ -498,11 +500,11 @@ class SpecificationProperties:
498500

499501
def __init__(
500502
self,
501-
user_name: str = None,
502-
category: str = None,
503-
scripting_name: str = None,
503+
user_name: Union[str, None] = None,
504+
category: Union[str, None] = None,
505+
scripting_name: Union[str, None] = None,
504506
exposure: Exposures = Exposures.public,
505-
plugin: str = None,
507+
plugin: Union[str, None] = None,
506508
license: str = None,
507509
spec=None,
508510
**kwargs,

src/ansys/dpf/core/operators/math/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
from .qr_solve import qr_solve
6969
from .real_part import real_part
7070
from .relative_error import relative_error
71-
from .sampler import sampler
7271
from .scale import scale
7372
from .scale_by_field import scale_by_field
7473
from .scale_by_field_fc import scale_by_field_fc
@@ -79,8 +78,6 @@
7978
from .sqr_fc import sqr_fc
8079
from .sqrt import sqrt
8180
from .sqrt_fc import sqrt_fc
82-
from .stft import stft
83-
from .stft_fc import stft_fc
8481
from .svd import svd
8582
from .sweeping_phase import sweeping_phase
8683
from .sweeping_phase_fc import sweeping_phase_fc

src/ansys/dpf/core/operators/math/correlation.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313

1414
class correlation(Operator):
1515
"""Takes two fields and a weighting and computes their correlation:
16-
aMb/(||aMa||.||bMb||).
16+
aMb/(||aMa||.||bMb||). If several b fields are provided (via a
17+
fields container), correlation is computed for each of them.
1718
1819
Parameters
1920
----------
2021
fieldA : Field or float
22+
Field a. the reference field.
2123
fieldB : Field or FieldsContainer
22-
ponderation : Field
24+
Field b. if a fields container is provided,
25+
correlation is computed for each
26+
field.
27+
ponderation : Field or FieldsContainer
28+
Field m, optional weighting for correclation
29+
computation.
2330
2431
2532
Examples
@@ -65,41 +72,48 @@ def __init__(
6572
@staticmethod
6673
def _spec():
6774
description = """Takes two fields and a weighting and computes their correlation:
68-
aMb/(||aMa||.||bMb||)."""
75+
aMb/(||aMa||.||bMb||). If several b fields are provided
76+
(via a fields container), correlation is computed for each
77+
of them."""
6978
spec = Specification(
7079
description=description,
7180
map_input_pin_spec={
7281
0: PinSpecification(
7382
name="fieldA",
7483
type_names=["field", "double", "vector<double>"],
7584
optional=False,
76-
document="""""",
85+
document="""Field a. the reference field.""",
7786
),
7887
1: PinSpecification(
7988
name="fieldB",
8089
type_names=["field", "fields_container"],
8190
optional=False,
82-
document="""""",
91+
document="""Field b. if a fields container is provided,
92+
correlation is computed for each
93+
field.""",
8394
),
8495
2: PinSpecification(
8596
name="ponderation",
86-
type_names=["field"],
97+
type_names=["field", "fields_container"],
8798
optional=False,
88-
document="""""",
99+
document="""Field m, optional weighting for correclation
100+
computation.""",
89101
),
90102
},
91103
map_output_pin_spec={
92104
0: PinSpecification(
93105
name="field",
94106
type_names=["field"],
95107
optional=False,
96-
document="""""",
108+
document="""Correlation factor for each input field b.""",
97109
),
98110
1: PinSpecification(
99111
name="index",
100112
type_names=["int32"],
101113
optional=False,
102-
document="""""",
114+
document="""If several b are provided, this output
115+
contains the index of the highest
116+
correlation factor.""",
103117
),
104118
},
105119
)
@@ -171,6 +185,8 @@ def __init__(self, op: Operator):
171185
def fieldA(self):
172186
"""Allows to connect fieldA input to the operator.
173187
188+
Field a. the reference field.
189+
174190
Parameters
175191
----------
176192
my_fieldA : Field or float
@@ -189,6 +205,10 @@ def fieldA(self):
189205
def fieldB(self):
190206
"""Allows to connect fieldB input to the operator.
191207
208+
Field b. if a fields container is provided,
209+
correlation is computed for each
210+
field.
211+
192212
Parameters
193213
----------
194214
my_fieldB : Field or FieldsContainer
@@ -207,9 +227,12 @@ def fieldB(self):
207227
def ponderation(self):
208228
"""Allows to connect ponderation input to the operator.
209229
230+
Field m, optional weighting for correclation
231+
computation.
232+
210233
Parameters
211234
----------
212-
my_ponderation : Field
235+
my_ponderation : Field or FieldsContainer
213236
214237
Examples
215238
--------

0 commit comments

Comments
 (0)