Skip to content

Commit

Permalink
Merge branch 'main' into maint/update_delete_syntax_for_surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
prmukherj authored Dec 17, 2024
2 parents 9dfd0e2 + ba1ff61 commit 5ccf183
Show file tree
Hide file tree
Showing 14 changed files with 1,361 additions and 84 deletions.
30 changes: 15 additions & 15 deletions doc/source/user_guide/solver_settings/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ as a dictionary for ``Group`` and ``NamedObject`` types or as a list for ``ListO
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> viscous = pyfluent.Viscous(settings_source=solver)
>>> viscous = pyfluent.solver.Viscous(settings_source=solver)
>>> viscous.model()
'k-epsilon-standard'
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> energy = pyfluent.Energy(settings_source=solver)
>>> energy = pyfluent.solver.Energy(settings_source=solver)
>>> from pprint import pprint
>>> pprint (energy(), width=1)
{'enabled': True,
'inlet_diffusion': True,
'kinetic_energy': False,
'pressure_work': False,
'viscous_dissipation': False}
>>> inlet1 = pyfluent.VelocityInlet(settings_source=solver, name="inlet1")
>>> inlet1 = pyfluent.solver.VelocityInlet(settings_source=solver, name="inlet1")
>>> inlet1.vmag.constant()
10.0
Expand All @@ -129,11 +129,11 @@ and ``NamedObject`` types, the state value is a dictionary. For the
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> viscous = pyfluent.Viscous(settings_source=solver)
>>> viscous = pyfluent.solver.Viscous(settings_source=solver)
>>> viscous.model = 'laminar'
>>> energy = pyfluent.Energy(settings_source=solver)
>>> energy = pyfluent.solver.Energy(settings_source=solver)
>>> energy = { 'enabled' : False }
>>> inlet1 = pyfluent.VelocityInlet(settings_source=solver, name="inlet1")
>>> inlet1 = pyfluent.solver.VelocityInlet(settings_source=solver, name="inlet1")
>>> inlet1.vmag.constant = 14
Expand Down Expand Up @@ -165,7 +165,7 @@ You can print the current state in a simple text format with the
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> models = pyfluent.Models(settings_source=solver)
>>> models = pyfluent.solver.Models(settings_source=solver)
>>> models.print_state()
Expand Down Expand Up @@ -219,23 +219,23 @@ for that object or returns ``None`` otherwise.
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> viscous = pyfluent.Viscous(settings_source=solver)
>>> viscous = pyfluent.solver.Viscous(settings_source=solver)
>>> viscous.model.allowed_values()
['inviscid', 'laminar', 'k-epsilon-standard', 'k-omega-standard', 'mixing-length', 'spalart-allmaras', 'k-kl-w', 'transition-sst', 'reynolds-stress', 'scale-adaptive-simulation', 'detached-eddy-simulation', 'large-eddy-simulation']
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> viscous = pyfluent.Viscous(settings_source=solver)
>>> viscous = pyfluent.solver.Viscous(settings_source=solver)
>>> viscous.model.get_attr('allowed-values')
['inviscid', 'laminar', 'k-epsilon-standard', 'k-omega-standard', 'mixing-length', 'spalart-allmaras', 'k-kl-w', 'transition-sst', 'reynolds-stress', 'scale-adaptive-simulation', 'detached-eddy-simulation', 'large-eddy-simulation']
.. code-block::
>>> import ansys.fluent.core as pyfluent
>>> viscous = pyfluent.Viscous(settings_source=solver)
>>> viscous = pyfluent.solver.Viscous(settings_source=solver)
>>> viscous.model.get_attrs(['allowed-values'])
{'allowed-values': ['inviscid', 'laminar', 'k-epsilon', 'k-omega', 'mixing-length', 'spalart-allmaras', 'k-kl-w', 'transition-sst', 'reynolds-stress', 'scale-adaptive-simulation', 'detached-eddy-simulation', 'large-eddy-simulation']}
Expand Down Expand Up @@ -303,7 +303,7 @@ in a single solver session:
>>> solver.settings.file.read(file_type="case", file_name=import_file_name)
Fast-loading...
...Done
>>> viscous = pyfluent.Viscous(settings_source=solver)
>>> viscous = pyfluent.solver.Viscous(settings_source=solver)
>>> viscous.is_active()
True
>>> viscous.model.is_read_only()
Expand All @@ -322,7 +322,7 @@ in a single solver session:
'scale-adaptive-simulation',
'detached-eddy-simulation',
'large-eddy-simulation']
>>> cold_inlet = pyfluent.VelocityInlet(settings_source=solver, name="cold-inlet")
>>> cold_inlet = pyfluent.solver.VelocityInlet(settings_source=solver, name="cold-inlet")
>>> cold_inlet.turb_intensity.min()
0
>>> cold_inlet.turb_intensity.max()
Expand All @@ -339,7 +339,7 @@ The ``get_active_child_names()`` method returns a list of
active children::

>>> import ansys.fluent.core as pyfluent
>>> models = pyfluent.Models(settings_source=solver)
>>> models = pyfluent.solver.Models(settings_source=solver)
>>> models.get_active_child_names()
['energy', 'multiphase', 'viscous']

Expand All @@ -355,14 +355,14 @@ You can use wildcards when using named objects, list objects, and string list se
For named objects and list objects, for instance::

>>> import ansys.fluent.core as pyfluent
>>> fluid = pyfluent.FluidCellZone(settings_source=solver, name="*")
>>> fluid = pyfluent.solver.FluidCellZone(settings_source=solver, name="*")
>>> fluid.source_terms["*mom*"]()
{'fluid': {'source_terms': {'x-momentum': [], 'y-momentum': [], 'z-momentum': []}}}

Also, when you have one or more velocity inlets with "inlet" in their names::

>>> import ansys.fluent.core as pyfluent
>>> inlet = pyfluent.VelocityInlet(settings_source=solver, name="*inlet*")
>>> inlet = pyfluent.solver.VelocityInlet(settings_source=solver, name="*inlet*")
>>> inlet.vmag()
{'velo-inlet_2': {'vmag': {'option': 'value', 'value': 50}},
'velo-inlet_1': {'vmag': {'option': 'value', 'value': 35}}
Expand Down
4 changes: 2 additions & 2 deletions examples/00-fluent/species_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@

from pathlib import Path # noqa: E402

from ansys.fluent.core import ( # noqa: E402
from ansys.fluent.core.examples import download_file # noqa: E402
from ansys.fluent.core.solver import ( # noqa: E402
Contour,
Energy,
Mesh,
Expand All @@ -82,7 +83,6 @@
Viscous,
WallBoundary,
)
from ansys.fluent.core.examples import download_file # noqa: E402

# %%
# Mesh
Expand Down
5 changes: 0 additions & 5 deletions src/ansys/fluent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
warning,
)

try:
from ansys.fluent.core.generated.solver.settings_builtin import * # noqa: F401, F403
except (ImportError, AttributeError, SyntaxError):
pass

_VERSION_INFO = None
"""Global variable indicating the version of the PyFluent package - Empty by default"""

Expand Down
11 changes: 11 additions & 0 deletions src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ def configure_container_dict(
container_dict["environment"] = {}
container_dict["environment"]["FLUENT_NO_AUTOMATIC_TRANSCRIPT"] = "1"

if (
os.getenv("REMOTING_NEW_DM_API") == "1"
or os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1"
):
if "environment" not in container_dict:
container_dict["environment"] = {}
if os.getenv("REMOTING_NEW_DM_API") == "1":
container_dict["environment"]["REMOTING_NEW_DM_API"] = "1"
if os.getenv("REMOTING_MAPPED_NEW_DM_API") == "1":
container_dict["environment"]["REMOTING_MAPPED_NEW_DM_API"] = "1"

fluent_commands = ["-gu", f"-sifile={container_server_info_file}"] + args

container_dict_default = {}
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ def _del_item(self, key: str) -> None:
# On-deleted subscription objects are unsubscribed after the datamodel
# object is deleted.
self[key].add_on_deleted(
lambda _: self.service.subscriptions.unsubscribe_while_deleting(
lambda: self.service.subscriptions.unsubscribe_while_deleting(
self.rules, se_path, "after"
)
)
Expand Down
6 changes: 6 additions & 0 deletions src/ansys/fluent/core/solver/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""The top-level module of PyFluent providing solver-related functionality."""

try:
from ansys.fluent.core.generated.solver.settings_builtin import * # noqa: F401, F403
except (ImportError, AttributeError, SyntaxError):
pass
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/solver/settings_builtin_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Data for for builtin setting classes."""

from ansys.fluent.core import FluentVersion
from ansys.fluent.core.utils.fluent_version import FluentVersion

# {<class name>: (<kind>, <path>)}
DATA = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def _process_streaming(self, id, stream_begin_method, started_evt, *args, **kwar
elif response.HasField("commandAttributeChangedEventResponse"):
value = response.commandAttributeChangedEventResponse.value
cb[1](_convert_variant_to_value(value))
elif (
response.HasField("modifiedEventResponse")
or response.HasField("deletedEventResponse")
or response.HasField("affectedEventResponse")
):
elif response.HasField(
"modifiedEventResponse"
) or response.HasField("affectedEventResponse"):
cb[1](cb[0])
elif response.HasField("deletedEventResponse"):
cb[1]()
elif response.HasField("commandExecutedEventResponse"):
command = response.commandExecutedEventResponse.command
args = _convert_variant_to_value(
Expand Down
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from ansys.fluent.core.utils.file_transfer_service import RemoteFileTransferStrategy
from ansys.fluent.core.utils.fluent_version import FluentVersion

sys.path.append(Path(__file__).parent / "util")


def pytest_addoption(parser):
parser.addoption(
Expand Down Expand Up @@ -383,3 +385,16 @@ def periodic_rot_settings_session(new_solver_session):
@pytest.fixture
def disable_datamodel_cache(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(pyfluent, "DATAMODEL_USE_STATE_CACHE", False)


@pytest.fixture(params=["old", "new"])
def datamodel_api_version_all(request, monkeypatch: pytest.MonkeyPatch) -> None:
if request.param == "new":
monkeypatch.setenv("REMOTING_NEW_DM_API", "1")
monkeypatch.setenv("REMOTING_MAPPED_NEW_DM_API", "1")


@pytest.fixture
def datamodel_api_version_new(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("REMOTING_NEW_DM_API", "1")
monkeypatch.setenv("REMOTING_MAPPED_NEW_DM_API", "1")
2 changes: 1 addition & 1 deletion tests/test_builtin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

try:
from ansys.fluent.core import (
from ansys.fluent.core.solver import (
Ablation,
Battery,
BoundaryCondition,
Expand Down
Loading

0 comments on commit 5ccf183

Please sign in to comment.