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

Feat/plot warped mesh #269

Merged
merged 19 commits into from
Jul 5, 2022
Merged

Feat/plot warped mesh #269

merged 19 commits into from
Jul 5, 2022

Conversation

PProfizi
Copy link
Contributor

This PR adds the possibility to use a result to warp the mesh with.
This result should give a 3D vector field.

This enables for example the plotting of deformed geometries by giving as input a displacement result at a specific time step:
disp_result = model.results.displacement.on_time_scoping([step])
mesh.plot(warping_field=disp_result, scaling_factor=scaling_factor)

@PProfizi PProfizi self-assigned this Jun 29, 2022
@PProfizi PProfizi added enhancement New feature or request examples Related to PyDPF-Core examples labels Jun 29, 2022
@codecov
Copy link

codecov bot commented Jun 29, 2022

Codecov Report

Merging #269 (3471545) into master (4e7d7d5) will increase coverage by 0.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
+ Coverage   86.22%   86.32%   +0.10%     
==========================================
  Files          52       52              
  Lines        5661     5697      +36     
==========================================
+ Hits         4881     4918      +37     
+ Misses        780      779       -1     

Remove treatment of kwarg show_axes in add_point_labels as only kwargs for pv.add_point_labels are supposed to be supported there, and it has nothing to do here.
This should increase test coverage of the PR to 100%.
@@ -262,12 +264,20 @@ def plot(self, shell_layers=None, **kwargs):
shell_layers : shell_layers, optional
Enum used to set the shell layers if the model to plot
contains shell elements. The default is ``None``.
scaling_result : result operator, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

This class name will reflect poorly in the doc, the real type name needs to be used.
I also think that restricting the input type to "Result" is not a good idea, Operators (maybe even Field and Fields Containers) should be supported. "Result" is a helper but not a main DPF entity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbellot000 I am not sure I understand how we would scale by an Operator other than a Result Operator. Also I thought it was just a specific type of Operator. The problem here is that if I put "Operator" as input type in the docstring and it only supports Result operators, there might be issues.
As for Field and FieldsContainer support, it can be done. I just wanted to get a first feature out there.

ansys/dpf/core/plotter.py Outdated Show resolved Hide resolved
title='MeshedRegion', text='MeshedRegion.plot(disp_field)')

# Split the model by material and plot the deformed MeshesContainer obtained
split_mesh_op = dpf.Operator("split_mesh")
Copy link
Contributor

Choose a reason for hiding this comment

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

old operator syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbellot000 Reworked

setup.py Outdated Show resolved Hide resolved
@PProfizi PProfizi requested a review from cbellot000 July 1, 2022 11:56
@PProfizi PProfizi merged commit 136d109 into master Jul 5, 2022
@PProfizi PProfizi deleted the feat/plot_warped_mesh branch July 5, 2022 14:47
cbellot000 pushed a commit that referenced this pull request Jul 8, 2022
* WIP

* Fixed MeshedRegion.plot(warped)

* Clean example

* Finish adding scale factor text

* Add show_axes=True as default when plotting

* Forcing protobuf to less than 4.*

* Fix error when warping_field is None for MeshesContainer.plot

* Refactor name of argument as "warp_by"
Update docstrings

* Fix coordinates as optional in _as_vtk

* Refactor the first test with more pythonic and newer API calls.

* Renamed the mesh warp method to scale_coordinates_by_result

* Rename scaling method, and fixed an error

* Rename parameter to scaling_result

* Remove unused DpfPlotter.update_mesh
Remove treatment of kwarg show_axes in add_point_labels as only kwargs for pv.add_point_labels are supposed to be supported there, and it has nothing to do here.
This should increase test coverage of the PR to 100%.

* Improve operator instantiations in example

* Renamed scaling_result as deform_by, scaling_factor as scale_factor, and changed the docstring for deform_by.

* Show support for Field, Operator, Result or FieldsContainer as a deform_by argument for plotting.
# Conflicts:
#	ansys/dpf/core/meshed_region.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request examples Related to PyDPF-Core examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants