ansys-fluent-core 0.33.0__py3-none-any.whl → 0.34.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-fluent-core might be problematic. Click here for more details.
- ansys/fluent/core/__init__.py +3 -3
- ansys/fluent/core/codegen/builtin_settingsgen.py +25 -19
- ansys/fluent/core/codegen/settingsgen.py +17 -5
- ansys/fluent/core/codegen/tuigen.py +2 -1
- ansys/fluent/core/docker/docker_compose.py +4 -1
- ansys/fluent/core/docker/utils.py +35 -0
- ansys/fluent/core/exceptions.py +13 -1
- ansys/fluent/core/field_data_interfaces.py +239 -38
- ansys/fluent/core/file_session.py +139 -59
- ansys/fluent/core/fluent_connection.py +23 -16
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_231/flicing.py +30 -30
- ansys/fluent/core/generated/datamodel_231/meshing.py +171 -171
- ansys/fluent/core/generated/datamodel_232/flicing.py +35 -35
- ansys/fluent/core/generated/datamodel_232/meshing.py +223 -223
- ansys/fluent/core/generated/datamodel_241/flicing.py +35 -35
- ansys/fluent/core/generated/datamodel_241/meshing.py +264 -264
- ansys/fluent/core/generated/datamodel_242/flicing.py +30 -30
- ansys/fluent/core/generated/datamodel_242/meshing.py +369 -369
- ansys/fluent/core/generated/datamodel_251/flicing.py +35 -35
- ansys/fluent/core/generated/datamodel_251/meshing.py +331 -331
- ansys/fluent/core/generated/datamodel_251/part_management.py +3 -3
- ansys/fluent/core/generated/datamodel_252/flicing.py +50 -50
- ansys/fluent/core/generated/datamodel_252/meshing.py +398 -398
- ansys/fluent/core/generated/datamodel_252/part_management.py +5 -5
- ansys/fluent/core/generated/datamodel_261/flicing.py +40 -40
- ansys/fluent/core/generated/datamodel_261/meshing.py +416 -397
- ansys/fluent/core/generated/datamodel_261/part_management.py +10 -10
- ansys/fluent/core/generated/datamodel_261/preferences.py +7 -0
- ansys/fluent/core/generated/fluent_version_261.py +3 -3
- ansys/fluent/core/generated/meshing/tui_261.py +1186 -1180
- ansys/fluent/core/generated/solver/settings_231.py +1 -0
- ansys/fluent/core/generated/solver/settings_231.pyi +3025 -1
- ansys/fluent/core/generated/solver/settings_232.py +1 -0
- ansys/fluent/core/generated/solver/settings_232.pyi +3425 -1
- ansys/fluent/core/generated/solver/settings_241.py +1 -0
- ansys/fluent/core/generated/solver/settings_241.pyi +4423 -1
- ansys/fluent/core/generated/solver/settings_242.py +1 -0
- ansys/fluent/core/generated/solver/settings_242.pyi +5474 -1
- ansys/fluent/core/generated/solver/settings_251.py +11 -0
- ansys/fluent/core/generated/solver/settings_251.pyi +6006 -1
- ansys/fluent/core/generated/solver/settings_252.py +11 -1
- ansys/fluent/core/generated/solver/settings_252.pyi +6782 -2
- ansys/fluent/core/generated/solver/settings_261.py +5592 -2740
- ansys/fluent/core/generated/solver/settings_261.pyi +10335 -1994
- ansys/fluent/core/generated/solver/settings_builtin.py +56 -22
- ansys/fluent/core/generated/solver/settings_builtin.pyi +22 -0
- ansys/fluent/core/generated/solver/tui_261.py +2445 -2281
- ansys/fluent/core/launcher/container_launcher.py +6 -2
- ansys/fluent/core/launcher/error_handler.py +1 -1
- ansys/fluent/core/launcher/fluent_container.py +53 -10
- ansys/fluent/core/launcher/launcher.py +3 -0
- ansys/fluent/core/launcher/watchdog.py +6 -6
- ansys/fluent/core/launcher/watchdog_exec +1 -1
- ansys/fluent/core/pyfluent_warnings.py +7 -1
- ansys/fluent/core/report.py +2 -0
- ansys/fluent/core/search.py +11 -3
- ansys/fluent/core/services/__init__.py +2 -2
- ansys/fluent/core/services/app_utilities.py +39 -0
- ansys/fluent/core/services/deprecated_field_data.py +4 -4
- ansys/fluent/core/services/field_data.py +158 -41
- ansys/fluent/core/services/reduction.py +16 -5
- ansys/fluent/core/services/settings.py +1 -0
- ansys/fluent/core/session.py +16 -1
- ansys/fluent/core/session_pure_meshing.py +5 -5
- ansys/fluent/core/session_pure_meshing.pyi +1 -0
- ansys/fluent/core/session_solver.py +33 -8
- ansys/fluent/core/session_solver.pyi +1 -0
- ansys/fluent/core/solver/error_message.py +2 -2
- ansys/fluent/core/solver/flobject.py +187 -120
- ansys/fluent/core/solver/function/reduction.py +37 -9
- ansys/fluent/core/solver/settings_builtin_data.py +5 -3
- ansys/fluent/core/utils/fluent_version.py +1 -3
- ansys/fluent/core/utils/networking.py +18 -8
- {ansys_fluent_core-0.33.0.dist-info → ansys_fluent_core-0.34.0.dist-info}/METADATA +10 -11
- {ansys_fluent_core-0.33.0.dist-info → ansys_fluent_core-0.34.0.dist-info}/RECORD +78 -77
- {ansys_fluent_core-0.33.0.dist-info → ansys_fluent_core-0.34.0.dist-info}/WHEEL +1 -1
- {ansys_fluent_core-0.33.0.dist-info/licenses → ansys_fluent_core-0.34.0.dist-info}/LICENSE +0 -0
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
"""Wrappers over FieldData gRPC service of Fluent."""
|
|
24
|
+
from collections.abc import Iterable
|
|
24
25
|
from dataclasses import dataclass, field
|
|
25
26
|
from enum import Enum
|
|
26
27
|
from functools import reduce
|
|
@@ -30,6 +31,7 @@ from typing import Callable, Dict, List, Tuple
|
|
|
30
31
|
import warnings
|
|
31
32
|
import weakref
|
|
32
33
|
|
|
34
|
+
from deprecated.sphinx import deprecated
|
|
33
35
|
import grpc
|
|
34
36
|
import numpy as np
|
|
35
37
|
|
|
@@ -39,8 +41,8 @@ from ansys.fluent.core.exceptions import DisallowedValuesError
|
|
|
39
41
|
from ansys.fluent.core.field_data_interfaces import (
|
|
40
42
|
BaseFieldDataSource,
|
|
41
43
|
BaseFieldInfo,
|
|
44
|
+
FieldBatch,
|
|
42
45
|
FieldDataSource,
|
|
43
|
-
FieldTransaction,
|
|
44
46
|
PathlinesFieldDataRequest,
|
|
45
47
|
ScalarFieldDataRequest,
|
|
46
48
|
SurfaceDataType,
|
|
@@ -51,7 +53,12 @@ from ansys.fluent.core.field_data_interfaces import (
|
|
|
51
53
|
_AllowedSurfaceNames,
|
|
52
54
|
_AllowedVectorFieldNames,
|
|
53
55
|
_ReturnFieldData,
|
|
56
|
+
_ScalarFields,
|
|
57
|
+
_SurfaceIds,
|
|
58
|
+
_SurfaceNames,
|
|
54
59
|
_to_field_name_str,
|
|
60
|
+
_VectorFields,
|
|
61
|
+
get_surfaces_from_objects,
|
|
55
62
|
)
|
|
56
63
|
from ansys.fluent.core.pyfluent_warnings import PyFluentDeprecationWarning
|
|
57
64
|
from ansys.fluent.core.services.interceptors import (
|
|
@@ -156,25 +163,7 @@ class FieldDataService(StreamingService):
|
|
|
156
163
|
return elementss
|
|
157
164
|
|
|
158
165
|
|
|
159
|
-
class
|
|
160
|
-
"""Provides access to Fluent field information.
|
|
161
|
-
|
|
162
|
-
Methods
|
|
163
|
-
-------
|
|
164
|
-
get_scalar_field_range(field: str, node_value: bool, surface_ids: List[int])
|
|
165
|
-
-> List[float]
|
|
166
|
-
Get the range (minimum and maximum values) of the field.
|
|
167
|
-
|
|
168
|
-
get_scalar_fields_info(self) -> dict
|
|
169
|
-
Get fields information (field name, domain, and section).
|
|
170
|
-
|
|
171
|
-
get_vector_fields_info(self) -> dict
|
|
172
|
-
Get vector fields information.
|
|
173
|
-
|
|
174
|
-
get_surfaces_info(self) -> dict
|
|
175
|
-
Get surfaces information (surface name, ID, and type).
|
|
176
|
-
"""
|
|
177
|
-
|
|
166
|
+
class _FieldInfo(BaseFieldInfo):
|
|
178
167
|
def __init__(
|
|
179
168
|
self,
|
|
180
169
|
service: FieldDataService,
|
|
@@ -201,6 +190,16 @@ class FieldInfo(BaseFieldInfo):
|
|
|
201
190
|
-------
|
|
202
191
|
List[float]
|
|
203
192
|
"""
|
|
193
|
+
warnings.warn(
|
|
194
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
195
|
+
f"Please use 'field_data.scalar_fields.range({field}, {node_value}, {surface_ids})' instead",
|
|
196
|
+
PyFluentDeprecationWarning,
|
|
197
|
+
)
|
|
198
|
+
return self._get_scalar_field_range(field, node_value, surface_ids)
|
|
199
|
+
|
|
200
|
+
def _get_scalar_field_range(
|
|
201
|
+
self, field: str, node_value: bool = False, surface_ids: List[int] = None
|
|
202
|
+
) -> List[float]:
|
|
204
203
|
if not surface_ids:
|
|
205
204
|
surface_ids = []
|
|
206
205
|
request = FieldDataProtoModule.GetRangeRequest()
|
|
@@ -219,6 +218,14 @@ class FieldInfo(BaseFieldInfo):
|
|
|
219
218
|
-------
|
|
220
219
|
Dict
|
|
221
220
|
"""
|
|
221
|
+
warnings.warn(
|
|
222
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
223
|
+
"Please use 'field_data.scalar_fields()' instead",
|
|
224
|
+
PyFluentDeprecationWarning,
|
|
225
|
+
)
|
|
226
|
+
return self._get_scalar_fields_info()
|
|
227
|
+
|
|
228
|
+
def _get_scalar_fields_info(self) -> Dict[str, Dict]:
|
|
222
229
|
request = FieldDataProtoModule.GetFieldsInfoRequest()
|
|
223
230
|
response = self._service.get_scalar_fields_info(request)
|
|
224
231
|
return {
|
|
@@ -238,6 +245,14 @@ class FieldInfo(BaseFieldInfo):
|
|
|
238
245
|
-------
|
|
239
246
|
Dict
|
|
240
247
|
"""
|
|
248
|
+
warnings.warn(
|
|
249
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
250
|
+
"Please use 'field_data.vector_fields()' instead",
|
|
251
|
+
PyFluentDeprecationWarning,
|
|
252
|
+
)
|
|
253
|
+
return self._get_vector_fields_info()
|
|
254
|
+
|
|
255
|
+
def _get_vector_fields_info(self) -> Dict[str, Dict]:
|
|
241
256
|
request = FieldDataProtoModule.GetVectorFieldsInfoRequest()
|
|
242
257
|
response = self._service.get_vector_fields_info(request)
|
|
243
258
|
return {
|
|
@@ -256,6 +271,14 @@ class FieldInfo(BaseFieldInfo):
|
|
|
256
271
|
-------
|
|
257
272
|
Dict
|
|
258
273
|
"""
|
|
274
|
+
warnings.warn(
|
|
275
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
276
|
+
"Please use 'field_data.surfaces()' instead",
|
|
277
|
+
PyFluentDeprecationWarning,
|
|
278
|
+
)
|
|
279
|
+
return self._get_surfaces_info()
|
|
280
|
+
|
|
281
|
+
def _get_surfaces_info(self) -> Dict[str, Dict]:
|
|
259
282
|
request = FieldDataProtoModule.GetSurfacesInfoResponse()
|
|
260
283
|
response = self._service.get_surfaces_info(request)
|
|
261
284
|
info = {
|
|
@@ -271,20 +294,64 @@ class FieldInfo(BaseFieldInfo):
|
|
|
271
294
|
|
|
272
295
|
def validate_scalar_fields(self, field_name: str):
|
|
273
296
|
"""Validate scalar fields."""
|
|
297
|
+
warnings.warn(
|
|
298
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
299
|
+
f"Please use 'field_data.scalar_fields.is_active(field_name={field_name})' instead",
|
|
300
|
+
PyFluentDeprecationWarning,
|
|
301
|
+
)
|
|
274
302
|
_AllowedScalarFieldNames(
|
|
275
|
-
self._is_data_valid, info=self.
|
|
303
|
+
self._is_data_valid, info=self._get_scalar_fields_info()
|
|
276
304
|
).valid_name(field_name)
|
|
277
305
|
|
|
278
306
|
def validate_vector_fields(self, field_name: str):
|
|
279
307
|
"""Validate vector fields."""
|
|
308
|
+
warnings.warn(
|
|
309
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
310
|
+
f"Please use 'field_data.vector_fields.is_active(field_name={field_name})' instead",
|
|
311
|
+
PyFluentDeprecationWarning,
|
|
312
|
+
)
|
|
280
313
|
_AllowedVectorFieldNames(
|
|
281
|
-
self._is_data_valid, info=self.
|
|
314
|
+
self._is_data_valid, info=self._get_vector_fields_info()
|
|
282
315
|
).valid_name(field_name)
|
|
283
316
|
|
|
284
317
|
def validate_surfaces(self, surfaces: List[str]):
|
|
285
318
|
"""Validate surfaces."""
|
|
319
|
+
warnings.warn(
|
|
320
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
321
|
+
f"Please use 'field_data.surfaces.validate(surfaces={surfaces})' instead",
|
|
322
|
+
PyFluentDeprecationWarning,
|
|
323
|
+
)
|
|
286
324
|
for surface in surfaces:
|
|
287
|
-
_AllowedSurfaceNames(info=self.
|
|
325
|
+
_AllowedSurfaceNames(info=self._get_surfaces_info()).valid_name(surface)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
class FieldInfo(_FieldInfo):
|
|
329
|
+
"""Provides access to Fluent field information.
|
|
330
|
+
|
|
331
|
+
Methods
|
|
332
|
+
-------
|
|
333
|
+
get_scalar_field_range(field: str, node_value: bool, surface_ids: List[int])
|
|
334
|
+
-> List[float]
|
|
335
|
+
Get the range (minimum and maximum values) of the field.
|
|
336
|
+
|
|
337
|
+
get_scalar_fields_info(self) -> dict
|
|
338
|
+
Get fields information (field name, domain, and section).
|
|
339
|
+
|
|
340
|
+
get_vector_fields_info(self) -> dict
|
|
341
|
+
Get vector fields information.
|
|
342
|
+
|
|
343
|
+
get_surfaces_info(self) -> dict
|
|
344
|
+
Get surfaces information (surface name, ID, and type).
|
|
345
|
+
"""
|
|
346
|
+
|
|
347
|
+
def __init__(self, service: FieldDataService, is_data_valid: Callable[[], bool]):
|
|
348
|
+
"""__init__ method of FieldInfo class."""
|
|
349
|
+
warnings.warn(
|
|
350
|
+
"'FieldInfo' is deprecated and will be removed in a future release. "
|
|
351
|
+
"Please use relevant methods from 'FieldData' instead",
|
|
352
|
+
PyFluentDeprecationWarning,
|
|
353
|
+
)
|
|
354
|
+
super().__init__(service, is_data_valid)
|
|
288
355
|
|
|
289
356
|
|
|
290
357
|
class _FieldMethod:
|
|
@@ -294,6 +361,30 @@ class _FieldMethod:
|
|
|
294
361
|
|
|
295
362
|
def allowed_values(self):
|
|
296
363
|
"""Returns set of allowed values."""
|
|
364
|
+
if self._accessor.__class__.__name__ == "_AllowedScalarFieldNames":
|
|
365
|
+
warnings.warn(
|
|
366
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
367
|
+
"Please use 'scalar_fields.allowed_values()' instead",
|
|
368
|
+
PyFluentDeprecationWarning,
|
|
369
|
+
)
|
|
370
|
+
elif self._accessor.__class__.__name__ == "_AllowedVectorFieldNames":
|
|
371
|
+
warnings.warn(
|
|
372
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
373
|
+
"Please use 'vector_fields.allowed_values()' instead",
|
|
374
|
+
PyFluentDeprecationWarning,
|
|
375
|
+
)
|
|
376
|
+
elif self._accessor.__class__.__name__ == "_AllowedSurfaceNames":
|
|
377
|
+
warnings.warn(
|
|
378
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
379
|
+
"Please use 'field_data.surfaces.allowed_values()' instead",
|
|
380
|
+
PyFluentDeprecationWarning,
|
|
381
|
+
)
|
|
382
|
+
elif self._accessor.__class__.__name__ == "_AllowedSurfaceIDs":
|
|
383
|
+
warnings.warn(
|
|
384
|
+
"This usage is deprecated and will be removed in a future release. "
|
|
385
|
+
"Please use 'field_data.surface_ids.allowed_values()' instead",
|
|
386
|
+
PyFluentDeprecationWarning,
|
|
387
|
+
)
|
|
297
388
|
return sorted(self._accessor())
|
|
298
389
|
|
|
299
390
|
def __init__(self, field_data_accessor, args_allowed_values_accessors):
|
|
@@ -445,6 +536,7 @@ class BaseFieldData:
|
|
|
445
536
|
kwargs.get("surfaces"),
|
|
446
537
|
self.get_surface_ids(kwargs.get("surfaces")),
|
|
447
538
|
surface_data,
|
|
539
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
448
540
|
)
|
|
449
541
|
|
|
450
542
|
def _get_vector_field_data(
|
|
@@ -473,6 +565,7 @@ class BaseFieldData:
|
|
|
473
565
|
kwargs.get("surfaces"),
|
|
474
566
|
self.get_surface_ids(kwargs.get("surfaces")),
|
|
475
567
|
pathlines_data,
|
|
568
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
476
569
|
)
|
|
477
570
|
|
|
478
571
|
def get_field_data(
|
|
@@ -495,8 +588,8 @@ class BaseFieldData:
|
|
|
495
588
|
return self._get_pathlines_field_data(**obj._asdict())
|
|
496
589
|
|
|
497
590
|
|
|
498
|
-
class
|
|
499
|
-
"""Provides access to Fluent field data on surfaces collected via
|
|
591
|
+
class BatchFieldData(BaseFieldData, BaseFieldDataSource):
|
|
592
|
+
"""Provides access to Fluent field data on surfaces collected via batches."""
|
|
500
593
|
|
|
501
594
|
def __init__(
|
|
502
595
|
self,
|
|
@@ -505,7 +598,7 @@ class TransactionFieldData(BaseFieldData, BaseFieldDataSource):
|
|
|
505
598
|
allowed_surface_names,
|
|
506
599
|
allowed_scalar_field_names,
|
|
507
600
|
):
|
|
508
|
-
"""__init__ method of
|
|
601
|
+
"""__init__ method of BatchFieldData class."""
|
|
509
602
|
super().__init__(
|
|
510
603
|
data, field_info, allowed_surface_names, allowed_scalar_field_names
|
|
511
604
|
)
|
|
@@ -517,19 +610,19 @@ class TransactionFieldData(BaseFieldData, BaseFieldDataSource):
|
|
|
517
610
|
return self.data
|
|
518
611
|
|
|
519
612
|
|
|
520
|
-
class
|
|
613
|
+
class Batch(FieldBatch):
|
|
521
614
|
"""Populates Fluent field data on surfaces."""
|
|
522
615
|
|
|
523
616
|
def __init__(
|
|
524
617
|
self,
|
|
525
618
|
service: FieldDataService,
|
|
526
|
-
field_info:
|
|
619
|
+
field_info: _FieldInfo,
|
|
527
620
|
allowed_surface_ids,
|
|
528
621
|
allowed_surface_names,
|
|
529
622
|
allowed_scalar_field_names,
|
|
530
623
|
allowed_vector_field_names,
|
|
531
624
|
):
|
|
532
|
-
"""__init__ method of
|
|
625
|
+
"""__init__ method of Batch class."""
|
|
533
626
|
self._service = service
|
|
534
627
|
self._field_info = field_info
|
|
535
628
|
self._fields_request = get_fields_request()
|
|
@@ -873,7 +966,7 @@ class Transaction(FieldTransaction):
|
|
|
873
966
|
self._cache_requests.append(req)
|
|
874
967
|
return self
|
|
875
968
|
|
|
876
|
-
def get_fields(self) ->
|
|
969
|
+
def get_fields(self) -> BatchFieldData:
|
|
877
970
|
"""Get data for previously added requests."""
|
|
878
971
|
warnings.warn(
|
|
879
972
|
"'get_fields' is deprecated, use 'get_response' instead",
|
|
@@ -881,7 +974,7 @@ class Transaction(FieldTransaction):
|
|
|
881
974
|
)
|
|
882
975
|
return self.get_response()
|
|
883
976
|
|
|
884
|
-
def get_response(self) ->
|
|
977
|
+
def get_response(self) -> BatchFieldData:
|
|
885
978
|
"""Get data for previously added requests.
|
|
886
979
|
|
|
887
980
|
Returns
|
|
@@ -892,7 +985,7 @@ class Transaction(FieldTransaction):
|
|
|
892
985
|
|
|
893
986
|
The tag is a tuple for Fluent 2023 R1 or later.
|
|
894
987
|
"""
|
|
895
|
-
return
|
|
988
|
+
return BatchFieldData(
|
|
896
989
|
ChunkParser().extract_fields(
|
|
897
990
|
self._service.get_fields(self._fields_request)
|
|
898
991
|
),
|
|
@@ -932,9 +1025,9 @@ class _FieldDataConstants:
|
|
|
932
1025
|
|
|
933
1026
|
|
|
934
1027
|
def _get_surface_ids(
|
|
935
|
-
field_info:
|
|
1028
|
+
field_info: _FieldInfo,
|
|
936
1029
|
allowed_surface_names,
|
|
937
|
-
surfaces: List[int | str],
|
|
1030
|
+
surfaces: List[int | str | object],
|
|
938
1031
|
) -> List[int]:
|
|
939
1032
|
"""Get surface IDs based on surface names or IDs.
|
|
940
1033
|
|
|
@@ -948,10 +1041,11 @@ def _get_surface_ids(
|
|
|
948
1041
|
List[int]
|
|
949
1042
|
"""
|
|
950
1043
|
surface_ids = []
|
|
951
|
-
|
|
1044
|
+
updated_surfaces = get_surfaces_from_objects(surfaces)
|
|
1045
|
+
for surf in updated_surfaces:
|
|
952
1046
|
if isinstance(surf, str):
|
|
953
1047
|
surface_ids.extend(
|
|
954
|
-
field_info.
|
|
1048
|
+
field_info._get_surfaces_info()[allowed_surface_names.valid_name(surf)][
|
|
955
1049
|
"surface_id"
|
|
956
1050
|
]
|
|
957
1051
|
)
|
|
@@ -959,6 +1053,8 @@ def _get_surface_ids(
|
|
|
959
1053
|
allowed_surf_ids = _AllowedSurfaceIDs(field_info)()
|
|
960
1054
|
if surf in allowed_surf_ids:
|
|
961
1055
|
surface_ids.append(surf)
|
|
1056
|
+
elif isinstance(surf, Iterable) and not isinstance(surf, (str, bytes)):
|
|
1057
|
+
raise DisallowedValuesError("surface", surf, list(surf))
|
|
962
1058
|
else:
|
|
963
1059
|
raise DisallowedValuesError("surface", surf, allowed_surf_ids)
|
|
964
1060
|
return surface_ids
|
|
@@ -1257,7 +1353,7 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1257
1353
|
def __init__(
|
|
1258
1354
|
self,
|
|
1259
1355
|
service: FieldDataService,
|
|
1260
|
-
field_info:
|
|
1356
|
+
field_info: _FieldInfo,
|
|
1261
1357
|
is_data_valid: Callable[[], bool],
|
|
1262
1358
|
scheme_eval=None,
|
|
1263
1359
|
get_zones_info: weakref.WeakMethod[Callable[[], list[ZoneInfo]]] | None = None,
|
|
@@ -1327,12 +1423,21 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1327
1423
|
),
|
|
1328
1424
|
self.get_pathlines_field_data,
|
|
1329
1425
|
)
|
|
1426
|
+
self.surfaces = _SurfaceNames(allowed_surface_names=self._allowed_surface_names)
|
|
1427
|
+
self.surface_ids = _SurfaceIds(allowed_surface_ids=self._allowed_surface_ids)
|
|
1428
|
+
self.scalar_fields = _ScalarFields(
|
|
1429
|
+
available_field_names=self._allowed_scalar_field_names,
|
|
1430
|
+
field_info=self._field_info,
|
|
1431
|
+
)
|
|
1432
|
+
self.vector_fields = _VectorFields(
|
|
1433
|
+
available_field_names=self._allowed_vector_field_names
|
|
1434
|
+
)
|
|
1330
1435
|
self._returned_data = _ReturnFieldData()
|
|
1331
1436
|
self._fetched_data = _FetchFieldData()
|
|
1332
1437
|
|
|
1333
|
-
def
|
|
1334
|
-
"""Create a new field
|
|
1335
|
-
return
|
|
1438
|
+
def new_batch(self):
|
|
1439
|
+
"""Create a new field batch."""
|
|
1440
|
+
return Batch(
|
|
1336
1441
|
self._service,
|
|
1337
1442
|
self._field_info,
|
|
1338
1443
|
self._allowed_surface_ids,
|
|
@@ -1341,6 +1446,11 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1341
1446
|
self._allowed_vector_field_names,
|
|
1342
1447
|
)
|
|
1343
1448
|
|
|
1449
|
+
@deprecated(version="0.34", reason="Use `new_batch` instead.")
|
|
1450
|
+
def new_transaction(self):
|
|
1451
|
+
"""Create a new field transaction."""
|
|
1452
|
+
return self.new_batch()
|
|
1453
|
+
|
|
1344
1454
|
def _get_scalar_field_data(self, **kwargs):
|
|
1345
1455
|
surfaces = kwargs.get("surfaces")
|
|
1346
1456
|
surface_ids = self.get_surface_ids(surfaces)
|
|
@@ -1385,10 +1495,15 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1385
1495
|
surface_ids,
|
|
1386
1496
|
surface_data,
|
|
1387
1497
|
deprecated_flag=True,
|
|
1498
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1388
1499
|
)
|
|
1389
1500
|
|
|
1390
1501
|
return self._returned_data._surface_data(
|
|
1391
|
-
kwargs.get("data_types"),
|
|
1502
|
+
kwargs.get("data_types"),
|
|
1503
|
+
kwargs.get("surfaces"),
|
|
1504
|
+
surface_ids,
|
|
1505
|
+
surface_data,
|
|
1506
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1392
1507
|
)
|
|
1393
1508
|
|
|
1394
1509
|
def _get_vector_field_data(
|
|
@@ -1467,6 +1582,7 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1467
1582
|
surface_ids,
|
|
1468
1583
|
pathlines_data,
|
|
1469
1584
|
deprecated_flag=True,
|
|
1585
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1470
1586
|
)
|
|
1471
1587
|
|
|
1472
1588
|
return self._returned_data._pathlines_data(
|
|
@@ -1474,6 +1590,7 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1474
1590
|
kwargs.get("surfaces"),
|
|
1475
1591
|
surface_ids,
|
|
1476
1592
|
pathlines_data,
|
|
1593
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1477
1594
|
)
|
|
1478
1595
|
|
|
1479
1596
|
def get_scalar_field_data(
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
"""Wrappers over Reduction gRPC service of Fluent."""
|
|
24
|
-
|
|
24
|
+
from collections.abc import Iterable
|
|
25
25
|
from typing import Any, List, Tuple
|
|
26
26
|
import weakref
|
|
27
27
|
|
|
@@ -29,6 +29,7 @@ import grpc
|
|
|
29
29
|
|
|
30
30
|
from ansys.api.fluent.v0 import reduction_pb2 as ReductionProtoModule
|
|
31
31
|
from ansys.api.fluent.v0 import reduction_pb2_grpc as ReductionGrpcModule
|
|
32
|
+
from ansys.fluent.core.exceptions import DisallowedValuesError
|
|
32
33
|
from ansys.fluent.core.services.datamodel_se import _convert_variant_to_value
|
|
33
34
|
from ansys.fluent.core.services.interceptors import (
|
|
34
35
|
BatchInterceptor,
|
|
@@ -36,6 +37,7 @@ from ansys.fluent.core.services.interceptors import (
|
|
|
36
37
|
GrpcErrorInterceptor,
|
|
37
38
|
TracingInterceptor,
|
|
38
39
|
)
|
|
40
|
+
from ansys.fluent.core.solver.function.reduction import Weight
|
|
39
41
|
from ansys.fluent.core.variable_strategies import (
|
|
40
42
|
FluentExprNamingStrategy as naming_strategy,
|
|
41
43
|
)
|
|
@@ -282,7 +284,7 @@ class Reduction:
|
|
|
282
284
|
if all(
|
|
283
285
|
loc not in names()
|
|
284
286
|
for names in (
|
|
285
|
-
self.ctxt.fields.
|
|
287
|
+
self.ctxt.fields.field_data.surfaces,
|
|
286
288
|
self.ctxt.settings.setup.cell_zone_conditions,
|
|
287
289
|
)
|
|
288
290
|
):
|
|
@@ -292,6 +294,8 @@ class Reduction:
|
|
|
292
294
|
if locations == []:
|
|
293
295
|
return []
|
|
294
296
|
for loc in locations:
|
|
297
|
+
if isinstance(loc, Iterable) and not isinstance(loc, (str, bytes)):
|
|
298
|
+
raise DisallowedValuesError("location", loc, list(loc))
|
|
295
299
|
if isinstance(loc, str):
|
|
296
300
|
self._validate_str_location(loc)
|
|
297
301
|
try:
|
|
@@ -312,12 +316,17 @@ class Reduction:
|
|
|
312
316
|
if expression is not None:
|
|
313
317
|
request.expression = self._to_str(expression)
|
|
314
318
|
if weight is not None:
|
|
315
|
-
request.weight = weight
|
|
319
|
+
request.weight = Weight(weight).value
|
|
316
320
|
if condition is not None:
|
|
317
321
|
request.condition = condition
|
|
318
322
|
request.locations.extend(self._get_location_string(locations, ctxt))
|
|
319
323
|
return request
|
|
320
324
|
|
|
325
|
+
@property
|
|
326
|
+
def weight(self):
|
|
327
|
+
"""Weight for calculating sum."""
|
|
328
|
+
return Weight
|
|
329
|
+
|
|
321
330
|
def area(self, locations, ctxt=None) -> Any:
|
|
322
331
|
"""Get area."""
|
|
323
332
|
request = self._make_request("AreaRequest", locations, ctxt)
|
|
@@ -442,13 +451,15 @@ class Reduction:
|
|
|
442
451
|
response = self.service.moment(request)
|
|
443
452
|
return (response.value.x, response.value.y, response.value.z)
|
|
444
453
|
|
|
445
|
-
def sum(self, expression, locations, weight, ctxt=None) -> Any:
|
|
454
|
+
def sum(self, expression, locations, weight: str | Weight, ctxt=None) -> Any:
|
|
446
455
|
"""Get sum."""
|
|
447
456
|
request = self._make_request("SumRequest", locations, ctxt, expression, weight)
|
|
448
457
|
response = self.service.sum(request)
|
|
449
458
|
return _convert_variant_to_value(response.value)
|
|
450
459
|
|
|
451
|
-
def sum_if(
|
|
460
|
+
def sum_if(
|
|
461
|
+
self, expression, condition, locations, weight: str | Weight, ctxt=None
|
|
462
|
+
) -> Any:
|
|
452
463
|
"""Compute the weighted sum of the expression at locations where the given condition is satisfied."""
|
|
453
464
|
request = self._make_request(
|
|
454
465
|
"SumIfRequest", locations, ctxt, expression, weight, condition
|
|
@@ -335,6 +335,7 @@ class SettingsService:
|
|
|
335
335
|
"""
|
|
336
336
|
request = SettingsModule.GetStaticInfoRequest()
|
|
337
337
|
request.root = "fluent"
|
|
338
|
+
request.optional_attrs.append("allowed-values")
|
|
338
339
|
response = self._service_impl.get_static_info(request)
|
|
339
340
|
# The RPC calls no longer raise an exception. Force an exception if
|
|
340
341
|
# type is empty
|
ansys/fluent/core/session.py
CHANGED
|
@@ -452,9 +452,18 @@ class BaseSession:
|
|
|
452
452
|
"field_data_streaming",
|
|
453
453
|
"start_journal",
|
|
454
454
|
"stop_journal",
|
|
455
|
+
"scheme_eval",
|
|
455
456
|
}
|
|
456
457
|
return sorted(dir_list)
|
|
457
458
|
|
|
459
|
+
def enable_beta_features(self):
|
|
460
|
+
"""Enable access to Fluent beta-features"""
|
|
461
|
+
self._app_utilities.enable_beta()
|
|
462
|
+
|
|
463
|
+
@property
|
|
464
|
+
def _is_beta_enabled(self):
|
|
465
|
+
return self._app_utilities.is_beta_enabled()
|
|
466
|
+
|
|
458
467
|
|
|
459
468
|
class Fields:
|
|
460
469
|
"""Container for field and solution variables."""
|
|
@@ -468,7 +477,7 @@ class Fields:
|
|
|
468
477
|
self._is_solution_data_valid = (
|
|
469
478
|
_session._app_utilities.is_solution_data_available
|
|
470
479
|
)
|
|
471
|
-
self.
|
|
480
|
+
self._field_info = service_creator("field_info").create(
|
|
472
481
|
_session._field_data_service,
|
|
473
482
|
self._is_solution_data_valid,
|
|
474
483
|
)
|
|
@@ -488,3 +497,9 @@ class Fields:
|
|
|
488
497
|
self._is_solution_data_valid,
|
|
489
498
|
_session.scheme,
|
|
490
499
|
)
|
|
500
|
+
|
|
501
|
+
@property
|
|
502
|
+
@deprecated(version="0.34.0", reason="Use relevant ``field_data`` methods..")
|
|
503
|
+
def field_info(self):
|
|
504
|
+
"""Field Information."""
|
|
505
|
+
return self._field_info
|
|
@@ -27,6 +27,7 @@ from typing import Any, Dict
|
|
|
27
27
|
|
|
28
28
|
import ansys.fluent.core as pyfluent
|
|
29
29
|
from ansys.fluent.core.data_model_cache import DataModelCache, NameKey
|
|
30
|
+
from ansys.fluent.core.exceptions import BetaFeaturesNotEnabled
|
|
30
31
|
from ansys.fluent.core.fluent_connection import FluentConnection
|
|
31
32
|
from ansys.fluent.core.services import SchemeEval
|
|
32
33
|
from ansys.fluent.core.session import BaseSession
|
|
@@ -175,13 +176,12 @@ class PureMeshing(BaseSession):
|
|
|
175
176
|
|
|
176
177
|
Raises
|
|
177
178
|
------
|
|
178
|
-
|
|
179
|
+
AttributeError
|
|
179
180
|
If beta features are not enabled in Fluent.
|
|
180
181
|
"""
|
|
181
|
-
if not self.
|
|
182
|
-
raise
|
|
183
|
-
self._base_meshing.topology_based_meshing_workflow
|
|
184
|
-
return self._base_meshing.topology_based_meshing_workflow
|
|
182
|
+
if not self._is_beta_enabled:
|
|
183
|
+
raise BetaFeaturesNotEnabled("Topology-based meshing")
|
|
184
|
+
return self._base_meshing.topology_based_meshing_workflow()
|
|
185
185
|
|
|
186
186
|
@property
|
|
187
187
|
def PartManagement(self):
|
|
@@ -30,6 +30,7 @@ import weakref
|
|
|
30
30
|
|
|
31
31
|
from ansys.api.fluent.v0 import svar_pb2 as SvarProtoModule
|
|
32
32
|
import ansys.fluent.core as pyfluent
|
|
33
|
+
from ansys.fluent.core.exceptions import BetaFeaturesNotEnabled
|
|
33
34
|
from ansys.fluent.core.pyfluent_warnings import PyFluentDeprecationWarning
|
|
34
35
|
from ansys.fluent.core.services import SchemeEval, service_creator
|
|
35
36
|
from ansys.fluent.core.services.field_data import ZoneInfo, ZoneType
|
|
@@ -353,16 +354,40 @@ class Solver(BaseSession):
|
|
|
353
354
|
raise ex
|
|
354
355
|
|
|
355
356
|
def __dir__(self):
|
|
356
|
-
|
|
357
|
-
return ["is_active"]
|
|
358
|
-
dir_list = set(list(self.__dict__.keys()) + dir(type(self))) - {
|
|
357
|
+
dir_list = set(super().__dir__()) - {
|
|
359
358
|
"svar_data",
|
|
360
359
|
"svar_info",
|
|
361
360
|
"reduction",
|
|
362
|
-
"field_data",
|
|
363
|
-
"field_info",
|
|
364
|
-
"field_data_streaming",
|
|
365
|
-
"start_journal",
|
|
366
|
-
"stop_journal",
|
|
367
361
|
}
|
|
368
362
|
return sorted(dir_list)
|
|
363
|
+
|
|
364
|
+
def switch_to_meshing(self):
|
|
365
|
+
"""Switch to meshing mode and return a meshing session object. Deactivate this
|
|
366
|
+
object's public interface and streaming services.
|
|
367
|
+
|
|
368
|
+
Raises
|
|
369
|
+
------
|
|
370
|
+
AttributeError
|
|
371
|
+
If beta features are not enabled in Fluent.
|
|
372
|
+
|
|
373
|
+
Returns
|
|
374
|
+
-------
|
|
375
|
+
Meshing
|
|
376
|
+
"""
|
|
377
|
+
if not self._is_beta_enabled:
|
|
378
|
+
raise BetaFeaturesNotEnabled("switch_to_meshing")
|
|
379
|
+
from ansys.fluent.core.session_meshing import Meshing
|
|
380
|
+
|
|
381
|
+
self.settings.switch_to_meshing_mode()
|
|
382
|
+
for cb in self._fluent_connection.finalizer_cbs:
|
|
383
|
+
cb()
|
|
384
|
+
meshing_session = Meshing(
|
|
385
|
+
fluent_connection=self._fluent_connection,
|
|
386
|
+
scheme_eval=self.scheme,
|
|
387
|
+
file_transfer_service=self._file_transfer_service,
|
|
388
|
+
)
|
|
389
|
+
self._fluent_connection = None
|
|
390
|
+
self.__doc__ = (
|
|
391
|
+
"The solver session is no longer usable after switching to meshing mode."
|
|
392
|
+
)
|
|
393
|
+
return meshing_session
|
|
@@ -49,9 +49,9 @@ def allowed_name_error_message(
|
|
|
49
49
|
if all(isinstance(item, str) for item in allowed_values) and allowed_values:
|
|
50
50
|
matches = closest_allowed_names(trial_name, allowed_values)
|
|
51
51
|
if matches:
|
|
52
|
-
message += f"The most similar names are: {', '.join(matches)}
|
|
52
|
+
message += f"The most similar names are: {', '.join(matches)}"
|
|
53
53
|
else:
|
|
54
|
-
message += f"The allowed values are: {allowed_values}
|
|
54
|
+
message += f"The allowed values are: {allowed_values}"
|
|
55
55
|
|
|
56
56
|
return message
|
|
57
57
|
|