Skip to content

Commit

Permalink
fix: Remove get_fields_info() and implement factory pattern for AppUt…
Browse files Browse the repository at this point in the history
…ilities (#3604)

* fix: field_info for viz.

* fix: Use get_scalar_fields_info() instead of get_fields_info()

* Use factory pattern for AppUtilities

---------

Co-authored-by: Prithwish Mukherjee <[email protected]>
Co-authored-by: Prithwish Mukherjee <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2025
1 parent 70453dc commit 39b2d18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
18 changes: 0 additions & 18 deletions src/ansys/fluent/core/services/field_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ def __init__(
stub=FieldGrpcModule.FieldDataStub(intercept_channel), metadata=metadata
)

def get_fields_info(self, request):
"""GetFieldsInfo RPC of FieldData service."""
return self._stub.GetFieldsInfo(request, metadata=self._metadata)

def get_scalar_field_range(self, request):
"""GetRange RPC of FieldData service."""
return self._stub.GetRange(request, metadata=self._metadata)
Expand Down Expand Up @@ -92,9 +88,6 @@ class FieldInfo:
Methods
-------
get_fields_info(field: str) -> List[dict]
Get fields info.
get_scalar_field_range(field: str, node_value: bool, surface_ids: List[int])
-> List[float]
Get the range (minimum and maximum values) of the field.
Expand All @@ -118,17 +111,6 @@ def __init__(
self._service = service
self._is_data_valid = is_data_valid

def get_fields_info(self) -> List[dict]:
"""Get fields info.
Returns
-------
List[dict]
"""
request = FieldDataProtoModule.GetFieldsInfo()
response = self._service.get_fields_info(request)
return response["fieldInfo"]

def get_scalar_field_range(
self, field: str, node_value: bool = False, surface_ids: List[int] = None
) -> List[float]:
Expand Down
20 changes: 14 additions & 6 deletions src/ansys/fluent/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ def __call__(self):
return self._scheme_eval.scheme_eval("(data-valid?)")


class _AppUtilitiesFactory:
"""AppUtilities factory."""

@staticmethod
def _create_app_utilities(scheme_eval, fluent_connection):
if FluentVersion(scheme_eval.version) < FluentVersion.v252:
return AppUtilitiesOld(scheme_eval)
else:
return fluent_connection._connection_interface._app_utilities


class BaseSession:
"""Encapsulates a Fluent session.
Expand Down Expand Up @@ -133,12 +144,9 @@ def _build_from_fluent_connection(
if self._start_transcript:
self.transcript.start()

if FluentVersion(self.scheme_eval.version) < FluentVersion.v252:
self._app_utilities = AppUtilitiesOld(self.scheme_eval)
else:
self._app_utilities = (
self._fluent_connection._connection_interface._app_utilities
)
self._app_utilities = _AppUtilitiesFactory._create_app_utilities(
self.scheme_eval, self._fluent_connection
)

self.journal = Journal(self._app_utilities)

Expand Down

0 comments on commit 39b2d18

Please sign in to comment.