Skip to content

Commit

Permalink
Merge branch 'main' into maint/activate_2d_meshing_tests_for_251
Browse files Browse the repository at this point in the history
  • Loading branch information
prmukherj authored Sep 14, 2024
2 parents 60488aa + 46dee93 commit f02f208
Show file tree
Hide file tree
Showing 14 changed files with 344 additions and 83 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
# Check https://python-poetry.org/docs/pyproject/ for all available sections
name = "ansys-fluent-core"
version = "0.26.dev0"
version = "0.27.dev0"
description = "PyFluent provides Pythonic access to Ansys Fluent"
license = "MIT"
authors = ["ANSYS, Inc. <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

# major, minor, patch
version_info = 0, 26, "dev0"
version_info = 0, 27, "dev0"

# Nice string for the version
__version__ = ".".join(map(str, version_info))
Expand Down
22 changes: 14 additions & 8 deletions src/ansys/fluent/core/fluent_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,20 @@ def get_cortex_connection_properties(self):

return fluent_host_pid, cortex_host, cortex_pid, cortex_pwd

def is_solver_mode(self):
"""Checks if the Fluent session is in solver mode.
Returns
--------
``True`` if the Fluent session is in solver mode, ``False`` otherwise.
"""
return self.scheme_eval.scheme_eval("(cx-solver-mode?)")
def get_mode(self):
"""Get the mode of a running fluent session."""
from ansys.fluent.core import FluentMode

if self.scheme_eval.scheme_eval("(cx-solver-mode?)"):
mode_str = self.scheme_eval.scheme_eval('(getenv "PRJAPP_APP")')
if mode_str == "flaero_server":
return FluentMode.SOLVER_AERO
elif mode_str == "flicing":
return FluentMode.SOLVER_ICING
else:
return FluentMode.SOLVER
else:
return FluentMode.MESHING

def exit_server(self):
"""Exits the server."""
Expand Down
8 changes: 0 additions & 8 deletions src/ansys/fluent/core/launcher/fluent_launcher_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
},
"fluent_format": "{}"
},
"fluent_icing": {
"type": "bool",
"fluent_map": {
"true": " -flicing",
"false": ""
},
"fluent_format": "{}"
},
"py": {
"type": "bool",
"default": "null",
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/fluent/core/launcher/process_launch_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ def _generate_launch_string(
else:
exe_path = str(get_fluent_exe_path(**argvals))
launch_string = exe_path
if argvals["mode"] == FluentMode.SOLVER_ICING:
argvals["fluent_icing"] = True
launch_string += _build_fluent_launch_args_string(**argvals)
if argvals["mode"] == FluentMode.SOLVER_ICING:
launch_string += " -flicing -license=enterprise"
if argvals["mode"] == FluentMode.SOLVER_AERO:
launch_string += " -flaero_server -license=enterprise"
if FluentMode.is_meshing(argvals["mode"]):
launch_string += " -meshing"
if " " in server_info_file_name:
Expand Down
9 changes: 4 additions & 5 deletions src/ansys/fluent/core/launcher/pyfluent_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ansys.fluent.core.session_meshing import Meshing
from ansys.fluent.core.session_pure_meshing import PureMeshing
from ansys.fluent.core.session_solver import Solver
from ansys.fluent.core.session_solver_aero import SolverAero
from ansys.fluent.core.session_solver_icing import SolverIcing
from ansys.fluent.core.utils.fluent_version import FluentVersion
import ansys.platform.instancemanagement as pypim
Expand Down Expand Up @@ -80,6 +81,7 @@ class FluentMode(FluentEnum):
PURE_MESHING = "pure_meshing"
SOLVER = "solver"
SOLVER_ICING = "solver_icing"
SOLVER_AERO = "solver_aero"

def _default(self):
return self.SOLVER
Expand All @@ -90,6 +92,7 @@ def _get_enum_map(self):
self.PURE_MESHING: PureMeshing,
self.SOLVER: Solver,
self.SOLVER_ICING: SolverIcing,
self.SOLVER_AERO: SolverAero,
}

@staticmethod
Expand Down Expand Up @@ -267,11 +270,7 @@ def _get_running_session_mode(
session_mode = mode
else:
try:
session_mode = FluentMode(
"solver"
if fluent_connection._connection_interface.is_solver_mode()
else "meshing"
)
session_mode = fluent_connection._connection_interface.get_mode()
except Exception as ex:
raise exceptions.InvalidPassword() from ex
return session_mode.get_fluent_value()
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/launcher/standalone_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def __init__(
# Using 'start.exe' is better; otherwise Fluent is more susceptible to bad termination attempts.
self._launch_cmd = 'start "" ' + self._launch_string
else:
if self.argvals["ui_mode"] < UIMode.HIDDEN_GUI:
if self.argvals["ui_mode"] not in [UIMode.GUI, UIMode.HIDDEN_GUI]:
# Using nohup to hide Fluent output from the current terminal
self._launch_cmd = "nohup " + self._launch_string + " &"
else:
Expand Down
20 changes: 8 additions & 12 deletions src/ansys/fluent/core/services/solution_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ def __init__(
self._service = service
self._solution_variable_info = solution_variable_info

self.get_data = override_help_text(
_SvarMethod(
svar_accessor=self.get_data,
args_allowed_values_accessors={},
),
SolutionVariableData.get_data,
)

def _update_solution_variable_info(self):
self._allowed_zone_names = _AllowedZoneNames(self._solution_variable_info)

Expand All @@ -531,18 +539,6 @@ def _update_solution_variable_info(self):
self._allowed_solution_variable_names = _AllowedSvarNames(
self._solution_variable_info
)
svar_args = dict(
zone_names=self._allowed_zone_names,
solution_variable_name=self._allowed_solution_variable_names,
)

self.get_data = override_help_text(
_SvarMethod(
svar_accessor=self.get_data,
args_allowed_values_accessors=svar_args,
),
SolutionVariableData.get_data,
)

def create_empty_array(
self,
Expand Down
95 changes: 95 additions & 0 deletions src/ansys/fluent/core/session_solver_aero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""Module containing class encapsulating Fluent connection.
Expose aero capabilities.
"""

from typing import Any, Dict

from ansys.fluent.core.fluent_connection import FluentConnection
from ansys.fluent.core.services import SchemeEval
from ansys.fluent.core.services.datamodel_se import PyMenuGeneric
from ansys.fluent.core.session_solver import Solver


class SolverAero(Solver):
"""Encapsulates a Fluent server for Aero session connection.
SolverAero(Session) holds the top-level objects for solver TUI, settings and aero
datamodel objects calls.
"""

def __init__(
self,
fluent_connection: FluentConnection,
scheme_eval: SchemeEval,
file_transfer_service: Any | None = None,
start_transcript: bool = True,
launcher_args: Dict[str, Any] | None = None,
):
"""SolverAero session.
Parameters
----------
fluent_connection (:ref:`ref_fluent_connection`):
Encapsulates a Fluent connection.
scheme_eval: SchemeEval
Instance of ``SchemeEval`` to execute Fluent's scheme code on.
file_transfer_service : Optional
Service for uploading and downloading files.
start_transcript : bool, optional
Whether to start the Fluent transcript in the client.
The default is ``True``, in which case the Fluent
transcript can be subsequently started and stopped
using method calls on the ``Session`` object.
"""
super(SolverAero, self).__init__(
fluent_connection=fluent_connection,
scheme_eval=scheme_eval,
file_transfer_service=file_transfer_service,
start_transcript=start_transcript,
launcher_args=launcher_args,
)
self._flserver_root = None
self._fluent_version = None
self._fluent_connection = fluent_connection
# TODO: Update Aero DM
scheme_eval.scheme_eval("(aero-load-addon)")

def new_project(self, project_name: str):
"""Define a new project."""
# TODO: Update Aero DM
self.scheme_eval.scheme_eval(f"""(prjapp-new-project-cb #f "{project_name}")""")

def open_project(self, project_name: str):
"""Open a saved project."""
# TODO: Update Aero DM
self.scheme_eval.scheme_eval(
f"""(prjapp-project-open-project-cb #f "{project_name}")"""
)

def new_simulation(self, case_file_name: str):
"""Add a new simulation by loading a case-file."""
# TODO: Update Aero DM
self.scheme_eval.scheme_eval(
f"""(gui-aero-project-add-workflow-cb #f "{case_file_name}" #f #f)"""
)

def open_simulation(self, simulation_file_name: str):
"""Open a saved simulation."""
# TODO: Update Aero DM
self.scheme_eval.scheme_eval(
f"""(aero-server-project-open-simulation "{simulation_file_name}")"""
)

@property
def _flserver(self):
"""Root datamodel object."""
return PyMenuGeneric(service=self._se_service, rules="flserver")

@property
def aero(self):
"""Instance of aero (Case.App) -> root datamodel object."""
return self._flserver.Case.App

def __dir__(self):
return super(SolverAero, self).__dir__()
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/session_solver_icing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Module containing class encapsulating Fluent connection.
**********PRESENTLY SAME AS SOLVER WITH A SWITCH TO SOLVER***********
Expose icing capabilities.
"""

import importlib
Expand Down
Loading

0 comments on commit f02f208

Please sign in to comment.