.. 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 example demonstrates how to launch PyTurboGrid, load a blade model by reading an inf file, and generate a mesh. The example also demonstrates how to query mesh statistics for the mesh. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: default import json import os.path as ospath .. GENERATED FROM PYTHON SOURCE LINES 19-20 It is assumed that the ``ansys-turbogrid-core`` package has been installed. .. GENERATED FROM PYTHON SOURCE LINES 20-22 .. code-block:: default from ansys.turbogrid.core.launcher.launcher import get_turbogrid_exe_path, launch_turbogrid .. GENERATED FROM PYTHON SOURCE LINES 23-24 Launch a TurboGrid instance in the most basic way. .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: default turbogrid = launch_turbogrid() .. GENERATED FROM PYTHON SOURCE LINES 27-29 Find the examples folder based on the path to the TurboGrid executable found by the call below to ``get_turbogrid_exe_path``. This ensures that the examples folder from the current TurboGrid installation is used. .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: default 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 35-36 Ensure the examples folder exists. .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: default if not ospath.isdir(examples_path_str): print("examples folder not found in the TurboGrid installation") exit() .. GENERATED FROM PYTHON SOURCE LINES 41-42 Read the BladeGen \*.inf file for the rotor37 example. .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: default turbogrid.read_inf(examples_path_str + "/rotor37/BladeGen.inf") .. GENERATED FROM PYTHON SOURCE LINES 45-46 Generate a mesh with the default settings. .. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: default turbogrid.unsuspend(object="/TOPOLOGY SET") .. GENERATED FROM PYTHON SOURCE LINES 49-50 Get the mesh statistics from the current session. .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: default stats = turbogrid.query_mesh_statistics() .. GENERATED FROM PYTHON SOURCE LINES 53-55 Print out the mesh statistics in a format suitable for reading. json serializer can print nested dictionary content with indentation and formatting. .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: default print("Mesh statistics:", json.dumps(stats, indent=2)) .. GENERATED FROM PYTHON SOURCE LINES 58-59 Save the mesh. .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. code-block:: default turbogrid.save_mesh(filename="rotor37.gtm") .. GENERATED FROM PYTHON SOURCE LINES 62-63 Quit the TurboGrid session. .. GENERATED FROM PYTHON SOURCE LINES 63-64 .. code-block:: default turbogrid.quit() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _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-python :download:`Download Python source code: basic_read_inf_rotor37.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: basic_read_inf_rotor37.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_