Skip to content

Commit

Permalink
feat: Move the direct settings classes under ansys.fluent.core.solver…
Browse files Browse the repository at this point in the history
… namespace (#3572)

Co-authored-by: Prithwish Mukherjee <[email protected]>
  • Loading branch information
mkundu1 and prmukherj authored Dec 16, 2024
1 parent 887210b commit ba1ff61
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 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
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
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

0 comments on commit ba1ff61

Please sign in to comment.