Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
84 changes: 42 additions & 42 deletions doc/source/cheatsheet/cheat_sheet.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ solver = pyfluent.launch_fluent(

```{python}
fluent = pyfluent.connect_to_fluent(
ip="127.0.0.1",
port=50000,
ip="127.0.0.1",
port=50000,
password="abcdefg")
```

Expand Down Expand Up @@ -392,7 +392,7 @@ solution.run_calculation.iterate(iter_count=100)
from ansys.fluent.core import examples
from ansys.fluent.core.filereader.case_file import CaseFile
case_file_name = examples.download_file(
"Static_Mixer_Parameters.cas.h5",
"Static_Mixer_Parameters.cas.h5",
"pyfluent/static_mixer")
reader = CaseFile(case_file_name=case_file_name)
reader.precision()
Expand Down Expand Up @@ -432,7 +432,7 @@ from ansys.fluent.core.filereader.data_file import DataFile
from ansys.fluent.core.filereader.case_file import CaseFile
data_file_name = examples.download_file("elbow1.dat.h5", "pyfluent/file_session")
reader = DataFile(
data_file_name=data_file_name,
data_file_name=data_file_name,
case_file_handle=CaseFile(case_file_name))
reader.case_file
reader.variables()
Expand Down Expand Up @@ -461,10 +461,10 @@ fs.fields.field_info.get_scalar_fields_info()
from ansys.fluent.core import examples
from ansys.fluent.core.file_session import FileSession
case_file_name = examples.download_file(
"mixing_elbow_mul_ph.cas.h5",
"mixing_elbow_mul_ph.cas.h5",
"pyfluent/file_session")
data_file_name = examples.download_file(
"mixing_elbow_mul_ph.dat.h5",
"mixing_elbow_mul_ph.dat.h5",
"pyfluent/file_session")
fs = FileSession()
fs.read_case(case_file_name)
Expand Down Expand Up @@ -525,11 +525,11 @@ velocity_vector.display("w3")
import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples
case_path = examples.download_file(
file_name="exhaust_system.cas.h5",
file_name="exhaust_system.cas.h5",
directory="pyfluent/exhaust_system"
)
data_path = examples.download_file(
file_name="exhaust_system.dat.h5",
file_name="exhaust_system.dat.h5",
directory="pyfluent/exhaust_system"
)
solver = pyfluent.launch_fluent(
Expand All @@ -545,21 +545,21 @@ field_data = solver.fields.field_data
```{python}
from ansys.fluent.core.services.field_data import SurfaceDataType
data = field_data.get_surface_data(
surfaces=["inlet"],
surfaces=["inlet"],
data_types=[SurfaceDataType.Vertices]
)
data["inlet"][SurfaceDataType.Vertices].shape
data["inlet"][SurfaceDataType.Vertices][5]
faces_normal_and_centroid_data = field_data.get_surface_data(
data_types=[SurfaceDataType.FacesNormal,
data_types=[SurfaceDataType.FacesNormal,
SurfaceDataType.FacesCentroid],
surfaces=["inlet"]
)
inlet = faces_normal_and_centroid_data["inlet"]
inlet[SurfaceDataType.FacesNormal].shape
inlet[SurfaceDataType.FacesCentroid][15]
faces_connectivity_data = field_data.get_surface_data(
data_types=[SurfaceDataType.FacesConnectivity],
data_types=[SurfaceDataType.FacesConnectivity],
surfaces=["inlet"]
)
inlet = faces_connectivity_data["inlet"]
Expand All @@ -570,7 +570,7 @@ inlet[SurfaceDataType.FacesConnectivity][5]

```{python}
abs_press_data = field_data.get_scalar_field_data(
field_name="absolute-pressure",
field_name="absolute-pressure",
surfaces=["inlet"]
)
abs_press_data["inlet"].shape
Expand All @@ -581,7 +581,7 @@ abs_press_data["inlet"][120]

```{python}
velocity_vector_data = field_data.get_vector_field_data(
field_name="velocity",
field_name="velocity",
surfaces=["inlet", "inlet1"]
)
velocity_vector_data["inlet"].shape
Expand All @@ -592,7 +592,7 @@ velocity_vector_data["inlet1"].shape

```{python}
path_lines_data = field_data.get_pathlines_field_data(
field_name="velocity",
field_name="velocity",
surfaces=["inlet"]
)
path_lines_data["inlet"]["vertices"].shape
Expand Down Expand Up @@ -638,10 +638,10 @@ solver1 = pyfluent.launch_fluent(
mode=pyfluent.FluentMode.SOLVER
)
case_path = download_file(
file_name="exhaust_system.cas.h5",
file_name="exhaust_system.cas.h5",
directory="pyfluent/exhaust_system")
data_path = download_file(
file_name="exhaust_system.dat.h5",
file_name="exhaust_system.dat.h5",
directory="pyfluent/exhaust_system")
solver1.settings.file.read_case_data(
file_name=case_path
Expand All @@ -651,11 +651,11 @@ solver2 = pyfluent.launch_fluent(
mode=pyfluent.FluentMode.SOLVER
)
case_path = download_file(
"elbow1.cas.h5",
"elbow1.cas.h5",
"pyfluent/file_session"
)
data_path = download_file(
"elbow1.dat.h5",
"elbow1.dat.h5",
"pyfluent/file_session"
)
solver2.settings.file.read_case_data(
Expand All @@ -676,7 +676,7 @@ solver.fields.reduction.area(
locations=[inlet["inlet1"]]
)
solver.fields.reduction.area(
locations=["inlet1"],
locations=["inlet1"],
ctxt=solver)
```

Expand Down Expand Up @@ -767,7 +767,7 @@ zone_info.zone_type

```{python}
wall_fluid_info = solution_variable_info.get_variables_info(
zone_names=['wall' , "fluid"],
zone_names=['wall' , "fluid"],
domain_name="mixture")
wall_fluid_info.solution_variables
solution_variable_info_centroid = wall_fluid_info['SV_CENTROID']
Expand All @@ -782,7 +782,7 @@ solution_variable_info_centroid.field_type
```{python}
sv_t_wall_fluid= solution_variable_data.get_data(
variable_name="SV_T",
zone_names=["fluid", "wall"],
zone_names=["fluid", "wall"],
domain_name="mixture")
sv_t_wall_fluid.domain
sv_t_wall_fluid.zones
Expand Down Expand Up @@ -814,14 +814,14 @@ solution_variable_data.set_data(
transaction = solver.fields.field_data.new_transaction()

transaction.add_surfaces_request(
surfaces=[1],
data_types=[SurfaceDataType.Vertices,
surfaces=[1],
data_types=[SurfaceDataType.Vertices,
SurfaceDataType.FacesCentroid]
)
transaction.add_scalar_fields_request(
surfaces=[1, 2],
field_name="pressure",
node_value=True,
surfaces=[1, 2],
field_name="pressure",
node_value=True,
boundary_value=True
)
transaction.add_vector_fields_request(
Expand Down Expand Up @@ -862,11 +862,11 @@ import_case = examples.download_file(
import_data = examples.download_file(
file_name="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
)
solver.file.read_case_data(file_name=import_case)
solver.settings.file.read_case_data(file_name=import_case)
# check the active report plot monitors using the settings relevant object
solver.settings.solution.monitor.report_plots()
# initialize so that monitors object is usable
solver.solution.initialization.hybrid_initialize()
solver.settings.solution.initialization.hybrid_initialize()
# check which monitors are available
sorted(solver.monitors.get_monitor_set_names())
# create and register a callback function that will
Expand Down Expand Up @@ -896,7 +896,7 @@ def display_monitor_table(
register_id = solver.monitors.register_callback(
display_monitor_table())
# run the solver and see the full tabulated monitor data on each iteration
solver.solution.run_calculation.iterate(
solver.settings.solution.run_calculation.iterate(
iter_count=10)
```

Expand Down Expand Up @@ -969,21 +969,21 @@ from ansys.fluent.core import examples
from ansys.fluent.core.utils.file_transfer_service import StandaloneFileTransferStrategy

mesh_file_name = examples.download_file(
"mixing_elbow.msh.h5",
"mixing_elbow.msh.h5",
"pyfluent/mixing_elbow")
meshing_session = pyfluent.launch_fluent(
mode=pyfluent.FluentMode.MESHING,
mode=pyfluent.FluentMode.MESHING,
file_transfer_service=
StandaloneFileTransferStrategy())
meshing_session.upload(
file_name=mesh_file_name,
file_name=mesh_file_name,
remote_file_name="elbow.msh.h5")
meshing_session.meshing.File.ReadMesh(
FileName="elbow.msh.h5")
meshing_session.meshing.File.WriteMesh(
FileName="write_elbow.msh.h5")
meshing_session.download(
file_name="write_elbow.msh.h5",
file_name="write_elbow.msh.h5",
local_directory="<local_directory_path>")
```

Expand All @@ -995,21 +995,21 @@ from ansys.fluent.core import examples
from ansys.fluent.core.utils.file_transfer_service import ContainerFileTransferStrategy

case_file_name = examples.download_file(
"mixing_elbow.cas.h5",
"mixing_elbow.cas.h5",
"pyfluent/mixing_elbow")
solver_session = pyfluent.launch_fluent(
mode=pyfluent.FluentMode.SOLVER,
mode=pyfluent.FluentMode.SOLVER,
file_transfer_service=
ContainerFileTransferStrategy())
solver_session.upload(
file_name=case_file_name,
file_name=case_file_name,
remote_file_name="elbow.cas.h5")
solver_session.file.read_case(
solver_session.settings.file.read_case(
file_name="elbow.cas.h5")
solver_session.file.write_case(
solver_session.settings.file.write_case(
file_name="write_elbow.cas.h5")
solver_session.download(
file_name="write_elbow.cas.h5",
file_name="write_elbow.cas.h5",
local_directory="<local_directory_path>")
```

Expand Down Expand Up @@ -1044,7 +1044,7 @@ import ansys.fluent.core as pyfluent
pyfluent.search("font")

# Whole word search
pyfluent.search("ApplicationFontSize",
pyfluent.search("ApplicationFontSize",
match_whole_word=True)

# Wildcard pattern search
Expand Down Expand Up @@ -1081,8 +1081,8 @@ import ansys.fluent.core as pyfluent
os.environ["ANSYSLMD_LICENSE_FILE"] = "<license file or server>"

custom_config = {
'fluent_image': 'ansys_inc:latest',
'mount_source': f"{os.getcwd()}",
'fluent_image': 'ansys_inc:latest',
'mount_source': f"{os.getcwd()}",
'auto_remove': False}

solver = pyfluent.launch_fluent(
Expand Down
6 changes: 3 additions & 3 deletions doc/source/user_guide/fields/reduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Functional:
>>> reduction.area_average(
... expression=VariableCatalog.ABSOLUTE_PRESSURE,
... locations=solver_session.setup.boundary_conditions.velocity_inlet,
... locations=solver_session.settings.setup.boundary_conditions.velocity_inlet,
... )
101957.2452989816
Expand All @@ -271,8 +271,8 @@ Object-Oriented:
>>> reduction.minimum(
... expression=VariableCatalog.ABSOLUTE_PRESSURE,
... locations=solver1.setup.boundary_conditions.pressure_outlet
... + solver2.setup.boundary_conditions.pressure_outlet,
... locations=solver1.settings.setup.boundary_conditions.pressure_outlet
... + solver2.settings.setup.boundary_conditions.pressure_outlet,
... )
101325.0
Expand Down
18 changes: 9 additions & 9 deletions doc/source/user_guide/file_transfer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
File transfer
=============

PyFluent provides a file transfer service that manages how files are uploaded to and downloaded from the Fluent server.
This service allows file-based API methods like `read_case()` and `write_mesh()` to work seamlessly—even when Fluent is running remotely,
PyFluent provides a file transfer service that manages how files are uploaded to and downloaded from the Fluent server.
This service allows file-based API methods like `read_case()` and `write_mesh()` to work seamlessly—even when Fluent is running remotely,
in a container, or in a PIM-managed environment.

Depending on how Fluent is launched, different file transfer strategies are available:

1. **PIM file transfer service**

When launching Fluent through the `Product Instance Management (PIM) <https://pypim.docs.pyansys.com/version/stable/>`_ file transfer is fully automated.
When launching Fluent through the `Product Instance Management (PIM) <https://pypim.docs.pyansys.com/version/stable/>`_ file transfer is fully automated.
You don’t need to call `upload()` or `download()`—files are transferred transparently when you use file-based API methods.

Use this service when:
Expand All @@ -29,13 +29,13 @@ Depending on how Fluent is launched, different file transfer strategies are avai
>>> case_file = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")

>>> session = pyfluent.launch_fluent()
>>> session.file.read_case(file_name=case_file)
>>> session.file.write_case(file_name="write_mixing_elbow.cas.h5")
>>> session.settings.file.read_case(file_name=case_file)
>>> session.settings.file.write_case(file_name="write_mixing_elbow.cas.h5")


2. **Container file transfer service**

When Fluent runs in a Docker container, files cannot be shared directly between client and server.
When Fluent runs in a Docker container, files cannot be shared directly between client and server.
The remote file transfer service uses a gRPC-based mechanism to manage transfers.

Use this service when:
Expand All @@ -56,13 +56,13 @@ Depending on how Fluent is launched, different file transfer strategies are avai
>>> file_transfer_service = ContainerFileTransferStrategy()
>>> container_dict = {"mount_source": file_transfer_service.mount_source}
>>> session = pyfluent.launch_fluent(file_transfer_service=file_transfer_service, container_dict=container_dict)
>>> session.file.read_case(file_name=case_file)
>>> session.file.write_case(file_name="write_mixing_elbow.cas.h5")
>>> session.settings.file.read_case(file_name=case_file)
>>> session.settings.file.write_case(file_name="write_mixing_elbow.cas.h5")


3. **Standalone file transfer service**

When Fluent is launched in standalone mode on the same machine as the Python client, files can be accessed directly from the local file system.
When Fluent is launched in standalone mode on the same machine as the Python client, files can be accessed directly from the local file system.
In this case, the local file transfer service is used.

Use this service when:
Expand Down
6 changes: 3 additions & 3 deletions doc/source/user_guide/monitors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Using monitors
Monitors in PyFluent allow you to dynamically observe the convergence of
your solution by tracking the values of solution variables and residuals.
They enable you to visualize the progress of the solver, helping ensure that
the solution is progressing as expected and allowing you to diagnose issues
the solution is progressing as expected and allowing you to diagnose issues
early on.

You can integrate PyFluent's monitor callback mechanism with visualization
Expand Down Expand Up @@ -49,7 +49,7 @@ callback mechanism to perform a simple tabulation of monitored values per iterat
>>> "point-vel-rplot",
>>> "residual"
>>> ]
>>> # create and register a callback function that will
>>> # create and register a callback function that will
>>> def display_monitor_table(monitor_set_name="mass-bal-rplot"):
>>> def display_table():
>>> data = solver_session.monitors.get_monitor_set_data(monitor_set_name=monitor_set_name)
Expand All @@ -73,4 +73,4 @@ callback mechanism to perform a simple tabulation of monitored values per iterat
>>>
>>> register_id = solver_session.monitors.register_callback(display_monitor_table())
>>> # run the solver and see the full tabulated monitor data on each iteration
>>> solver_session.solution.run_calculation.iterate(iter_count=10)
>>> solver_session.settings.solution.run_calculation.iterate(iter_count=10)
4 changes: 2 additions & 2 deletions doc/source/user_guide/physical_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Here’s how to use ``VariableCatalog`` to read and reduce field data using unit

solver_session = launch_fluent()
case_path = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
solver_session.file.read(file_type="case", file_name=case_path)
solver_session.settings.file.read(file_type="case", file_name=case_path)

solver_session.settings.solution.initialization.hybrid_initialize()

Expand Down Expand Up @@ -67,7 +67,7 @@ You can also use physical quantities in report definitions to improve clarity an
surface_report.field = temperature # Note: using VariableCatalog, not a string
surface_report.surface_names = locations

result = solver_session.solution.report_definitions.compute(report_defs=["avg_temp"])
result = solver_session.settings.solution.report_definitions.compute(report_defs=["avg_temp"])
print(result[0]["avg_temp"][0])

Notes
Expand Down
Loading
Loading