Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions ansys/dpf/core/fields_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,11 @@ def animate(self, save_as=None, deform_by=None, scale_factor=1.0, **kwargs):
# Define the field extraction using the fields_container and indices
extract_field_op = dpf.core.operators.utility.extract_field(self)

loop_over = self.get_time_scoping()
frequencies = self.time_freq_support.time_frequencies
Copy link
Contributor

Choose a reason for hiding this comment

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

@PProfizi I don't understand this changes, it means that we can't animate if we don't have a time freq support?

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 That was already the case, I just moved this up. Right now the animation is based on the TimeFreqSupport, yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

to add in the US to handle having no time freq support and to be able to create an animator with a mesh + a fields container

if frequencies is None:
raise ValueError("The fields_container has no time_frequencies.")

# TODO /!\ We should be using a mechanical::time_selector, however it is not wrapped.

wf.set_input_name("indices", extract_field_op.inputs.indices) # Have to do it this way
Expand All @@ -543,8 +548,8 @@ def animate(self, save_as=None, deform_by=None, scale_factor=1.0, **kwargs):
f"!= len(self)={len(self)}).")
else:
deform = False
if deform:

if deform:
scale_factor_fc = dpf.core.animator.scale_factor_to_fc(scale_factor, deform_by)
scale_factor_invert = dpf.core.operators.math.invert_fc(scale_factor_fc)
# Extraction of the field of interest based on index
Expand All @@ -559,22 +564,12 @@ def animate(self, save_as=None, deform_by=None, scale_factor=1.0, **kwargs):

divide_op = dpf.core.operators.math.component_wise_divide(
extract_field_op_2.outputs.field, extract_scale_factor_op.outputs.field)
# Get the mesh from the field to render
get_mesh_op = dpf.core.operators.mesh.from_field(extract_field_op.outputs.field)
# Get the coordinates field from the mesh
get_coordinates_op = dpf.core.operators.mesh.node_coordinates(get_mesh_op.outputs.mesh)
# Addition to the scaled deformation field
add_op = dpf.core.operators.math.add(divide_op.outputs.field,
get_coordinates_op.outputs.coordinates_as_field)
wf.set_output_name("deform_by", add_op.outputs.field)
add_op.progress_bar = False
wf.set_output_name("deform_by", divide_op.outputs.field)
else:
scale_factor = None
wf.set_output_name("to_render", extract_field_op.outputs.field)
wf.progress_bar = False

loop_over = self.get_time_scoping()
frequencies = self.time_freq_support.time_frequencies
loop_over_field = dpf.core.fields_factory.field_from_array(
frequencies.data[loop_over.ids-1])
loop_over_field.scoping.ids = loop_over.ids
Expand Down
4 changes: 2 additions & 2 deletions examples/05-plotting/06-animate_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@

# import copy
# camera_pos_list = []
# init_pos = [(2.341999327925363, 2.2535751881950388, 3.241992870018055),
# (0.10000000000000725, 0.01157586026968312, 0.9999935420927001),
# init_pos = [(1.1710286191854873, 1.1276044794551632, 1.62102216127818),
# (0.05000000000000724, 0.006575860269683119, 0.4999935420927001),
# (0.0, 0.0, 1.0)]
# camera_pos_list.append(init_pos)
# for i in range(1, len(displacement_fields)):
Expand Down