.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/gallery_examples/00-mapdl-examples/slashmap_cfx_mapping.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_gallery_examples_00-mapdl-examples_slashmap_cfx_mapping.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_gallery_examples_00-mapdl-examples_slashmap_cfx_mapping.py:


.. _ref_cfx_mapping:

=============================================
CFX pressure data mapping to structural blade
=============================================

The objective of this test is to demonstrate CFX pressure data mapping to
structural 11 blade model in PyMAPDL.

Description
===========

The 11 blade model along with a fictitious disk is modeled. CFX generated
pressure data is used as input.

The test uses a CFX exported pressure data to map. Pressure file
correspond to a certain vibrating blade mode (vibrating mode 1
approximately 534 Hz)and to a certain pressure mode (pressure mode 1
also the same 534 Hz mode). However, due to lack of data for another
mode this same file will be assumed to represent other mode
combinations (vib mode 2 press mode 2) (vib mode 1 press mode 2)
(vib mode 2 press mode 1).

.. GENERATED FROM PYTHON SOURCE LINES 26-32

.. code-block:: default


    from datetime import datetime

    from ansys.mapdl.core import launch_mapdl
    from ansys.mapdl.core.examples import download_cfx_mapping_example_data








.. GENERATED FROM PYTHON SOURCE LINES 33-36

Downloading files
=================


.. GENERATED FROM PYTHON SOURCE LINES 36-41

.. code-block:: default

    files_path = download_cfx_mapping_example_data()

    db_file_path = files_path["model"]
    pressure_file_path = files_path["data"]








.. GENERATED FROM PYTHON SOURCE LINES 42-45

Launch MAPDL service
====================


.. GENERATED FROM PYTHON SOURCE LINES 45-52

.. code-block:: default


    mapdl = launch_mapdl()

    mapdl.title(
        "Verify Pressure Data Mapping exported from CFX on Structural 11 Blade Model"
    )





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    TITLE= 
     Verify Pressure Data Mapping exported from CFX on Structural 11 Blade Model



.. GENERATED FROM PYTHON SOURCE LINES 53-57

Upload files to the instance
============================

Uploading files

.. GENERATED FROM PYTHON SOURCE LINES 57-61

.. code-block:: default

    mapdl.upload(db_file_path)
    mapdl.upload(pressure_file_path)






.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    Uploading ExampleMapping.db:   0%|          | 0.00/24.6M [00:00<?, ?B/s]
    Uploading ExampleMapping.db: 100%|##########| 24.6M/24.6M [00:00<00:00, 810MB/s]

    Uploading 11_blades_mode_1_ND_0.csv:   0%|          | 0.00/828k [00:00<?, ?B/s]
    Uploading 11_blades_mode_1_ND_0.csv: 100%|##########| 828k/828k [00:00<00:00, 1.15GB/s]

    '11_blades_mode_1_ND_0.csv'



.. GENERATED FROM PYTHON SOURCE LINES 62-66

Pressure mapping
================

Resume the database from the example mapping file

.. GENERATED FROM PYTHON SOURCE LINES 66-92

.. code-block:: default

    mapdl.resume("ExampleMapping", "db")
    mapdl.esel("s", "type", "", 1)
    mapdl.cm("BladeElem", "elem")

    # Write CDB file
    mapdl.allsel()
    mapdl.cdwrite("all", "baseModel", "cdb")
    mapdl.finish()

    # Start the mapping processor and record the start time
    start_time = datetime.now()
    mapdl.slashmap()  # mapdl.slashmap(**kwargs); Enters the mapping processor.
    print("Enter the Mapping Processor")

    # Specifies the target nodes for mapping pressures onto surface effect elements.
    mapdl.run("target,pressure_faces")

    # Specifies the file type and pressure type for the subsequent import of source points and pressures.
    mapdl.ftype(filetype="cfxtbr", prestype="1")
    # Read the CFX exported file containing pressure data Blade 2, Export Surface 1
    mapdl.read(fname="11_blades_mode_1_ND_0.csv")

    # Perform the pressure mapping from source points to target surface elements.
    # Interpolation is done on a surface (default).
    print(mapdl.map(kdim="2", kout="1"))





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Enter the Mapping Processor
    MAP SOURCE DATA TO TARGET NODES
      INTERPOLATE ON A SURFACE
      MAXIMUM NUMBER OF NEAREST POINTS TO EXAMINE=  20
      SET RESULTS OUTSIDE OF REGION TO ZERO

     NON-ZERO PRESSURES APPLIED TO  9963 TARGET FACES (OUT OF 10622 DEFINED BY SURF154s)
      MIN REAL PRESSURE =  -2816.        MAX REAL PRESSURE =   4408.    
      MIN IMAG PRESSURE =  -5189.        MAX IMAG PRESSURE =   5754.




.. GENERATED FROM PYTHON SOURCE LINES 93-97

Plot mapping
============

Plot the geometries and mappings

.. GENERATED FROM PYTHON SOURCE LINES 97-119

.. code-block:: default

    mapdl.show("png,rev")
    mapdl.plgeom(item="BOTH")  # Plot both target and source geometries (default).
    mapdl.plmap(item="target")
    mapdl.plmap(item="target", imagkey="1")
    mapdl.plmap(item="source")
    mapdl.plmap(item="source", imagkey="1")
    mapdl.plmap(item="both")
    mapdl.plmap(item="both", imagkey="1")

    # Close the plot and write the mapped data to a file
    mapdl.show("close")
    mapdl.writemap("mappedHI.dat")

    # Print the mapping completion message and duration
    print("Mapping Completed")
    end_time = datetime.now()
    c = end_time - start_time
    seconds = c.total_seconds()
    print("\nDuration in seconds for Mapping is  : ", seconds)

    mapdl.eplot()




.. image-sg:: /examples/gallery_examples/00-mapdl-examples/images/sphx_glr_slashmap_cfx_mapping_001.png
   :alt: slashmap cfx mapping
   :srcset: /examples/gallery_examples/00-mapdl-examples/images/sphx_glr_slashmap_cfx_mapping_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Mapping Completed

    Duration in seconds for Mapping is  :  2.56985




.. GENERATED FROM PYTHON SOURCE LINES 120-122

Stop MAPDL


.. GENERATED FROM PYTHON SOURCE LINES 122-124

.. code-block:: default

    mapdl.finish()
    mapdl.exit()








.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  4.377 seconds)


.. _sphx_glr_download_examples_gallery_examples_00-mapdl-examples_slashmap_cfx_mapping.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example




    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: slashmap_cfx_mapping.py <slashmap_cfx_mapping.py>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: slashmap_cfx_mapping.ipynb <slashmap_cfx_mapping.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_