diff --git a/src/ansys/fluent/core/logging.py b/src/ansys/fluent/core/logging.py index 1e29be60dd0..e5558f2f836 100644 --- a/src/ansys/fluent/core/logging.py +++ b/src/ansys/fluent/core/logging.py @@ -61,6 +61,8 @@ def get_default_config() -> dict: 'maxBytes': 10485760}}, 'loggers': {'pyfluent.datamodel': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, + 'pyfluent.field_data': {'handlers': ['pyfluent_file'], + 'level': 'DEBUG'}, 'pyfluent.general': {'handlers': ['pyfluent_file'], 'level': 'DEBUG'}, 'pyfluent.launcher': {'handlers': ['pyfluent_file'], diff --git a/src/ansys/fluent/core/logging_config.yaml b/src/ansys/fluent/core/logging_config.yaml index 84e43fb9507..eeea066e8e1 100644 --- a/src/ansys/fluent/core/logging_config.yaml +++ b/src/ansys/fluent/core/logging_config.yaml @@ -43,3 +43,6 @@ loggers: pyfluent.post_objects: level: DEBUG handlers: [pyfluent_file] + pyfluent.field_data: + level: DEBUG + handlers: [pyfluent_file] diff --git a/src/ansys/fluent/core/services/field_data.py b/src/ansys/fluent/core/services/field_data.py index ded4d6da802..4e080aa278d 100644 --- a/src/ansys/fluent/core/services/field_data.py +++ b/src/ansys/fluent/core/services/field_data.py @@ -4,6 +4,7 @@ from enum import Enum from functools import reduce import io +import logging from typing import Callable, Dict, List, Tuple import weakref @@ -22,6 +23,8 @@ from ansys.fluent.core.services.streaming import StreamingService from ansys.fluent.core.utils.deprecate import deprecate_argument, deprecate_arguments +logger = logging.getLogger("pyfluent.field_data") + def override_help_text(func, func_to_be_wrapped): """Override function help text.""" @@ -1074,10 +1077,9 @@ class Mesh: Attributes: ----------- nodes : list[Node] - List of nodes in the mesh. Sorted by Fluent's node ID. + List of nodes in the mesh. elements : list[Element] - List of elements in the mesh. Unsorted as we want to correlate with the - solution data retrieved via svar service. + List of elements in the mesh. """ nodes: list[Node] @@ -1480,19 +1482,25 @@ def get_mesh(self, zone: str | int) -> Mesh: raise NotImplementedError("Face zone mesh is not supported.") # Mesh data is retrieved from the root domain in Fluent - request = FieldDataProtoModule.GetSolverMeshNodesRequest( + logger.info(f"Getting nodes data for zone {zone_info._id}") + nodes_request = FieldDataProtoModule.GetSolverMeshNodesRequest( domain_id=ROOT_DOMAIN_ID, thread_id=zone_info._id ) - response = self._service.get_solver_mesh_nodes(request) - nodes = response.nodes - nodes = [Node(_id=node.id, x=node.x, y=node.y, z=node.z) for node in nodes] - nodes = sorted(nodes, key=lambda x: x._id) - node_index_by_id = {node._id: index for index, node in enumerate(nodes)} - request = FieldDataProtoModule.GetSolverMeshElementsRequest( + nodes_response = self._service.get_solver_mesh_nodes(nodes_request) + logger.info("Nodes data received") + logger.info(f"Getting elements for zone {zone_info._id}") + elements_request = FieldDataProtoModule.GetSolverMeshElementsRequest( domain_id=ROOT_DOMAIN_ID, thread_id=zone_info._id ) - response = self._service.get_solver_mesh_elements(request) - elements_pb = response.elements + elements_response = self._service.get_solver_mesh_elements(elements_request) + logger.info("Elements data received") + logger.info("Constructing nodes structure in PyFluent") + nodes = nodes_response.nodes + nodes = [Node(_id=node.id, x=node.x, y=node.y, z=node.z) for node in nodes] + node_index_by_id = {node._id: index for index, node in enumerate(nodes)} + logger.info("Nodes structure constructed") + logger.info("Constructing elements structure in PyFluent") + elements_pb = elements_response.elements elements = [] for element_pb in elements_pb: element_type = CellElementType(element_pb.element_type) @@ -1515,4 +1523,6 @@ def get_mesh(self, zone: str | int) -> Mesh: node_indices=[node_index_by_id[id] for id in element_pb.node_ids], ) elements.append(element) + logger.info("Elements structure constructed") + logger.info("Returning mesh") return Mesh(nodes=nodes, elements=elements)