ansys-fluent-core 0.34.dev0__py3-none-any.whl → 0.35.dev0__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 +48 -84
- ansys/fluent/core/codegen/allapigen.py +2 -2
- ansys/fluent/core/codegen/builtin_settingsgen.py +41 -13
- ansys/fluent/core/codegen/datamodelgen.py +3 -1
- ansys/fluent/core/codegen/print_fluent_version.py +2 -2
- ansys/fluent/core/codegen/settingsgen.py +18 -6
- ansys/fluent/core/codegen/tuigen.py +6 -5
- ansys/fluent/core/data_model_cache.py +2 -2
- ansys/fluent/core/docker/docker_compose.py +11 -9
- ansys/fluent/core/docker/utils.py +35 -0
- ansys/fluent/core/examples/downloads.py +8 -11
- ansys/fluent/core/exceptions.py +13 -1
- ansys/fluent/core/field_data_interfaces.py +239 -38
- ansys/fluent/core/file_session.py +167 -61
- ansys/fluent/core/fluent_connection.py +41 -26
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_231/flicing.py +40 -40
- ansys/fluent/core/generated/datamodel_231/meshing.py +231 -231
- ansys/fluent/core/generated/datamodel_232/flicing.py +50 -50
- ansys/fluent/core/generated/datamodel_232/meshing.py +189 -189
- ansys/fluent/core/generated/datamodel_241/flicing.py +30 -30
- ansys/fluent/core/generated/datamodel_241/meshing.py +290 -290
- ansys/fluent/core/generated/datamodel_242/flicing.py +50 -50
- ansys/fluent/core/generated/datamodel_242/meshing.py +331 -331
- ansys/fluent/core/generated/datamodel_242/part_management.py +6 -6
- ansys/fluent/core/generated/datamodel_251/flicing.py +65 -65
- ansys/fluent/core/generated/datamodel_251/meshing.py +300 -300
- ansys/fluent/core/generated/datamodel_251/part_management.py +6 -6
- ansys/fluent/core/generated/datamodel_252/flicing.py +25 -25
- ansys/fluent/core/generated/datamodel_252/meshing.py +382 -382
- ansys/fluent/core/generated/datamodel_252/part_management.py +10 -10
- ansys/fluent/core/generated/datamodel_261/flicing.py +45 -45
- ansys/fluent/core/generated/datamodel_261/meshing.py +454 -435
- ansys/fluent/core/generated/datamodel_261/part_management.py +5 -5
- ansys/fluent/core/generated/datamodel_261/preferences.py +7 -0
- ansys/fluent/core/generated/fluent_version_252.py +1 -1
- ansys/fluent/core/generated/fluent_version_261.py +3 -3
- ansys/fluent/core/generated/meshing/tui_261.py +54 -3
- 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 +560 -38
- ansys/fluent/core/generated/solver/settings_builtin.pyi +24 -18
- ansys/fluent/core/generated/solver/tui_261.py +409 -285
- ansys/fluent/core/launcher/container_launcher.py +25 -6
- ansys/fluent/core/launcher/error_handler.py +1 -1
- ansys/fluent/core/launcher/fluent_container.py +97 -45
- ansys/fluent/core/launcher/launch_options.py +5 -4
- ansys/fluent/core/launcher/launcher.py +18 -2
- ansys/fluent/core/launcher/launcher_utils.py +63 -15
- ansys/fluent/core/launcher/pim_launcher.py +17 -3
- ansys/fluent/core/launcher/process_launch_string.py +3 -2
- ansys/fluent/core/launcher/server_info.py +7 -3
- ansys/fluent/core/launcher/slurm_launcher.py +4 -2
- ansys/fluent/core/launcher/standalone_launcher.py +6 -3
- ansys/fluent/core/launcher/watchdog.py +6 -6
- ansys/fluent/core/launcher/watchdog_exec +1 -1
- ansys/fluent/core/logger.py +3 -1
- ansys/fluent/core/module_config.py +358 -0
- ansys/fluent/core/pyfluent_warnings.py +9 -3
- ansys/fluent/core/report.py +2 -2
- ansys/fluent/core/search.py +34 -13
- ansys/fluent/core/services/__init__.py +2 -2
- ansys/fluent/core/services/api_upgrade.py +3 -2
- ansys/fluent/core/services/app_utilities.py +39 -0
- ansys/fluent/core/services/datamodel_se.py +4 -2
- ansys/fluent/core/services/deprecated_field_data.py +4 -4
- ansys/fluent/core/services/field_data.py +185 -49
- ansys/fluent/core/services/health_check.py +3 -1
- ansys/fluent/core/services/interceptors.py +8 -6
- ansys/fluent/core/services/reduction.py +16 -5
- ansys/fluent/core/services/settings.py +1 -0
- ansys/fluent/core/session.py +47 -4
- ansys/fluent/core/session_pure_meshing.py +6 -6
- ansys/fluent/core/session_pure_meshing.pyi +1 -0
- ansys/fluent/core/session_shared.py +4 -4
- ansys/fluent/core/session_solver.py +41 -10
- ansys/fluent/core/session_solver.pyi +1 -0
- ansys/fluent/core/session_utilities.py +7 -0
- ansys/fluent/core/solver/error_message.py +2 -2
- ansys/fluent/core/solver/flobject.py +192 -123
- ansys/fluent/core/solver/function/reduction.py +37 -9
- ansys/fluent/core/solver/settings_builtin_bases.py +3 -3
- ansys/fluent/core/solver/settings_builtin_data.py +7 -17
- ansys/fluent/core/streaming_services/datamodel_event_streaming.py +3 -2
- ansys/fluent/core/streaming_services/datamodel_streaming.py +3 -1
- ansys/fluent/core/streaming_services/events_streaming.py +2 -18
- ansys/fluent/core/system_coupling.py +3 -1
- ansys/fluent/core/utils/__init__.py +0 -7
- ansys/fluent/core/utils/data_transfer.py +3 -3
- ansys/fluent/core/utils/file_transfer_service.py +24 -15
- ansys/fluent/core/utils/fluent_version.py +4 -6
- ansys/fluent/core/utils/networking.py +21 -11
- {ansys_fluent_core-0.34.dev0.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/METADATA +10 -11
- {ansys_fluent_core-0.34.dev0.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/RECORD +108 -106
- {ansys_fluent_core-0.34.dev0.dist-info → ansys_fluent_core-0.35.dev0.dist-info}/WHEEL +1 -1
- {ansys_fluent_core-0.34.dev0.dist-info/licenses → ansys_fluent_core-0.35.dev0.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(
|
|
@@ -484,7 +577,20 @@ class BaseFieldData:
|
|
|
484
577
|
| PathlinesFieldDataRequest
|
|
485
578
|
),
|
|
486
579
|
) -> Dict[int | str, Dict | np.array]:
|
|
487
|
-
"""Get the surface, scalar, vector or path-lines field data on a surface.
|
|
580
|
+
"""Get the surface, scalar, vector or path-lines field data on a surface.
|
|
581
|
+
|
|
582
|
+
Returns
|
|
583
|
+
-------
|
|
584
|
+
Dict[int | str, Dict | np.array]
|
|
585
|
+
Field data for the requested surface. If field data is unavailable for the surface,
|
|
586
|
+
an empty array is returned and a warning is issued. Users should always check
|
|
587
|
+
the array size before using the data.
|
|
588
|
+
|
|
589
|
+
Example:
|
|
590
|
+
data = get_field_data(field_data_request)[surface_id]
|
|
591
|
+
if data.size == 0:
|
|
592
|
+
# Handle missing data
|
|
593
|
+
"""
|
|
488
594
|
if isinstance(obj, SurfaceFieldDataRequest):
|
|
489
595
|
return self._get_surface_data(**obj._asdict())
|
|
490
596
|
elif isinstance(obj, ScalarFieldDataRequest):
|
|
@@ -495,8 +601,8 @@ class BaseFieldData:
|
|
|
495
601
|
return self._get_pathlines_field_data(**obj._asdict())
|
|
496
602
|
|
|
497
603
|
|
|
498
|
-
class
|
|
499
|
-
"""Provides access to Fluent field data on surfaces collected via
|
|
604
|
+
class BatchFieldData(BaseFieldData, BaseFieldDataSource):
|
|
605
|
+
"""Provides access to Fluent field data on surfaces collected via batches."""
|
|
500
606
|
|
|
501
607
|
def __init__(
|
|
502
608
|
self,
|
|
@@ -505,7 +611,7 @@ class TransactionFieldData(BaseFieldData, BaseFieldDataSource):
|
|
|
505
611
|
allowed_surface_names,
|
|
506
612
|
allowed_scalar_field_names,
|
|
507
613
|
):
|
|
508
|
-
"""__init__ method of
|
|
614
|
+
"""__init__ method of BatchFieldData class."""
|
|
509
615
|
super().__init__(
|
|
510
616
|
data, field_info, allowed_surface_names, allowed_scalar_field_names
|
|
511
617
|
)
|
|
@@ -517,19 +623,19 @@ class TransactionFieldData(BaseFieldData, BaseFieldDataSource):
|
|
|
517
623
|
return self.data
|
|
518
624
|
|
|
519
625
|
|
|
520
|
-
class
|
|
626
|
+
class Batch(FieldBatch):
|
|
521
627
|
"""Populates Fluent field data on surfaces."""
|
|
522
628
|
|
|
523
629
|
def __init__(
|
|
524
630
|
self,
|
|
525
631
|
service: FieldDataService,
|
|
526
|
-
field_info:
|
|
632
|
+
field_info: _FieldInfo,
|
|
527
633
|
allowed_surface_ids,
|
|
528
634
|
allowed_surface_names,
|
|
529
635
|
allowed_scalar_field_names,
|
|
530
636
|
allowed_vector_field_names,
|
|
531
637
|
):
|
|
532
|
-
"""__init__ method of
|
|
638
|
+
"""__init__ method of Batch class."""
|
|
533
639
|
self._service = service
|
|
534
640
|
self._field_info = field_info
|
|
535
641
|
self._fields_request = get_fields_request()
|
|
@@ -873,7 +979,7 @@ class Transaction(FieldTransaction):
|
|
|
873
979
|
self._cache_requests.append(req)
|
|
874
980
|
return self
|
|
875
981
|
|
|
876
|
-
def get_fields(self) ->
|
|
982
|
+
def get_fields(self) -> BatchFieldData:
|
|
877
983
|
"""Get data for previously added requests."""
|
|
878
984
|
warnings.warn(
|
|
879
985
|
"'get_fields' is deprecated, use 'get_response' instead",
|
|
@@ -881,7 +987,7 @@ class Transaction(FieldTransaction):
|
|
|
881
987
|
)
|
|
882
988
|
return self.get_response()
|
|
883
989
|
|
|
884
|
-
def get_response(self) ->
|
|
990
|
+
def get_response(self) -> BatchFieldData:
|
|
885
991
|
"""Get data for previously added requests.
|
|
886
992
|
|
|
887
993
|
Returns
|
|
@@ -892,7 +998,7 @@ class Transaction(FieldTransaction):
|
|
|
892
998
|
|
|
893
999
|
The tag is a tuple for Fluent 2023 R1 or later.
|
|
894
1000
|
"""
|
|
895
|
-
return
|
|
1001
|
+
return BatchFieldData(
|
|
896
1002
|
ChunkParser().extract_fields(
|
|
897
1003
|
self._service.get_fields(self._fields_request)
|
|
898
1004
|
),
|
|
@@ -932,9 +1038,9 @@ class _FieldDataConstants:
|
|
|
932
1038
|
|
|
933
1039
|
|
|
934
1040
|
def _get_surface_ids(
|
|
935
|
-
field_info:
|
|
1041
|
+
field_info: _FieldInfo,
|
|
936
1042
|
allowed_surface_names,
|
|
937
|
-
surfaces: List[int | str],
|
|
1043
|
+
surfaces: List[int | str | object],
|
|
938
1044
|
) -> List[int]:
|
|
939
1045
|
"""Get surface IDs based on surface names or IDs.
|
|
940
1046
|
|
|
@@ -948,10 +1054,11 @@ def _get_surface_ids(
|
|
|
948
1054
|
List[int]
|
|
949
1055
|
"""
|
|
950
1056
|
surface_ids = []
|
|
951
|
-
|
|
1057
|
+
updated_surfaces = get_surfaces_from_objects(surfaces)
|
|
1058
|
+
for surf in updated_surfaces:
|
|
952
1059
|
if isinstance(surf, str):
|
|
953
1060
|
surface_ids.extend(
|
|
954
|
-
field_info.
|
|
1061
|
+
field_info._get_surfaces_info()[allowed_surface_names.valid_name(surf)][
|
|
955
1062
|
"surface_id"
|
|
956
1063
|
]
|
|
957
1064
|
)
|
|
@@ -959,6 +1066,8 @@ def _get_surface_ids(
|
|
|
959
1066
|
allowed_surf_ids = _AllowedSurfaceIDs(field_info)()
|
|
960
1067
|
if surf in allowed_surf_ids:
|
|
961
1068
|
surface_ids.append(surf)
|
|
1069
|
+
elif isinstance(surf, Iterable) and not isinstance(surf, (str, bytes)):
|
|
1070
|
+
raise DisallowedValuesError("surface", surf, list(surf))
|
|
962
1071
|
else:
|
|
963
1072
|
raise DisallowedValuesError("surface", surf, allowed_surf_ids)
|
|
964
1073
|
return surface_ids
|
|
@@ -1089,13 +1198,19 @@ class ChunkParser:
|
|
|
1089
1198
|
payload_tag_id = None
|
|
1090
1199
|
field = None
|
|
1091
1200
|
if payload_tag_id is not None:
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1201
|
+
if payload_info.fieldSize > 0:
|
|
1202
|
+
field = _extract_field(
|
|
1203
|
+
_FieldDataConstants.proto_field_type_to_np_data_type[
|
|
1204
|
+
payload_info.fieldType
|
|
1205
|
+
],
|
|
1206
|
+
payload_info.fieldSize,
|
|
1207
|
+
chunk_iterator,
|
|
1208
|
+
)
|
|
1209
|
+
else:
|
|
1210
|
+
warnings.warn(
|
|
1211
|
+
f"Field data is not available for surface: {surface_id}"
|
|
1212
|
+
)
|
|
1213
|
+
field = np.array([])
|
|
1099
1214
|
|
|
1100
1215
|
if self._callbacks_provider is not None:
|
|
1101
1216
|
for callback_data in self._callbacks_provider.callbacks():
|
|
@@ -1257,7 +1372,7 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1257
1372
|
def __init__(
|
|
1258
1373
|
self,
|
|
1259
1374
|
service: FieldDataService,
|
|
1260
|
-
field_info:
|
|
1375
|
+
field_info: _FieldInfo,
|
|
1261
1376
|
is_data_valid: Callable[[], bool],
|
|
1262
1377
|
scheme_eval=None,
|
|
1263
1378
|
get_zones_info: weakref.WeakMethod[Callable[[], list[ZoneInfo]]] | None = None,
|
|
@@ -1327,12 +1442,21 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1327
1442
|
),
|
|
1328
1443
|
self.get_pathlines_field_data,
|
|
1329
1444
|
)
|
|
1445
|
+
self.surfaces = _SurfaceNames(allowed_surface_names=self._allowed_surface_names)
|
|
1446
|
+
self.surface_ids = _SurfaceIds(allowed_surface_ids=self._allowed_surface_ids)
|
|
1447
|
+
self.scalar_fields = _ScalarFields(
|
|
1448
|
+
available_field_names=self._allowed_scalar_field_names,
|
|
1449
|
+
field_info=self._field_info,
|
|
1450
|
+
)
|
|
1451
|
+
self.vector_fields = _VectorFields(
|
|
1452
|
+
available_field_names=self._allowed_vector_field_names
|
|
1453
|
+
)
|
|
1330
1454
|
self._returned_data = _ReturnFieldData()
|
|
1331
1455
|
self._fetched_data = _FetchFieldData()
|
|
1332
1456
|
|
|
1333
|
-
def
|
|
1334
|
-
"""Create a new field
|
|
1335
|
-
return
|
|
1457
|
+
def new_batch(self):
|
|
1458
|
+
"""Create a new field batch."""
|
|
1459
|
+
return Batch(
|
|
1336
1460
|
self._service,
|
|
1337
1461
|
self._field_info,
|
|
1338
1462
|
self._allowed_surface_ids,
|
|
@@ -1341,6 +1465,11 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1341
1465
|
self._allowed_vector_field_names,
|
|
1342
1466
|
)
|
|
1343
1467
|
|
|
1468
|
+
@deprecated(version="0.34", reason="Use `new_batch` instead.")
|
|
1469
|
+
def new_transaction(self):
|
|
1470
|
+
"""Create a new field transaction."""
|
|
1471
|
+
return self.new_batch()
|
|
1472
|
+
|
|
1344
1473
|
def _get_scalar_field_data(self, **kwargs):
|
|
1345
1474
|
surfaces = kwargs.get("surfaces")
|
|
1346
1475
|
surface_ids = self.get_surface_ids(surfaces)
|
|
@@ -1385,10 +1514,15 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1385
1514
|
surface_ids,
|
|
1386
1515
|
surface_data,
|
|
1387
1516
|
deprecated_flag=True,
|
|
1517
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1388
1518
|
)
|
|
1389
1519
|
|
|
1390
1520
|
return self._returned_data._surface_data(
|
|
1391
|
-
kwargs.get("data_types"),
|
|
1521
|
+
kwargs.get("data_types"),
|
|
1522
|
+
kwargs.get("surfaces"),
|
|
1523
|
+
surface_ids,
|
|
1524
|
+
surface_data,
|
|
1525
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1392
1526
|
)
|
|
1393
1527
|
|
|
1394
1528
|
def _get_vector_field_data(
|
|
@@ -1467,6 +1601,7 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1467
1601
|
surface_ids,
|
|
1468
1602
|
pathlines_data,
|
|
1469
1603
|
deprecated_flag=True,
|
|
1604
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1470
1605
|
)
|
|
1471
1606
|
|
|
1472
1607
|
return self._returned_data._pathlines_data(
|
|
@@ -1474,6 +1609,7 @@ class LiveFieldData(BaseFieldData, FieldDataSource):
|
|
|
1474
1609
|
kwargs.get("surfaces"),
|
|
1475
1610
|
surface_ids,
|
|
1476
1611
|
pathlines_data,
|
|
1612
|
+
flatten_connectivity=kwargs.get("flatten_connectivity"),
|
|
1477
1613
|
)
|
|
1478
1614
|
|
|
1479
1615
|
def get_scalar_field_data(
|
|
@@ -80,7 +80,9 @@ class HealthCheckService:
|
|
|
80
80
|
"""
|
|
81
81
|
request = HealthCheckModule.HealthCheckRequest()
|
|
82
82
|
response = self._stub.Check(
|
|
83
|
-
request,
|
|
83
|
+
request,
|
|
84
|
+
metadata=self._metadata,
|
|
85
|
+
timeout=pyfluent.config.check_health_timeout,
|
|
84
86
|
)
|
|
85
87
|
return HealthCheckService.Status(response.status)
|
|
86
88
|
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
import builtins
|
|
26
26
|
import logging
|
|
27
|
-
import os
|
|
28
27
|
from typing import Any
|
|
29
28
|
|
|
30
29
|
from google.protobuf.json_format import MessageToDict
|
|
@@ -34,8 +33,6 @@ import grpc
|
|
|
34
33
|
from ansys.fluent.core.services.batch_ops import BatchOps
|
|
35
34
|
|
|
36
35
|
network_logger: logging.Logger = logging.getLogger("pyfluent.networking")
|
|
37
|
-
log_bytes_limit: int = int(os.getenv("PYFLUENT_GRPC_LOG_BYTES_LIMIT", 1000))
|
|
38
|
-
truncate_len: int = log_bytes_limit // 5
|
|
39
36
|
|
|
40
37
|
|
|
41
38
|
def _upper_snake_case_to_camel_case(name: str) -> str:
|
|
@@ -43,14 +40,17 @@ def _upper_snake_case_to_camel_case(name: str) -> str:
|
|
|
43
40
|
|
|
44
41
|
|
|
45
42
|
def _truncate_grpc_str(message: Message) -> str:
|
|
43
|
+
from ansys.fluent.core import config
|
|
44
|
+
|
|
45
|
+
truncate_len = config.grpc_log_bytes_limit // 5
|
|
46
46
|
message_bytes = message.ByteSize()
|
|
47
47
|
message_str = str(MessageToDict(message))
|
|
48
|
-
if not
|
|
48
|
+
if not config.grpc_log_bytes_limit or message_bytes < config.grpc_log_bytes_limit:
|
|
49
49
|
return message_str
|
|
50
50
|
else:
|
|
51
51
|
network_logger.debug(
|
|
52
52
|
f"GRPC_TRACE: message partially hidden, {message_bytes} bytes > "
|
|
53
|
-
f"{
|
|
53
|
+
f"{config.grpc_log_bytes_limit} bytes limit. To see the full message, set PYFLUENT_GRPC_LOG_BYTES_LIMIT to 0."
|
|
54
54
|
)
|
|
55
55
|
return f"{message_str[:truncate_len]} < ... > {message_str[-truncate_len:]}"
|
|
56
56
|
|
|
@@ -68,6 +68,8 @@ class TracingInterceptor(grpc.UnaryUnaryClientInterceptor):
|
|
|
68
68
|
client_call_details: grpc.ClientCallDetails,
|
|
69
69
|
request: Any,
|
|
70
70
|
) -> Any:
|
|
71
|
+
from ansys.fluent.core import config
|
|
72
|
+
|
|
71
73
|
network_logger.debug(
|
|
72
74
|
f"GRPC_TRACE: RPC = {client_call_details.method}, request = {_truncate_grpc_str(request)}"
|
|
73
75
|
)
|
|
@@ -75,7 +77,7 @@ class TracingInterceptor(grpc.UnaryUnaryClientInterceptor):
|
|
|
75
77
|
if not response.exception():
|
|
76
78
|
# call _truncate_grpc_str early to get the size warning even when hiding secrets
|
|
77
79
|
response_str = _truncate_grpc_str(response.result())
|
|
78
|
-
if
|
|
80
|
+
if not config.hide_log_secrets:
|
|
79
81
|
network_logger.debug(f"GRPC_TRACE: response = {response_str}")
|
|
80
82
|
return response
|
|
81
83
|
|
|
@@ -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
|