.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\04-advanced\14-incremental_evaluation.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_04-advanced_14-incremental_evaluation.py: .. _ref_incremental_evaluation: Use incremental evaluation helper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This example shows you how to use the incremental evaluation helper. .. GENERATED FROM PYTHON SOURCE LINES 9-15 .. code-block:: Python # Import necessary modules from ansys.dpf import core as dpf from ansys.dpf.core import examples .. GENERATED FROM PYTHON SOURCE LINES 16-17 Retrieve an example to instantiate a DataSources object .. GENERATED FROM PYTHON SOURCE LINES 17-29 .. code-block:: Python path = examples.download_transient_result() ds = dpf.DataSources(path) # From the DataSources object we can retrieve the scoping # In this example we want to compute the min/max for all the time sets tf_provider = dpf.operators.metadata.time_freq_provider(data_sources=ds) tf_support = tf_provider.get_output(output_type=dpf.types.time_freq_support) scoping = dpf.time_freq_scoping_factory.scoping_on_all_time_freqs(tf_support) # If you don't need to reuse TimeFreqSupport you could also use the DataSources # scoping = dpf.time_freq_scoping_factory.scoping_on_all_time_freqs(ds) .. GENERATED FROM PYTHON SOURCE LINES 30-31 Defining the workflow to exploit .. GENERATED FROM PYTHON SOURCE LINES 31-43 .. code-block:: Python # Instantiating a streams_provider is important when dealing with incremental evaluation # due to multiple reuses of operators streams_provider = dpf.operators.metadata.streams_provider(data_sources=ds) # Defining the main workflow result_op = dpf.operators.result.stress( data_sources=ds, time_scoping=scoping, streams_container=streams_provider ) norm_fc = dpf.operators.math.norm_fc(result_op) final_op = dpf.operators.min_max.min_max_fc_inc(norm_fc) .. GENERATED FROM PYTHON SOURCE LINES 44-45 Obtain a new operator to retrieve outputs from .. GENERATED FROM PYTHON SOURCE LINES 45-65 .. code-block:: Python # Workflow is adapted from the first and the last operator in the current workflow # Scoping is important to split the workload into chunks new_end_op = dpf.split_workflow_in_chunks(result_op, final_op, scoping) # Obtain results on the same pin numbers min = new_end_op.get_output(0, dpf.types.field) max = new_end_op.get_output(1, dpf.types.field) # Plot results import matplotlib.pyplot as plt x = tf_support.time_frequencies.data plt.plot(x, min.data, "b", label="Min") plt.plot(x, max.data, "r", label="Max") plt.xlabel("Time") plt.ylabel("Stress") plt.legend() plt.show() .. image-sg:: /examples/04-advanced/images/sphx_glr_14-incremental_evaluation_001.png :alt: 14 incremental evaluation :srcset: /examples/04-advanced/images/sphx_glr_14-incremental_evaluation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Estimating chunk_size with max_bytes: 1073741824 Done. chunk_size set to 35 (scoping size: 35) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.268 seconds) .. _sphx_glr_download_examples_04-advanced_14-incremental_evaluation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 14-incremental_evaluation.ipynb <14-incremental_evaluation.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 14-incremental_evaluation.py <14-incremental_evaluation.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_