Conversation
|
AS a PyFluent user, what is the advantage gained if I use the local service versus using no service? |
@seanpearsonuk User can specify remote file name while uploading and local directory while downloading the Fluent files. cc: @mkundu1 |
|
Hi @hpohekar, thanks for putting this together. I think the documentation has a good foundation, but it currently undersells the feature and misses the opportunity to highlight its most user-friendly capabilities. A few thoughts and suggestions:
I used Chat GPT to help make some improvements based on the above points and the following code block should be used as a basis. However, it is crucial to proof-read it for inaccuracies as I can see that some things look a bit off the mark (it lacks complete context) while I already corrected some other details. .. _ref_file_transfer_guide:
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, in a container, or in a PIM-managed environment.
Depending on how Fluent is launched, different file transfer strategies are available:
1. **Local 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. In this case, the local file transfer service is used.
Use this service when:
- Fluent is running locally.
- You want to ensure explicit control over file movement using `upload()` and `download()`.
Example:
.. code-block:: python
>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import LocalFileTransferStrategy
>>> mesh_file = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
>>> session = pyfluent.launch_fluent(mode=pyfluent.FluentMode.MESHING,
... file_transfer_service=LocalFileTransferStrategy())
>>> session.upload(file_name=mesh_file, remote_file_name="elbow.msh.h5")
>>> session.meshing.File.ReadMesh(FileName="elbow.msh.h5")
>>> session.meshing.File.WriteMesh(FileName="write_elbow.msh.h5")
>>> session.download(file_name="write_elbow.msh.h5", local_directory="<local_path>")
2. **Remote file transfer service**
When Fluent runs in a Docker container or another remote environment, 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:
- Fluent is running in container mode or remotely.
- You need to transfer files explicitly between environments.
Example:
.. code-block:: python
>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import RemoteFileTransferStrategy
>>> case_file = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> session = pyfluent.launch_fluent(file_transfer_service=RemoteFileTransferStrategy())
>>> session.upload(file_name=case_file, remote_file_name="elbow.cas.h5")
>>> session.file.read_case(file_name="elbow.cas.h5")
>>> session.file.write_case(file_name="write_elbow.cas.h5")
>>> session.download(file_name="write_elbow.cas.h5", local_directory="<local_path>")
3. **PIM file transfer service**
When launching Fluent through the Product Instance Management (PIM), 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:
- You launch Fluent using PIM.
- You want seamless file transfers without needing to manage them directly.
Example:
.. code-block:: python
>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> 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")
Defining your own file transfer service
---------------------------------------
Advanced users can define a custom file transfer strategy and use it when launching Fluent:
.. code-block:: python
>>> pyfluent.launch_fluent(file_transfer_service=<your_custom_strategy>)
(Instructions for creating a custom strategy are beyond the scope of this guide.) |
@seanpearsonuk Done. Thank you. |
|
@seanpearsonuk This PR is ready. |
seanpearsonuk
left a comment
There was a problem hiding this comment.
This looks like a distinct upgrade. Thanks.
|
Looks much more readable and clear now. |
closes #3907
Update file transfer docs.