From 98fde684368809327ebc224c107f8542e87b46ad Mon Sep 17 00:00:00 2001 From: Rajesh Meena <60212378+rajesh1359@users.noreply.github.com> Date: Wed, 14 Aug 2024 01:35:03 +0530 Subject: [PATCH 1/5] Fixes the mesh deformation for mode shape animation This commit make deform_by default for mode animation. --- src/ansys/dpf/core/animation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/dpf/core/animation.py b/src/ansys/dpf/core/animation.py index 87073956d7..ed418e6e0f 100644 --- a/src/ansys/dpf/core/animation.py +++ b/src/ansys/dpf/core/animation.py @@ -96,6 +96,7 @@ def animate_mode( wf.set_input_name("ponderation", scaling_op.inputs.ponderation) wf.set_output_name("field", scaling_op.outputs.field) + wf.set_output_name("deform_by", scaling_op.outputs.field) anim = Animator(workflow=wf, **kwargs) From 7faf7848759832574daefba106c3758140adc5e8 Mon Sep 17 00:00:00 2001 From: Rajesh Meena <60212378+rajesh1359@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:01:54 +0530 Subject: [PATCH 2/5] pass deformation scaling factor to animator This fix transfers deformation scale factor to animator --- src/ansys/dpf/core/animation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/dpf/core/animation.py b/src/ansys/dpf/core/animation.py index ed418e6e0f..b0b0ddf739 100644 --- a/src/ansys/dpf/core/animation.py +++ b/src/ansys/dpf/core/animation.py @@ -107,5 +107,6 @@ def animate_mode( save_as=save_as, mode_number=mode_number, clim=[0, max_data], + scale_factor=deform_scale_factor, **kwargs, ) From 27d47aabd14300ec8c5be79281ff4a1fdb8d5ff4 Mon Sep 17 00:00:00 2001 From: Rajesh Meena <60212378+rajesh1359@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:03:03 +0530 Subject: [PATCH 3/5] making use of scale factor per frame This fix adds use of scale factor per frame --- src/ansys/dpf/core/animator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/dpf/core/animator.py b/src/ansys/dpf/core/animator.py index a799a8c5e2..31581b47af 100644 --- a/src/ansys/dpf/core/animator.py +++ b/src/ansys/dpf/core/animator.py @@ -98,6 +98,7 @@ def render_frame(frame): self.add_field( field, deform_by=deform, + scale_factor=scale_factor[frame], scale_factor_legend=scale_factor[frame], **kwargs, ) From 6b31ec6f2c81d8a90321c717a9a1dd6792bbc68b Mon Sep 17 00:00:00 2001 From: Rajesh Meena <60212378+rajesh1359@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:38:05 +0530 Subject: [PATCH 4/5] Handling integer type scale factor This change handles integer type scale factor in animator. ideally integer type scale factor should be acceptable by scale operator. --- src/ansys/dpf/core/animator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/core/animator.py b/src/ansys/dpf/core/animator.py index 31581b47af..a8e67673c4 100644 --- a/src/ansys/dpf/core/animator.py +++ b/src/ansys/dpf/core/animator.py @@ -47,7 +47,7 @@ def animate_workflow( scale_factor = [False] * len(indices) type_scale = type(scale_factor) if type_scale in [int, float]: - scale_factor = [scale_factor] * len(indices) + scale_factor = [float(scale_factor)] * len(indices) elif type_scale == list: pass # elif type_scale in [core.field.Field, core.fields_container.FieldsContainer]: From 4594606274b5f287aa47520568e0e3c4ddae6cdc Mon Sep 17 00:00:00 2001 From: Rajesh Meena Date: Thu, 15 Aug 2024 00:46:22 +0530 Subject: [PATCH 5/5] add mode number and mode frequency in plotter text --- src/ansys/dpf/core/animation.py | 13 +++++++++++++ src/ansys/dpf/core/animator.py | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ansys/dpf/core/animation.py b/src/ansys/dpf/core/animation.py index b0b0ddf739..55e23ac017 100644 --- a/src/ansys/dpf/core/animation.py +++ b/src/ansys/dpf/core/animation.py @@ -71,7 +71,18 @@ def animate_mode( ) # Get fields + available_mode_numbers = fields_container.get_available_ids_for_label("time") + + + if not mode_number in available_mode_numbers: + raise ValueError( + f"The mode {mode_number} data is not available in field container." + ) fields_mode = fields_container.get_fields({"time": mode_number}) + mode_frequencies_field = fields_container.time_freq_support.time_frequencies + mode_frequencies = mode_frequencies_field.data + mode_frequency = mode_frequencies[available_mode_numbers.index(mode_number)] + # Merge fields if needed if len(fields_mode) > 1: @@ -84,6 +95,7 @@ def animate_mode( max_data = float(np.max(field_mode.data)) loop_over = dpf.fields_factory.field_from_array(scale_factor_per_frame) + loop_over.unit = mode_frequencies_field.unit # Create workflow wf = dpf.Workflow() @@ -106,6 +118,7 @@ def animate_mode( output_name="field", save_as=save_as, mode_number=mode_number, + mode_frequency = mode_frequency, clim=[0, max_data], scale_factor=deform_scale_factor, **kwargs, diff --git a/src/ansys/dpf/core/animator.py b/src/ansys/dpf/core/animator.py index a8e67673c4..930fd97f51 100644 --- a/src/ansys/dpf/core/animator.py +++ b/src/ansys/dpf/core/animator.py @@ -36,6 +36,7 @@ def animate_workflow( input_name="loop_over", save_as="", mode_number=None, + mode_frequency = None, scale_factor=1.0, **kwargs, ): @@ -109,9 +110,9 @@ def render_frame(frame): str_template.format(indices[frame], unit, freq_fmt), **kwargs_in ) else: - str_template = "frq={0:{2}} {1}" + str_template = "mode={3}\nfrq={0:{2}} {1}" self._plotter.add_text( - str_template.format(mode_number, unit, freq_fmt), **kwargs_in + str_template.format(mode_frequency, unit, freq_fmt, mode_number), **kwargs_in ) if cpos: