Skip to content

Commit cdefeb4

Browse files
rlaghaakaszynski
andauthored
Rlagha/example 2 (#29)
* harmonic example * cyclic example * multi stage example * patch examples and add math operator Co-authored-by: Alex Kaszynski <[email protected]>
1 parent fbe2b5a commit cdefeb4

File tree

15 files changed

+362
-10
lines changed

15 files changed

+362
-10
lines changed

ansys/dpf/core/core.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ def __init__(self, channel=None, load_operators=True, timeout=5):
4646
self._channel = channel
4747
self._stub = self._connect(timeout)
4848

49+
# these operators are included by default in v211
4950
if load_operators:
5051
self._load_native_operators()
5152
self._load_mapdl_operators()
5253
self._load_mesh_operators()
54+
self._load_math_operators()
5355

5456
def _connect(self, timeout=5):
5557
"""Connect to dpf service within a given timeout"""
@@ -151,3 +153,16 @@ def _load_hdf5(self):
151153
self.load_library('Ans.Dpf.Hdf5.dll', operator_name)
152154
else:
153155
self.load_library('Ans.Dpf.Hdf5D.dll', operator_name)
156+
157+
def _load_math_operators(self):
158+
"""Load math operators"""
159+
operator_name = 'math'
160+
try:
161+
self.load_library('libAns.Dpf.Math.so', operator_name)
162+
except:
163+
pass
164+
165+
if CONFIGURATION == "release":
166+
self.load_library('Ans.Dpf.Math.dll', operator_name)
167+
else:
168+
self.load_library('Ans.Dpf.MathD.dll', operator_name)

ansys/dpf/core/dpf_operator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ def _find_outputs_corresponding_pins(self, type_names, inpt, pin,
255255
corresponding_pins):
256256
input_type_name = type(inpt).__name__
257257
for python_name in type_names:
258+
# appears to be an issue on Linux. This check is here
259+
# because cpp mappings are a single type mapping and
260+
# sometimes the spec contains 'B' instead of 'bool'
261+
if python_name == 'B':
262+
python_name = 'bool'
263+
258264
if python_name == input_type_name:
259265
corresponding_pins.append(pin)
260266
elif input_type_name == "Outputs":

ansys/dpf/core/examples/downloads.py

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def download_all_kinds_of_complexity_modal() -> str:
119119
Download an example result file and return the path of the file
120120
121121
>>> from ansys.dpf.core import examples
122-
>>> path = examples.download_all_kinds_of_complexity_modal
122+
>>> path = examples.download_all_kinds_of_complexity_modal()
123123
>>> path
124124
'C:/Users/user/AppData/local/temp/modal_allKindOfComplexity.rst'
125125
@@ -144,9 +144,58 @@ def download_pontoon() -> str:
144144
Download an example result file and return the path of the file
145145
146146
>>> from ansys.dpf.core import examples
147-
>>> path = examples.download_all_kinds_of_complexity_modal
147+
>>> path = examples.download_pontoon()
148148
>>> path
149-
'C:/Users/user/AppData/local/temp/modal_allKindOfComplexity.rst'
149+
'C:/Users/user/AppData/local/temp/pontoon.rst'
150150
151151
"""
152152
return _download_file('docs', 'pontoon.rst')
153+
154+
155+
def download_multi_harmonic_result() -> str:
156+
"""Download an example multi-harmonic result file and return the
157+
download path.
158+
159+
Examples files are downloaded to a persistent cache to avoid
160+
re-downloading the same file twice.
161+
162+
Returns
163+
-------
164+
str
165+
Path to the example file.
166+
167+
Examples
168+
--------
169+
Download an example result file and return the path of the file
170+
171+
>>> from ansys.dpf.core import examples
172+
>>> path = examples.download_multi_harmonic_result()
173+
>>> path
174+
'C:/Users/user/AppData/local/temp/file_harmonic_5rpms.rst'
175+
"""
176+
return _download_file('harmonic', 'file_harmonic_5rpms.rst')
177+
178+
179+
def download_multi_stage_cyclic_result() -> str:
180+
"""Download an example multi stage result file and return the
181+
download path.
182+
183+
Examples files are downloaded to a persistent cache to avoid
184+
re-downloading the same file twice.
185+
186+
Returns
187+
-------
188+
str
189+
Path to the example file.
190+
191+
Examples
192+
--------
193+
Download an example result file and return the path of the file
194+
195+
>>> from ansys.dpf.core import examples
196+
>>> path = examples.download_multi_stage_cyclic_result()
197+
>>> path
198+
'C:/Users/user/AppData/local/temp/multistage.rst'
199+
200+
"""
201+
return _download_file('multistage', 'multistage.rst')

ansys/dpf/core/examples/examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
steady_therm = os.path.join(_module_path, 'rth', 'rth_steady.rth')
1818
transient_therm = os.path.join(_module_path, 'rth', 'rth_transient.rth')
1919
msup_transient = os.path.join(_module_path, 'msup_transient_plate1.rst')
20+
simple_cyclic = os.path.join(_module_path, 'file_cyclic.rst')
512 KB
Binary file not shown.

ansys/dpf/core/inputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def connect(self, inpt):
4343

4444
corresponding_pins = []
4545

46-
self._operator._find_outputs_corresponding_pins(self._python_expected_types,inpt, self._pin, corresponding_pins)
46+
self._operator._find_outputs_corresponding_pins(self._python_expected_types, inpt, self._pin, corresponding_pins)
4747
if len(corresponding_pins) > 1:
4848
err_str = "Pin connection is ambiguous, specify the pin with:\n"
4949
for pin in corresponding_pins:

ansys/dpf/core/mapping_types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sys
22
import inspect
3-
import re
43

54
## to do : change that one the module is done
65
from ansys.dpf.core.meshed_region import *
@@ -18,7 +17,7 @@
1817

1918
map_types_to_cpp = smart_dict_camel()
2019
for classes in inspect.getmembers(sys.modules[__name__], inspect.isclass):
21-
map_types_to_cpp[classes[0]]=camel_to_snake_case(classes[0])
20+
map_types_to_cpp[classes[0]] = camel_to_snake_case(classes[0])
2221
map_types_to_cpp['str'] = 'string'
2322
map_types_to_cpp['MeshedRegion'] = 'abstract_meshed_region'
2423
map_types_to_cpp['list'] = 'vector<int32>'
@@ -27,12 +26,13 @@
2726
map_types_to_cpp['double'] = 'double'
2827
map_types_to_cpp['float'] = 'double'
2928

29+
3030
class smart_dict_snake(dict):
3131
def __missing__(self, key):
3232
return snake_to_camel_case(key)
33-
map_types_to_python= smart_dict_snake()
33+
map_types_to_python = smart_dict_snake()
3434
for k, v in map_types_to_cpp.items():
35-
map_types_to_python[v]=k
35+
map_types_to_python[v] = k
3636

3737

3838
map_unit_system = smart_dict_unit_system()

docker/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22

33
source IMAGE_NAME
44
docker build -t $IMAGE .
5-
# docker push $IMAGE

docker/push_image.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
source IMAGE_NAME
4+
docker push $IMAGE

docker/run_image.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@
1818

1919
source IMAGE_NAME
2020
docker run -it --rm -v `pwd`/../:/dpf -v /tmp:/dpf/_cache -p 50054:50054 --name dpf $IMAGE
21-

0 commit comments

Comments
 (0)