-
Notifications
You must be signed in to change notification settings - Fork 25
Add a new example 00-basic_dpf_implementation.py #1709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
# # ~~~~~~~ DPF PRESENTATION ~~~~~~~ # # | ||
|
||
# Ansys Data Processing Framework (DPF) provides a modular and easy to use toolbox for accessing and transforming | ||
# simulation data using the DPF operators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luisaFelixSalles ok so here this example ends-up being an in-depth explanation on how to use operators in PyDPF-Core.
As we are discussing right now, maybe we will not actually put this as a basic usage example.
# DPF package is named : 'ansys.dpf.core package'. This package contains (based in the 2024 doc version): | ||
# a) Three subpackages: | ||
# - 'ansys.dpf.core.examples' package | ||
# - 'ansys.dpf.core.helpers' namespace | ||
# - 'ansys.dpf.core.operators' package | ||
# b) Sixty three submodules | ||
# - 'animation', 'animator', 'any', 'available_result', 'collection', 'collection_base', 'common', | ||
# 'Operator config', 'core', 'custom_fields_container', 'custom_operator_base', 'custom_type_field', | ||
# 'cyclic_support', 'data_sources', 'data_tree', 'dimensionality', 'dpf_array', 'dpf_operator', 'elements', | ||
# 'element_descriptor', 'errors', 'faces', 'field','fields_definition', 'fields_container', | ||
# 'fields_container_factory', 'fields_factory', 'generic_data_container', 'generic_support','normalize_vector', | ||
# 'create_point', 'incremental', 'inputs', 'meshed_region', 'meshes_container', 'mesh_info', | ||
# 'mesh_scoping_factory', 'model', 'nodes', 'operator_specification', 'outputs', 'path_utilities', 'plotter', | ||
# 'plugins', 'property_field', 'results', 'result_info', 'runtime_config', 'scoping', 'scopings_container', | ||
# 'server', 'server_context', 'server_factory', 'server_types', 'session', 'settings', 'streams_container', | ||
# 'string_field', 'support', 'time_freq_scoping_factory', 'time_freq_support', 'unit_system', 'workflow' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this should be in the example.
We can describe this in the doc, like in the user guide.
The ansys.dpf.core.operators
submodule can be presented in the example on operators, to explain that their Python wrappers are there.
The ansys.dpf.core.helpers
I think we can make several dedicated examples about.
And the ansys.dpf.core.examples
submodule may require a short introduction in the main page for examples, but not much more.
# This package also have its subpackages: | ||
# - 'ansys.dpf.core.operators.averaging' package | ||
# - 'ansys.dpf.core.operators.compression' namespace | ||
# - 'ansys.dpf.core.operators.filter' package | ||
# - 'ansys.dpf.core.operators.geo' package | ||
# - 'aansys.dpf.core.operators.invariant package' package | ||
# - 'ansys.dpf.core.operators.logic' package | ||
# - 'ansys.dpf.core.operators.mapping' package | ||
# - 'ansys.dpf.core.operators.math' package | ||
# - 'ansys.dpf.core.operators.mesh' package | ||
# - 'ansys.dpf.core.operators.metadata' package | ||
# - 'ansys.dpf.core.operators.min_max' package | ||
# - 'ansys.dpf.core.operators.result' package | ||
# - 'ansys.dpf.core.operators.scoping' package | ||
# - 'ansys.dpf.core.operators.serialization' package | ||
# - 'ansys.dpf.core.operators.server' package | ||
# - 'ansys.dpf.core.operators.utility' package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply say there are categories of operators, and maybe give a short description of each category
|
||
# The basic steps for using the operators are: | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# 1) Instance the operator. There are two ways for doing this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 1) Instance the operator. There are two ways for doing this: | |
# 1) Instantiate the operator. There are two ways for doing this: |
# If you believe you'll be using multiple modules available in the same package, its better to import it all | ||
# at the beginning | ||
from ansys.dpf.core import operators as ops # Import of the dpf core subpackage 'ansys.dpf.core.operators' | ||
my_operator = ops.subpackageAttribute.operatorAttribute() # I use the word attribute for any name following a dot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, one thing to keep in mind, is that the examples are run in the CI. So they need to actually be working scripts.
If you want to make a generic example, you can put it as text in a comment.
|
||
# We will use the 1.1 method | ||
from ansys.dpf.core import operators as ops | ||
my_operator = ops.subpackageAttribute.operatorAttribute(parameterName=expectedDataType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, this is non-working code.
my_displacement_operator=ops.result.displacement(data_sources=my_displacement_ds) | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# 3) Get the computed result from the output pin. There are two ways for doing this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 3) Get the computed result from the output pin. There are two ways for doing this: | |
# 3) Evaluate an output of the operator. There are two ways for doing this: |
# 2) Connect the operator input pin, this allows the user to pass on his data to the operator. | ||
# Every operator have at least one imperative input pin. There are two ways for doing this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 2) Connect the operator input pin, this allows the user to pass on his data to the operator. | |
# Every operator have at least one imperative input pin. There are two ways for doing this: | |
# 2) Connect input data to the an operator input pin. | |
# Every operator has at least one mandatory input pin. | |
# There are two ways for connecting data to an operator input: |
# 4) Chain operators. You can attach one operator’s outputs to another operator’s inputs to chain operators together. | ||
# This allows you to create a workflow to create more complex operations and customizable results.DPF evaluates each | ||
# operator only when the final operator is evaluated and the data is requested. So the order that you connect the | ||
# operators is important. There are three ways for doing this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 4) Chain operators. You can attach one operator’s outputs to another operator’s inputs to chain operators together. | |
# This allows you to create a workflow to create more complex operations and customizable results.DPF evaluates each | |
# operator only when the final operator is evaluated and the data is requested. So the order that you connect the | |
# operators is important. There are three ways for doing this: | |
# 4) Chain operators. You can attach an operator output to another operator input to chain them together. | |
# This allows you to create a workflow to create more complex operations and customizable results. Operators in the workflow run only when requesting evaluation of an affiliated workflow output. | |
# There are three ways of doing this: |
my_min_max_operator = ops.min_max.min_max(my_displacement_operator) | ||
|
||
###################################################################################################################### | ||
# # ~~~~~~~ THE OPERATORS ~~~~~~~ # # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A global comment: please use the RST ways of defining sections and titles. See https://github.com/ralsina/rst-cheatsheet/blob/master/rst-cheatsheet.rst
No description provided.