.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/00-basic/05-surface_traces_lic.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_00-basic_05-surface_traces_lic.py: .. _surface_traces_lic: Surface Restricted Traces and Line Integral Convolution ======================================================= Utilize EnSight to investigate two types of surface streamlines: * Surface Restricted Traces (using Particle Trace) * Line Integral Convolution (LIC) This example works with EnSight version 24.2 or later. .. GENERATED FROM PYTHON SOURCE LINES 18-22 Start an EnSight session ------------------------ Launch and connect to an instance of EnSight. This example uses a local EnSight installation. .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: Python from ansys.pyensight.core import LocalLauncher session = LocalLauncher().start() .. GENERATED FROM PYTHON SOURCE LINES 28-33 Load a dataset -------------- Load Shuttle Session file included in the EnSight installation and render .. image:: /_static/05_srt_lic_0.png .. GENERATED FROM PYTHON SOURCE LINES 33-42 .. code-block:: Python session.ensight.objs.ensxml_restore_file( f"{session.cei_home}/ensight{session.cei_suffix}gui/demos/Shuttle Basic.ens" ) session.ensight.view.highlight_parts("OFF") session.ensight.view_transf.fit(0) session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 43-50 Using Particle Trace to create Surface Restricted Traces -------------------------------------------------------- Using a Particle Trace capability Parent Part and Emit part are the same part. Surface Restriction is ON. .. image:: /_static/05_srt_lic_1.png .. GENERATED FROM PYTHON SOURCE LINES 50-67 .. code-block:: Python emitter_part = session.ensight.utils.parts.select_parts_by_dimension(2) parent_parts = emitter_part npts = 1500 # number of emitters SRTpart = session.ensight.utils.parts.create_particle_trace_from_parts( "SurfaceRestrictedTrace", "Momentum", parts=emitter_part, source_parts=parent_parts, direction="+/-", surface_restrict=True, num_points=npts, ) session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 68-74 Change Visual Attributes ------------------------ Modify the attributes of the Surface Restricted Traces to be visually closer to flourescene or titanium dioxide (experimental use) .. image:: /_static/05_srt_lic_2.png .. GENERATED FROM PYTHON SOURCE LINES 74-80 .. code-block:: Python SRTpart.colorbyrgb = [0, 1, 0] SRTpart.OPAQUENESS = 0.25 session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 81-90 Try Line Integral Convolution (LIC) instead ------------------------------------------- As we do not already have a near-surface, non-zero vector defined we need to create 'Offset' Variable. Create Offset Variable for Value of Momentum at 2.e-5 distance into fluid domain Specify Offset Variable as the variable for LIC Specify High Contrast and 1 length for LIC Specify that we want to see LIC for the Shuttle Surface .. image:: /_static/05_srt_lic_3.png .. GENERATED FROM PYTHON SOURCE LINES 90-102 .. code-block:: Python SRTpart.VISIBLE = False offset_var = session.ensight.utils.variables.calculator.offsetvar(["Shuttle"], "Momentum", 2.0e-5) current_case = session.ensight.objs.core.CURRENTCASE[0] current_case.SFTVARIABLE = offset_var current_case.SFTCONTRAST = True current_case.SFTNORMLENGTH = 1.0 session.ensight.objs.core.PARTS["Shuttle"][0].SHOWSFT = True session.show("image", width=800, height=600) .. GENERATED FROM PYTHON SOURCE LINES 103-106 Close the session ----------------- Close the connection and shut down the EnSight instance. .. GENERATED FROM PYTHON SOURCE LINES 106-109 .. code-block:: Python # sphinx_gallery_thumbnail_path = '_static/05_srt_lic_3.png' session.close() .. _sphx_glr_download__examples_00-basic_05-surface_traces_lic.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05-surface_traces_lic.ipynb <05-surface_traces_lic.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05-surface_traces_lic.py <05-surface_traces_lic.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05-surface_traces_lic.zip <05-surface_traces_lic.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_