Skip to content

Commit

Permalink
Moved some post objects from viz. to core repo. (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
prmukherj authored Dec 8, 2022
1 parent fda43cb commit b0d77ec
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 935 deletions.
67 changes: 10 additions & 57 deletions src/ansys/fluent/visualization/matplotlib/matplot_objects.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,28 @@
"""Module providing visualization objects for Matplotlib."""
import inspect
import sys
from typing import Optional

from ansys.fluent.core.meta import PyLocalContainer
from ansys.fluent.core.post_objects.post_object_definitions import (
MonitorDefn,
XYPlotDefn,
)
from ansys.fluent.core.post_objects.post_objects_container import (
Plots as PlotsContainer,
)

from ansys.fluent.visualization.matplotlib.matplot_windows_manager import (
matplot_windows_manager,
)
from ansys.fluent.visualization.post_object_defns import MonitorDefn, XYPlotDefn


class Plots:
"""Provides the Matplotlib ``Plots`` objects manager.
class Plots(PlotsContainer):
"""
This class provides access to ``Plots`` object containers for a given
session so that plots can be created.
Parameters
----------
session : obj
Session object.
local_surfaces_provider : object, optional
Object providing local surfaces so that you can access surfaces
created in other modules, such as PyVista. The default is ``None``.
Attributes
----------
XYPlots : dict
Container for XY plot objects.
MonitorPlots : dict
Container for monitor plot objects.
"""

_sessions_state = {}

def __init__(self, session, local_surfaces_provider=None):
"""Instantiate Plots, container of plot objects.
Parameters
----------
session :
Session object.
local_surfaces_provider : object, optional
Object providing local surfaces.
"""
session_state = Plots._sessions_state.get(session.id if session else 1)
if not session_state:
session_state = self.__dict__
Plots._sessions_state[session.id if session else 1] = session_state
self.session = session
self._init_module(self, sys.modules[__name__])
else:
self.__dict__ = session_state
self._local_surfaces_provider = lambda: local_surfaces_provider or getattr(
self, "Surfaces", []
)

def _init_module(self, obj, mod):
from ansys.fluent.visualization.post_helper import PostAPIHelper

for name, cls in mod.__dict__.items():

if cls.__class__.__name__ in (
"PyLocalNamedObjectMetaAbstract",
) and not inspect.isabstract(cls):
setattr(
obj,
cls.PLURAL,
PyLocalContainer(self, cls, PostAPIHelper),
)
super().__init__(session, sys.modules[__name__], local_surfaces_provider)


class XYPlot(XYPlotDefn):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from typing import Dict, List, Optional, Union

from ansys.fluent.core.fluent_connection import _FluentConnection
from ansys.fluent.core.post_objects.post_object_definitions import (
MonitorDefn,
PlotDefn,
XYPlotDefn,
)
from ansys.fluent.core.utils.generic import AbstractSingletonMeta, in_notebook

from ansys.fluent.visualization import get_config
from ansys.fluent.visualization.matplotlib.plotter_defns import Plotter, ProcessPlotter
from ansys.fluent.visualization.post_data_extractor import XYPlotDataExtractor
from ansys.fluent.visualization.post_object_defns import (
MonitorDefn,
PlotDefn,
XYPlotDefn,
)
from ansys.fluent.visualization.post_windows_manager import (
PostWindow,
PostWindowsManager,
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/fluent/visualization/post_data_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
from typing import Dict

from ansys.api.fluent.v0.field_data_pb2 import DataLocation, PayloadTag
from ansys.fluent.core.post_objects.post_object_definitions import (
GraphicsDefn,
PlotDefn,
)
from ansys.fluent.core.services.field_data import (
_FieldDataConstants,
merge_pathlines_data,
)
import numpy as np

from ansys.fluent.visualization.post_object_defns import GraphicsDefn, PlotDefn


class FieldDataExtractor:
"""FieldData DataExtractor."""
Expand Down
149 changes: 0 additions & 149 deletions src/ansys/fluent/visualization/post_helper.py

This file was deleted.

Loading

0 comments on commit b0d77ec

Please sign in to comment.