Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seamless File Handling - Ansys Lab #2138

Merged
merged 52 commits into from
Nov 1, 2023

Conversation

hpohekar
Copy link
Collaborator

@hpohekar hpohekar commented Oct 13, 2023

  • Design primary interface.
  • Test in the Ansys Lab.
  • Refactor code - removed duplication.
  • Again tested in the Ansys Lab.
  • Create a separate module FileTransferService.
  • Separated pypim upload and download methods.
  • Fix a regression for local sessions.
  • Separate upload and download methods.
  • Integrate remote file handler.
  • Test in the Ansys Lab
  • Test local sessions.

We were doing following steps to read and write a case file in the Ansys Lab

meshing.upload(file_path="read/elbow.cas.h5", remote_file_name="uploaded_elbow.cas.h5")
meshing.tui.file.read_case("uploaded_elbow.cas.h5")
meshing.tui.file.write_case("written_sample_elbow_tui.cas.h5")
meshing.download(file_name="written_sample_elbow_tui.cas.h5", local_file_path=".")

Now we are handling upload and download part internally. So, we just need to execute following steps to read and write a case file.

meshing.read_case("read/elbow.cas.h5")
meshing.write_case("write_meshing_sample_elbow.cas.h5")
  • upload to upload files if pypim is configured.
  • download to download files if pypim is configured.

image

----------------------------------------------------

image

------------------------------------------------------

image

image

--------------------------------------------------------

image

@hpohekar hpohekar linked an issue Oct 13, 2023 that may be closed by this pull request
@hpohekar hpohekar marked this pull request as ready for review October 13, 2023 11:21
@hpohekar hpohekar linked an issue Oct 13, 2023 that may be closed by this pull request
@raph-luc
Copy link
Member

@hpohekar there was a new 2024 R1 container release about 2 hours ago, that is probably why the tests are failing, going to create an issue tracker for this

@hpohekar
Copy link
Collaborator Author

hpohekar commented Oct 13, 2023

@hpohekar there was a new 2024 R1 container release about 2 hours ago, that is probably why the tests are failing, going to create an issue tracker for this

@raph-luc I see. Thanks for the update. These are failing in both this and #2131 PR.

@raph-luc raph-luc mentioned this pull request Oct 13, 2023
@hpohekar
Copy link
Collaborator Author

These methods will work for both local PyFluent sessions and Ansys Lab. We are handling it on basis of whether PyPIM is configured or not.

@hpohekar You are right, sorry for my confusion: I had misunderstood what _pypim_upload() does. The docstring and function name are misleading in my opinion, it only uploads using PyPIM if it is configured, if it is not then it just executes the callback defined (going to make a separate suggestion regarding this)

@raph-luc No worries at all. Your suggestion will be helpful. Thank you.

Copy link
Member

@raph-luc raph-luc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to my previous points: the discussion with @seanpearsonuk made me realize that this read_case() implementation won't work with local/container Fluent sessions when specifying files not in the current working dir, i.e. inside folders or when providing an absolute path, as only the basename is being passed to the actual read command

@seanpearsonuk
Copy link
Collaborator

Related to my previous points: the discussion with @seanpearsonuk made me realize that this read_case() implementation won't work with local/container Fluent sessions when specifying files not in the current working dir, i.e. inside folders or when providing an absolute path, as only the basename is being passed to the actual read command

correct

@hpohekar
Copy link
Collaborator Author

Related to my previous points: the discussion with @seanpearsonuk made me realize that this read_case() implementation won't work with local/container Fluent sessions when specifying files not in the current working dir, i.e. inside folders or when providing an absolute path, as only the basename is being passed to the actual read command

Yes, I verified and your point is correct. I just realized that after refactoring I need to update file_name passed to on_uploaded callback.

@hpohekar
Copy link
Collaborator Author

hpohekar commented Oct 31, 2023

Local Solver session testing.

>>> from ansys.fluent.core import examples                                                    
>>> from ansys.fluent.core import launch_fluent 
>>> import_file_name = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
Checking if specified file already exists...
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.msh.h5
>>> solver = launch_fluent()
>>> solver.read_case(import_file_name)
pyfluent.settings_api WARNING: Mismatch between generated file and server object info. Dynamically created settings classes will be used.
Fast-loading "D:\ANSYSDev\vNNN\fluent\fluent24.1\\addons\afd\lib\hdfio.bin"
Done.
Multicore SMT processors detected. Processor affinity set!

Reading from AAPQ13pUvWxQtxN:"C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.msh.h5" in NODE0 mode ...
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     3 node zones ...

Building...
     mesh
     materials,
     interface,
     domains,
     zones,
        Skipping thread 20 of domain 1 (not referenced by grid).
        Skipping thread 21 of domain 1 (not referenced by grid).
        Skipping thread 22 of domain 1 (not referenced by grid).
        Skipping thread 23 of domain 1 (not referenced by grid).
        Skipping thread 24 of domain 1 (not referenced by grid).
        Skipping thread 25 of domain 1 (not referenced by grid).
        Skipping thread 26 of domain 1 (not referenced by grid).
        Skipping thread 27 of domain 1 (not referenced by grid).
        Skipping thread 28 of domain 1 (not referenced by grid).
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
Mesh is now scaled to meters.
>>> solver.read_case("mixing_elbow.msh.h5")
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.Multicore SMT processors detected. Processor affinity set!

       Clearing partially read grid.

Reading from AAPQ13pUvWxQtxN:"D:\hackathon\pyfluent\mixing_elbow.msh.h5" in NODE0 mode ...
  Reading mesh ...
       17822 cells,     1 cell zone  ...
          17822 mixed cells,  zone id: 87
       91581 faces,     7 face zones ...
           2168 polygonal wall faces,  zone id: 34
            268 polygonal wall faces,  zone id: 33
            155 polygonal pressure-outlet faces,  zone id: 32
            152 polygonal velocity-inlet faces,  zone id: 31
             55 polygonal velocity-inlet faces,  zone id: 30
           2001 polygonal symmetry faces,  zone id: 29
          86782 mixed interior faces,  zone id: 89
       66417 nodes,     3 node zones ...

Building...
     mesh
     materials,
     interface,
     domains,
     zones,
        Skipping thread 20 of domain 1 (not referenced by grid).
        Skipping thread 21 of domain 1 (not referenced by grid).
        Skipping thread 22 of domain 1 (not referenced by grid).
        Skipping thread 23 of domain 1 (not referenced by grid).
        Skipping thread 24 of domain 1 (not referenced by grid).
        Skipping thread 25 of domain 1 (not referenced by grid).
        Skipping thread 26 of domain 1 (not referenced by grid).
        Skipping thread 27 of domain 1 (not referenced by grid).
        Skipping thread 28 of domain 1 (not referenced by grid).
        wall-elbow
        wall-inlet
        outlet
        cold-inlet
        hot-inlet
        symmetry-xyplane
        interior--elbow-fluid
        elbow-fluid
     parallel,
Done.
Mesh is now scaled to meters.
>>> solver.write_case("latest_zzz.cas.h5")

Writing to AAPQ13pUvWxQtxN:"D:\hackathon\pyfluent\latest_zzz.cas.h5" in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
Warning: reading 2 partition grid onto 1 compute node machine.
         Combining every 2 partitions.
  Done.       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> solver.write_case("latest_zzz.cas.h5")

Writing to AAPQ13pUvWxQtxN:"D:\hackathon\pyfluent\latest_zzz.cas.h5" in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.
>>> solver.write_case("D:\hackathon\pyfluent\examples\latest_zzz.cas.h5")

Writing to AAPQ13pUvWxQtxN:"D:\hackathon\pyfluent\examples\latest_zzz.cas.h5" in NODE0 mode and compression level 1 ...
Grouping cells for Laplace smoothing ...
       17822 cells,     1 zone  ...
       91581 faces,     7 zones ...
       66417 nodes,     1 zone  ...
  Done.
Done.

@hpohekar
Copy link
Collaborator Author

Local Meshing session testing.

>>> from ansys.fluent.core import examples                                                    
>>> from ansys.fluent.core import launch_fluent
>>> import_file_name = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
Checking if specified file already exists...
File already exists. File path:
C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.msh.h5
>>> meshing = launch_fluent(mode="meshing")                               
>>> meshing.read_case(import_file_name)
Reading "C:\Users\hpohekar\AppData\Local\Ansys\ansys_fluent_core\examples\mixing_elbow.msh.h5" ...
3D mesh
nodes: 66417
edges: 300
faces: 91581
cells: 17822
reading 3 node zones
reading 9 edge zones
reading 7 face zones
reading 1 cell zones
updating sub-domains...
done.
generating pointers...done.
extracting boundary entities...
 13264 boundary nodes.
 4799 boundary faces.
 6 boundary face zones.
done.
generating cells...done.
analyzing boundary connectivity...done.
>>> meshing.read_case("mixing_elbow.msh.h5")
Reading "mixing_elbow.msh.h5" ...
copy file from "mixing_elbow.msh.h5" to "C:\\Users\\hpohekar\\\\mixing_elbow.msh.h5" 
file copy done
3D mesh
nodes: 66417
edges: 300
faces: 91581
cells: 17822
reading 3 node zones
reading 9 edge zones
reading 7 face zones
reading 1 cell zones
updating sub-domains...
done.
generating pointers...done.
extracting boundary entities...
 13264 boundary nodes.
 4799 boundary faces.
 6 boundary face zones.
done.
generating cells...done.
analyzing boundary connectivity...done.
>>> meshing.write_case("latest_yyy.cas.h5")

The case file is being written in the mesher mode.
Previously saved data files are incompatible and should not be read with this case file.

Writing "latest_yyy.cas.h5" ...
writing 3 node zones
writing 7 face zones 
writing 1 cell zones 
writing boundary layer flags
writing node curvature data...
>>> meshing.write_case("D:\hackathon\pyfluent\examples\latest_yyy.cas.h5")
done.
The case file is being written in the mesher mode.
Previously saved data files are incompatible and should not be read with this case file.

Writing "D:\hackathon\pyfluent\examples\latest_yyy.cas.h5" ...
writing 3 node zones
writing 7 face zones 
writing 1 cell zones 
writing boundary layer flags
writing node curvature data...
>>> meshing.exit()                                                        

@hpohekar hpohekar merged commit 2950945 into main Nov 1, 2023
18 checks passed
@hpohekar hpohekar deleted the feat/seamless_file_handling_refactored branch November 1, 2023 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move _Uploader from session.py to separate module Seamless file handling
4 participants