diff --git a/ansys/dpf/core/fields_container.py b/ansys/dpf/core/fields_container.py index 5ac36c5c313..f983090083e 100644 --- a/ansys/dpf/core/fields_container.py +++ b/ansys/dpf/core/fields_container.py @@ -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 + 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 @@ -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 @@ -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 diff --git a/examples/05-plotting/06-animate_results.py b/examples/05-plotting/06-animate_results.py index feae81c8025..fe969ebfe3c 100644 --- a/examples/05-plotting/06-animate_results.py +++ b/examples/05-plotting/06-animate_results.py @@ -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)):