Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved some post objects from viz. to core repo. #166

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 8 additions & 62 deletions src/ansys/fluent/visualization/matplotlib/matplot_objects.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,21 @@
"""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 import Plots as PlotsBase

prmukherj marked this conversation as resolved.
Show resolved Hide resolved
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.

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 = {}

class Plots(PlotsBase):
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 Expand Up @@ -121,7 +67,7 @@ class MonitorPlot(MonitorDefn):

.. code-block:: python

from ansys.fluent.visualization.matplotlib import Plots
from ansys.fluent.core.post_objects.post_objects import Plots

matplotlib_plots = Plots(session)
plot1 = matplotlib_plots.Monitors["plot-1"]
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