Skip to content

Commit 9a10aef

Browse files
resolved conflicts for 22.2 release
2 parents e1de60f + c0dd388 commit 9a10aef

File tree

543 files changed

+14467
-4107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

543 files changed

+14467
-4107
lines changed

ansys/dpf/__init__.py

Whitespace-only changes.

ansys/dpf/core/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131
)
3232
from ansys.dpf.core.data_sources import DataSources
3333
from ansys.dpf.core.scoping import Scoping
34-
from ansys.dpf.core.common import types, natures, locations, shell_layers
34+
from ansys.dpf.core.common import (
35+
types,
36+
natures,
37+
locations,
38+
shell_layers,
39+
config_options
40+
)
3541
from ansys.dpf.core import help
3642
from ansys.dpf.core.core import (
3743
BaseService,
@@ -42,6 +48,7 @@
4248
upload_files_in_folder,
4349
download_files_in_folder,
4450
make_tmp_dir_server,
51+
get_runtime_client_config,
4552
)
4653
from ansys.dpf.core.time_freq_support import TimeFreqSupport
4754
from ansys.dpf.core.meshed_region import MeshedRegion
@@ -73,9 +80,10 @@
7380
USER_DATA_PATH = None
7481
LOCAL_DOWNLOADED_EXAMPLES_PATH = None
7582
try:
76-
import appdirs
83+
import pkgutil
7784

78-
USER_DATA_PATH = appdirs.user_data_dir("ansys-dpf-core")
85+
spec = pkgutil.get_loader("ansys.dpf.core")
86+
USER_DATA_PATH = os.path.dirname(spec.get_filename())
7987
if not os.path.exists(USER_DATA_PATH): # pragma: no cover
8088
os.makedirs(USER_DATA_PATH)
8189

@@ -90,4 +98,5 @@
9098

9199
_server_instances = []
92100

93-
settings.set_default_pyvista_config()
101+
settings.set_default_pyvista_config()
102+
settings._forward_to_gate()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from ansys.dpf.gate import capi, external_operator_capi, dpf_vector
2+
from enum import Enum
3+
from ansys.dpf.core import (
4+
field, property_field, scoping, collection, data_sources, meshed_region, time_freq_support, \
5+
workflow, data_tree, dpf_operator, fields_container, scopings_container, \
6+
meshes_container, result_info
7+
)
8+
9+
external_operator_api = external_operator_capi.ExternalOperatorCAPI
10+
11+
functions_registry = []
12+
@capi.OperatorCallBack
13+
def __operator_main__(operator_functor, data):
14+
capi.OperatorMainCallback(operator_functor)(data)
15+
16+
17+
_type_to_output_method = [
18+
(bool, external_operator_api.external_operator_put_out_bool), # always before int
19+
((int, Enum), external_operator_api.external_operator_put_out_int),
20+
(str, external_operator_api.external_operator_put_out_string),
21+
(float, external_operator_api.external_operator_put_out_double),
22+
(field.Field, external_operator_api.external_operator_put_out_field),
23+
(property_field.PropertyField, external_operator_api.external_operator_put_out_property_field),
24+
(scoping.Scoping, external_operator_api.external_operator_put_out_scoping),
25+
(collection.Collection, external_operator_api.external_operator_put_out_collection),
26+
(data_sources.DataSources, external_operator_api.external_operator_put_out_data_sources),
27+
(meshed_region.MeshedRegion, external_operator_api.external_operator_put_out_meshed_region),
28+
(result_info.ResultInfo, external_operator_api.external_operator_put_out_result_info),
29+
(time_freq_support.TimeFreqSupport, external_operator_api.external_operator_put_out_time_freq),
30+
# TO DO : (cyclic_support.CyclicSupport, external_operator_api.external_operator_put_out_cy),
31+
(workflow.Workflow, external_operator_api.external_operator_put_out_workflow),
32+
(data_tree.DataTree, external_operator_api.external_operator_put_out_data_tree),
33+
(dpf_operator.Operator, external_operator_api.external_operator_put_out_operator),
34+
]
35+
36+
_type_to_input_method = [
37+
(bool, external_operator_api.external_operator_get_in_bool),
38+
(int, external_operator_api.external_operator_get_in_int),
39+
(str, external_operator_api.external_operator_get_in_string),
40+
(float, external_operator_api.external_operator_get_in_double),
41+
(field.Field, external_operator_api.external_operator_get_in_field, "field"),
42+
(property_field.PropertyField, external_operator_api.external_operator_get_in_property_field, "property_field"),
43+
(scoping.Scoping, external_operator_api.external_operator_get_in_scoping, "scoping"),
44+
(fields_container.FieldsContainer, external_operator_api.external_operator_get_in_fields_container, "fields_container"),
45+
(scopings_container.ScopingsContainer, external_operator_api.external_operator_get_in_scopings_container, "scopings_container"),
46+
(meshes_container.MeshesContainer, external_operator_api.external_operator_get_in_meshes_container, "meshes_container"),
47+
(data_sources.DataSources, external_operator_api.external_operator_get_in_data_sources, "data_sources"),
48+
(meshed_region.MeshedRegion, external_operator_api.external_operator_get_in_meshed_region, "mesh"),
49+
# TO DO : (result_info.ResultInfo, external_operator_api.external_operator_get_in_re),
50+
(time_freq_support.TimeFreqSupport, external_operator_api.external_operator_get_in_time_freq, "time_freq_support"),
51+
# TO DO : (cyclic_support.CyclicSupport, external_operator_api.external_operator_get_in_cy),
52+
(workflow.Workflow, external_operator_api.external_operator_get_in_workflow, "workflow"),
53+
(data_tree.DataTree, external_operator_api.external_operator_get_in_data_tree, "data_tree"),
54+
# TO DO : (dpf_operator.Operator, external_operator_api.external_operator_get_in_operator, "operator"),
55+
]

ansys/dpf/core/available_result.py

Lines changed: 111 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,71 @@
44
"""
55

66
from warnings import warn
7-
from ansys.grpc.dpf import available_result_pb2, base_pb2
8-
from ansys.dpf.core.common import _remove_spaces, _make_as_function_name
7+
from ansys.dpf.core.common import _remove_spaces, _make_as_function_name, natures
8+
from enum import Enum, unique
9+
10+
11+
@unique
12+
class Homogeneity(Enum):
13+
acceleration = 0
14+
angle = 1
15+
angular_velocity = 2
16+
surface = 3
17+
capacitance = 4
18+
electric_charge = 5
19+
electric_charge_density = 6
20+
conductivity = 7
21+
current = 9
22+
density = 10
23+
displacement = 11
24+
electric_conductivity = 12
25+
electric_field = 13
26+
electric_flux_density = 14
27+
electric_resistivity = 15
28+
energy = 16
29+
film_coefficient = 17
30+
force = 18
31+
force_intensity = 19
32+
frequency = 20
33+
heat_flux = 21
34+
heat_generation = 22
35+
heat_rate = 23
36+
inductance = 24
37+
inverse_stress = 25
38+
length = 26
39+
magnetic_field_intensity = 27
40+
magnetic_flux = 28
41+
magnetic_flux_density = 29
42+
mass = 30
43+
moment = 31
44+
moment_intertia = 32 # TODO typo
45+
permeability = 33
46+
permittivity = 34
47+
poisson = 35
48+
power = 36
49+
pressure = 37
50+
relative_permeability = 38
51+
relative_permittivity = 39
52+
section_modulus = 40
53+
specific_heat = 41
54+
specific_weight = 42
55+
shear_strain = 43
56+
stiffness = 44
57+
strain = 45
58+
stress = 46
59+
strength = 47
60+
thermal_expansion = 48
61+
temperature = 49
62+
time = 50
63+
velocity = 51
64+
voltage = 52
65+
volume = 53
66+
moment_inertia_mass = 55
67+
stress_intensity_factor = 92
68+
thermal_gradient = 95
69+
resistance = 1000
70+
unknown = 111
71+
dimensionless = 117
972

1073

1174
class AvailableResult:
@@ -40,7 +103,15 @@ class AvailableResult:
40103

41104
def __init__(self, availableresult):
42105
"""Initialize the AvailableResult with an availableResult message."""
43-
self._message = availableresult
106+
self._name = availableresult.name
107+
self._physics_name = availableresult.physicsname
108+
self._dimensionality = availableresult.dimensionality
109+
self._homogeneity = availableresult.homogeneity
110+
self._unit = availableresult.unit
111+
self._n_comp = availableresult.ncomp
112+
self._properties = {"scripting_name": availableresult.properties["scripting_name"],
113+
"location": availableresult.properties["loc_name"]}
114+
self._sub_res = availableresult.sub_res
44115

45116
def __str__(self):
46117
txt = (
@@ -58,75 +129,74 @@ def __str__(self):
58129
@property
59130
def name(self):
60131
"""Result operator."""
61-
if hasattr(self._message, "properties") and "scripting_name" in self._message.properties:
62-
name = self._message.properties["scripting_name"]
132+
if hasattr(self, "properties") and "scripting_name" in self._properties.keys():
133+
name = self.properties["scripting_name"]
63134
elif self.operator_name in _result_properties:
64135
name = _result_properties[self.operator_name]["scripting_name"]
65136
else:
66-
name = _remove_spaces(self._message.physicsname)
137+
name = _remove_spaces(self._physics_name)
67138
return _make_as_function_name(name)
68139

69140
@property
70141
def n_components(self):
71142
"""Number of components of the result."""
72-
return self._message.ncomp
143+
return self._n_comp
73144

74145
@property
75146
def dimensionality(self):
76147
"""Dimensionality nature of the result, such as a vector, scalar, or tensor."""
77-
return base_pb2.Nature.Name(self._message.dimensionality).lower()
148+
return natures(self._dimensionality).name
78149

79150
@property
80151
def homogeneity(self):
81152
"""Homogeneity of the result."""
82153
try:
83-
homogeneity = self._message.homogeneity
84-
if homogeneity == 117:
85-
return available_result_pb2.Homogeneity.Name(
86-
available_result_pb2.Homogeneity.DIMENSIONLESS
87-
).lower()
88-
return available_result_pb2.Homogeneity.Name(homogeneity).lower()
154+
# homogeneity = self._homogeneity
155+
# if homogeneity == 117:
156+
# return Homogeneity(Homogeneity.DIMENSIONLESS).name
157+
return Homogeneity(self._homogeneity).name
89158
except ValueError as exception:
90159
warn(str(exception))
91160
return ""
92161

93162
@property
94163
def unit(self):
95164
"""Unit of the result."""
96-
return self._message.unit.lower()
165+
return self._unit.lower()
97166

98167
@property
99168
def operator_name(self):
100169
"""Name of the corresponding operator."""
101-
return self._message.name
170+
return self._name
102171

103172
@property
104173
def sub_results(self):
105174
"""List of the subresult."""
106-
rep_sub_res = self._message.sub_res
107-
list = []
108-
for sub_res in rep_sub_res:
175+
rep_sub_res = self._sub_res
176+
list_of_rep = []
177+
for sub_res_name in rep_sub_res.keys():
178+
sub_res = rep_sub_res[sub_res_name]
109179
try:
110-
int(sub_res.name)
111-
dict = {
112-
"name": "principal" + sub_res.name,
113-
"operator name": sub_res.op_name,
114-
"description": sub_res.description,
180+
int(sub_res_name)
181+
rep_sub = {
182+
"name": "principal" + sub_res_name,
183+
"operator name": sub_res[0],
184+
"description": sub_res[1],
115185
}
116186
except:
117-
dict = {
118-
"name": sub_res.name,
119-
"operator name": sub_res.op_name,
120-
"description": sub_res.description,
187+
rep_sub = {
188+
"name": sub_res_name,
189+
"operator name": sub_res[0],
190+
"description": sub_res[1],
121191
}
122-
list.append(dict)
123-
return list
192+
list_of_rep.append(rep_sub)
193+
return list_of_rep
124194

125195
@property
126196
def native_location(self):
127197
"""Native location of the result."""
128-
if hasattr(self._message, "properties") and "location" in self._message.properties:
129-
return self._message.properties["location"]
198+
if hasattr(self, "_properties") and "location" in self._properties.keys():
199+
return self._properties["location"]
130200
if self.operator_name in _result_properties:
131201
return _result_properties[self.operator_name]["location"]
132202

@@ -142,7 +212,7 @@ def native_scoping_location(self):
142212
@property
143213
def physical_name(self) -> str:
144214
"""Name of the result with spaces"""
145-
return self._message.physicsname
215+
return self._physics_name
146216

147217

148218
_result_properties = {
@@ -180,9 +250,13 @@ def physical_name(self) -> str:
180250

181251

182252
def available_result_from_name(name) -> AvailableResult:
183-
message = available_result_pb2.AvailableResultResponse()
184-
message.physicsname = name
185253
for key, item in _result_properties.items():
186254
if item["scripting_name"] == name:
187-
message.name = key
188-
return AvailableResult(message)
255+
from types import SimpleNamespace
256+
availableresult = SimpleNamespace(name=key, physicsname=name, ncomp=None,
257+
dimensionality=None,
258+
homogeneity=None,
259+
unit=None, sub_res={},
260+
properties={"loc_name": item["location"],
261+
"scripting_name": name})
262+
return AvailableResult(availableresult)

0 commit comments

Comments
 (0)