Skip to content
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

Example/example re assembling fields #1726

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

luisaFelixSalles
Copy link
Collaborator

This new example shows how to do some matrix operations, including basic mathematical operation (power, add and multiply by
a constant, add field containers and invert ) and separating and assembling fields and fields containers

@luisaFelixSalles luisaFelixSalles added the examples Related to PyDPF-Core examples label Sep 3, 2024
@luisaFelixSalles luisaFelixSalles self-assigned this Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.65%. Comparing base (52c4ce8) to head (06dee83).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1726      +/-   ##
==========================================
- Coverage   86.93%   86.65%   -0.29%     
==========================================
  Files          83       83              
  Lines        9937     9937              
==========================================
- Hits         8639     8611      -28     
- Misses       1298     1326      +28     

@rafacanton
Copy link
Contributor

@luisaFelixSalles Thanks for the example. I think it would be good to have a follow-up on this one to explain users how to create their own matrix fields "by hand". Dpf Matrix Fields are created "by column" and not "by row", and we are not documenting it anywhere. This also affects the way the generalized_dot_product operator is working.

@PProfizi This caused a bug in the past, so I think it is something we would like to properly document. In addition, it works differently in numpy, so it is not very straigthforward to use without an example

@PProfizi
Copy link
Contributor

PProfizi commented Sep 4, 2024

@luisaFelixSalles Thanks for the example. I think it would be good to have a follow-up on this one to explain users how to create their own matrix fields "by hand". Dpf Matrix Fields are created "by column" and not "by row", and we are not documenting it anywhere. This also affects the way the generalized_dot_product operator is working.

@PProfizi This caused a bug in the past, so I think it is something we would like to properly document. In addition, it works differently in numpy, so it is not very straigthforward to use without an example

@luisaFelixSalles I think this remark could go both in a specific tutorial on Field creation, and in the User Guide documentation.

Copy link
Contributor

@PProfizi PProfizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice example, just a few things to change

examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
import ansys.dpf.core.operators.math as maths

###############################################################################
# Open an example and print the ``Model`` object. Here a result file from a crankshaft
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Open an example and print the ``Model`` object. Here a result file from a crankshaft
# Load an example and print the ``Model`` object. Here a result file from a crankshaft

#
my_model = dpf.Model(examples.find_complex_rst())
my_mesh = my_model.metadata.meshed_region
# print(my_model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why comment the print?

examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
Comment on lines 88 to 90
# There are different methods to re-assemble the components

# 1) With the class :class:'assemble_scalars_to_matrices_fc <ansys.dpf.core.operators.utility.assemble_scalars_to_matrices_fc.assemble_scalars_to_matrices_fc>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now there is only one

examples/01-mathematical-operations/matrix-operations.py Outdated Show resolved Hide resolved
@luisaFelixSalles luisaFelixSalles mentioned this pull request Sep 6, 2024
3 tasks
Co-authored-by: Paul Profizi <100710998+PProfizi@users.noreply.github.com>
Co-authored-by: Paul Profizi <100710998+PProfizi@users.noreply.github.com>
luisaFelixSalles and others added 2 commits September 26, 2024 09:20
Co-authored-by: Paul Profizi <100710998+PProfizi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Related to PyDPF-Core examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants