.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/basic_read_inf_rotor37.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_basic_read_inf_rotor37.py: .. _read_inf_rotor37: Basic mesh generation --------------------- This basic example shows how to launch PyTurboGrid, load a blade model by reading an INF file, and generate a mesh. .. GENERATED FROM PYTHON SOURCE LINES 34-42 Model overview ~~~~~~~~~~~~~~ .. image:: ../_static/rotor37_overview.png :width: 400 :alt: Model overview. :align: center .. GENERATED FROM PYTHON SOURCE LINES 44-48 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform the required imports. It is assumed that the ``ansys-turbogrid-core`` package has been installed. .. GENERATED FROM PYTHON SOURCE LINES 48-55 .. code-block:: Python import json import os.path as ospath from ansys.turbogrid.core.launcher.launcher import get_turbogrid_exe_path, launch_turbogrid .. GENERATED FROM PYTHON SOURCE LINES 57-60 Launch TurboGrid instance ~~~~~~~~~~~~~~~~~~~~~~~~~ Launch a TurboGrid instance in the most basic way. .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python turbogrid = launch_turbogrid() .. GENERATED FROM PYTHON SOURCE LINES 64-69 Find TurboGrid examples ~~~~~~~~~~~~~~~~~~~~~~~ Find the ``examples`` folder for TurboGrid based on the path to the directory where it is installed. Calling the ``get_turbogrid_exe_path()`` method ensures use of the ``examples`` folder in the current TurboGrid installation. .. GENERATED FROM PYTHON SOURCE LINES 69-75 .. code-block:: Python exec_path = get_turbogrid_exe_path() turbogrid_install_location = "/".join(exec_path.parts[:-2]) turbogrid_install_location = turbogrid_install_location.replace("\\", "") examples_path_str = turbogrid_install_location + "/examples" .. GENERATED FROM PYTHON SOURCE LINES 76-79 Ensure folder with examples exists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ensure that the ``examples`` folder exists. .. GENERATED FROM PYTHON SOURCE LINES 79-84 .. code-block:: Python if not ospath.isdir(examples_path_str): print("examples folder not found in the TurboGrid installation") exit() .. GENERATED FROM PYTHON SOURCE LINES 85-88 Read file for rotor37 example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Read the BladeGen INF file for the rotor37 example. .. GENERATED FROM PYTHON SOURCE LINES 88-91 .. code-block:: Python turbogrid.read_inf(examples_path_str + "/rotor37/BladeGen.inf") .. GENERATED FROM PYTHON SOURCE LINES 92-95 Generate mesh ~~~~~~~~~~~~~ Generate a mesh with the default settings. .. GENERATED FROM PYTHON SOURCE LINES 95-98 .. code-block:: Python turbogrid.unsuspend(object="/TOPOLOGY SET") .. GENERATED FROM PYTHON SOURCE LINES 99-102 Get mesh statistics ~~~~~~~~~~~~~~~~~~~ Get the mesh statistics from the current session. .. GENERATED FROM PYTHON SOURCE LINES 102-105 .. code-block:: Python stats = turbogrid.query_mesh_statistics() .. GENERATED FROM PYTHON SOURCE LINES 106-111 Print mesh statistics ~~~~~~~~~~~~~~~~~~~~~ Print the mesh statistics in a format suitable for reading. A JSON serializer can print nested dictionary content with indentation and formatting. .. GENERATED FROM PYTHON SOURCE LINES 111-114 .. code-block:: Python print("Mesh statistics:", json.dumps(stats, indent=2)) .. GENERATED FROM PYTHON SOURCE LINES 115-118 Save mesh ~~~~~~~~~ Save the mesh. .. GENERATED FROM PYTHON SOURCE LINES 118-121 .. code-block:: Python turbogrid.save_mesh(filename="rotor37.gtm") .. GENERATED FROM PYTHON SOURCE LINES 122-125 Quit session ~~~~~~~~~~~~~ Quit the TurboGrid session. .. GENERATED FROM PYTHON SOURCE LINES 125-127 .. code-block:: Python turbogrid.quit() .. _sphx_glr_download_examples_basic_read_inf_rotor37.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: basic_read_inf_rotor37.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: basic_read_inf_rotor37.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_